Quantcast
Channel: Questions in topic: "static variables"
Browsing latest articles
Browse All 84 View Live

Using variables and classes of C# in Javascript?

Hello, I have a set of Javascript classes that each work on a number of static variables. The problem is that some of these static variables are obtained by calling a function which my friend...

View Article



Asign value of Attribute to static variable

Hi everybody, I'm attaching my Script "VisibilityScript" to some GameObjects with the following Editor-Script: class MyPostprocessor extends AssetPostprocessor { function...

View Article

What is the best way to implement Game States?

So I am trying to create an RPG, and off the top of my head I will need about 4 different game states that changes what button input does. The first would be the normal state (when your just walking...

View Article

Reset static variables

How can I reset a static variable? For my game i have a reset button however it does not reset my static variable. my static variable is: public static int Score = 0; and it is being called at: void...

View Article

Static Variable Doesn't Change ?

Hello Unity Community. I'm very anixous about a code :S There's a code i translate form C# to .js #pragma strict /////////////////////////////////////////////////////////// var startTime : float; var...

View Article


Static References to Game Objects: Bad Idea?

Hey guys, I'm relatively new to Unity, but I've been programming for some time now. Some friends and I are building a game and I had the idea of making a central manager that has references to certain...

View Article

Design Advice: Power Up System (static variables?)

hey there, I have a game in progress in which the player can fly around in 3d space and shoot weapons. I have various variables for the player like: movement speed, rate of fire, damage, hit points...

View Article

Static variables not staying

I'm creating a script so a player knows when they collect 5 coins in a row. For some reason, if there is too much time between coin collection Unity resets my variable back to 0...and I'm not sure what...

View Article


How to reset all static variables.

Hi, I have hundreds of static variables across dozens of scripts. In fact 1 script has almost 200 in, and there are 71 scripts. I am looking for a simple bug free way to reset all of these static...

View Article


Why are my static member variables null inside other classes/scripts?

In my application, there is a need for all of my strings to be multilingual. My first plan was to import key-value pairs as text assets and parse these per individual scene. Being rather new to Unity,...

View Article

how to keep static variables or 2d array value

I made a tilemap editor. Tilemap editor can make or edit 2d tiled terrain to use static values and 2d array. 2d array have terrain data. But when i play my game in unity editor, or updating my scene...

View Article

Multiple GameObjects accessing the same script, when script destroys game...

I'm making a shield system for the enemy ships. I have all of the shields running off of the same shield script, which seems to work fine other than when it destroys the game object. All of the ships...

View Article

Making my variable global.

I was trying to change the sprite image of my character from another scene. I made two scripts 1. Sprite_Img.js 2. changeTheSprite.js I have attached Sprite_Img.js to my character object and...

View Article


object reference required to to access non-static member, userSession

I'm trying to get userSession, a variable to put in to my highscore database but i keep getting object reference error. My SessionScript get the user's name that is logged in from the User table...

View Article

Static variable resetting when it shouldn't!

Hi! I have a problem with just one of my static variables and I have no idea why. It was working correctly just a day ago and now it isn't. A certain trigger is supposed to give the player one point,...

View Article


A Question about static, please help me.

Hello everyone, when i am learning Scripting "static", there is a question wrap me around. 1. What is the different between: - public static float a; - static public float a; 2. if a public function...

View Article

Start behavior only working when one instance of UI in scene

Hi there, I know I'm doing something obviously wrong but I can't seem to find the right words to search for.....so apologies for the n00bism. I have a class with a simple start function that takes the...

View Article


Static variable inside a function like in C ?

In C lang I could do something like this: void f() { static int a = 0; printf("%d\n", a); a++; } Calling this function 3 times would result in: 0 1 2 Is it possible to use static variables like this in...

View Article

How to access static members in the watch/immediate window when debugging...

I have been searching for an answer to this for a while and a great one would be really appreciated. Let's take the following scenario: I am in MonoDevelop on OSX, I placed a breakpoint in a class and...

View Article

Force reset static variable

After googling a bit, I've tried some methods to try to reset a static variable, but none of them want to work (Sure I'm doing some wrong steps). First I tried to Reset the value to 0, both via Start,...

View Article

Environment reset after plugin import kill all static variables.

Hey I'm trying to realize installer with settings in Editor for my own plugin. It should ask user about required parts of my plugin, download some zip and unitypackage files and import them to a...

View Article


How to reset a static variables on loading a scene...

How to reset a static variables on loading a scene [SceneManager.LoadScene(NameofScene)]. I tried to initialize variables in Start function or in Awake function but i find bad result.

View Article


Sound Clip isn't playing when triggered.

I want my kill streak sound to be triggered when the KSsound value reaches 250. However the sound doesn't play when the value reaches 250. using System.Collections; using System.Collections.Generic;...

View Article

Does reading/changing Static variables constantly affect Performance or get...

From the last question that i asked, @Bunny83 said: > `GUI.enabled` is just a state stored in an internal field. There is no overhead involved setting that state. So `GUI.enabled` is a static bool,...

View Article

load winning scene when completed race

I got this script that goes along with a checkpoint script, it has a static variable that counts how many laps the player has completed, what I want to do is load a winning scene or overlay when the...

View Article


How do I get these variables to work together!?

So this Script here using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerStats : MonoBehaviour { public int currentLevel; public int currentEXP; public...

View Article

Delegate value does not fall within the expected range

Hi, I am trying to pass an arbitrary function to be called inside a fixed function, which itself is called using `delegate` keyword through the `AddListener` function of `InputField.onEndEdit` event. I...

View Article

Get a float transferred between two scenes and scripts

I have two scenes, one where you type in the speed of a car via Input Field, and the next one, with a car with a script attached to it, with the float "speed". Script Nr. 1: public static class Data {...

View Article

How can i link a static string variable to another scene and display it?

Hi all, I am just starting to learn how to use Unity to create a simple 2D game, and i have encountered a issue. I try to search through forums and also follow the Unity tutorial...

View Article



Using static variables (or similar) to affect instances of the same object...

Hi everyone, So basically, I've got an RPG world with many of the same item (let's say it's a rock). I've been using static variables to keep data about the player between scenes, but I'm not sure of...

View Article
Browsing latest articles
Browse All 84 View Live




Latest Images