Okay, So this is my first time posting on the forums. I’ve been reading through the the pages, trying to find something that would be helpful for me in understanding the Unity GUI, but it’s just not clicking.
I come from a strong background in Visual Basic (versions 3-6) and the GUI elements make sense, but confuse me at the same time.
I’m used to referencing objects by names and handles, so is there an efficient way to continue doing this with the Unity GUI?
Here’s a sample of code:
function DoScoreWindow (windowsID : int) {
//Make the window be draggble in the top 20 pixels
GUI.DragWindow(Rect(0,0,System.Decimal.MaxValue, 20));
GUILayout.Label("My Score for Level 1 is:");
var lblStar : int = GUILayout.Label(MYSTARS+"");
var lblCrate : int = GUILayout.Label(MYCRATES+"");
lblStar.name = "lblStarCounter";
lblCrate.name = "lblCrateCounter";
}
This is an edited copy from the 2D Platform tutorial on the site.
MYSTARS is a static variable updated with the OnTrigger Event in another script, essentially it’s a counter variable.
MYCRATES is also a static variable that’s updated through another OnTrigger Event.
I’m using Debug.Log(varName+“”); and the variables are updating correctly. Just having a problem working with Unity GUI. I’ve read through the information available on the main website, but the connection just isn’t being made mentally.
As you can see, the code written above doesn’t work! How would I save the handle of the GUI item, so it can be (1)named, and then the (2)text can be updated through other scripts in the project?
My thought process is geared more towards VB, so any one who can explain it simply would be appreciated!
-Tony Z.