Question by
HyblockerDevelopment · Sep 17, 2016 at 08:23 AM ·
c#guitext
Connect C# script with GuiText
So I have made 3 Gui text objects which I have to change, which are: Health, Ammo in Vest and Ammo In Gun. I have made 6 text labels and they are split into 2 sections of 3: Text and values. I have a C# script which controls the gun and need to connect the Gui Text Objects to it. like
public Text AmmoUi;
Please help me A.S.A.P. as I have this for an assignment
Comment
Best Answer
Answer by HyblockerDevelopment · Sep 17, 2016 at 11:03 AM
No worries I fixed it :D
For those who have the same problem:
//these go before anything
public Component var1name; //replace var1name with your variable name
public Text VAR2NAME; //replace VAR2NAME with your second variable name
void Awake()
{
VAR2NAME = var1name.GetComponent<Text>(); //replace with the ones you used up there /\
}
Then you assign your Text gameobjects from the Inspector windows. Hope this helped the rest!