Personal Game Dev Note:
I wasn't allowed to drag my instance of the "_GameScoreKeeper" that was in the Hierarchy into the public "Game_Commander" type object slot on the "Target", but once I turned it into a prefab I was able to drop it in no problem.
Also, didn't declare it as a "GameObject", but as a "Game_Commander" after giving the object a Game_Commander Class script.
Also(2), don't forget to declare the method as "public", otherwise it's inaccessible to other scripts.
UPDATE (2013.SEP.18):
STATIC:
Use "Static" variables, methods, classes, etc. to declare something to be part of the CLASS itself, and not the INSTANCE of the class.
Statics
You can just use the dot operator "." to access the method, and don't need to instantiate an object of that class to use it's members.
Entire classes can be static. However, STATIC classes can not be instantiated.
NON-STATIC:
Non static variables and methods belong to the instance of the class.
ENABLE / DISABLE USING IF-STATEMENTS
Use this technique to disable GUI Buttons, etc.
PROPERTIES:
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
Monday, September 9, 2013
UNITY: Adding Vector Data
Figured out Vector data can be added together as variables. Example:
" private Vector2 offset = new Vector2(200, 200);
private Vector2 screenDim = new Vector2( Screen.width, Screen.height );
private Vector2 textLocation = new Vector2( (Screen.width / -2), (Screen.height / -2));
void WriteCountText()
{
countText.pixelOffset = textLocation + offset;
countText.text = "Count: " + count2.ToString();
}
"
" private Vector2 offset = new Vector2(200, 200);
private Vector2 screenDim = new Vector2( Screen.width, Screen.height );
private Vector2 textLocation = new Vector2( (Screen.width / -2), (Screen.height / -2));
void WriteCountText()
{
countText.pixelOffset = textLocation + offset;
countText.text = "Count: " + count2.ToString();
}
"
Subscribe to:
Posts (Atom)