My current layout looks like:
Menu
-
Panel
-
Items (Button)
-
Special (Button)
-
Equipment (Button)
-
Formation (Button)
-
Save (Button)
-
CharOnePortrait
-
C1HP/MP (Text)
-
CharOneName (Text)
-
CharOneHP (Text)
-
CharOneMP (Text)
-
CharTwoPortrait
-
C2HP/MP (Text)
-
CharTwoName (Text)
-
CharTwoHP (Text)
-
CharTwoMP (Text)
-
CharThreePortrait
-
C3HP/MP (Text)
-
CharThreeName (Text)
-
CharThreeHP (Text)
-
CharThreeMP (Text)
-
Location1 (Text)
-
Location2 (Text)
-
Currency (Text)
And I have a script attached to Menu - GameMenu.cs (C#) that I want to use to send values to all the Text entries on the menu.
Well, I don’t know how to do that, so I’ve been using GameObject.Find and putting in the names of the Text. Here is the code I’ve made, and it works, but it’s so bloated.
private Text charOneName;
private Text charTwoName;
private Text charThreeName;
private Text charOneHP;
private Text charTwoHP;
private Text charThreeHP;
private Text charOneMP;
private Text charTwoMP;
private Text charThreeMP;
private Text currency;
private Text location1;
private Text location2;
void Start ()
{
charOneName = GameObject.Find(“CharOneName”).GetComponent();
charTwoName = GameObject.Find(“CharTwoName”).GetComponent();
charThreeName = GameObject.Find(“CharThreeName”).GetComponent();
charOneHP = GameObject.Find(“CharOneHP”).GetComponent();
charTwoHP = GameObject.Find(“CharTwoHP”).GetComponent();
charThreeHP = GameObject.Find(“CharThreeHP”).GetComponent();
charOneMP = GameObject.Find(“CharOneMP”).GetComponent();
charTwoMP = GameObject.Find(“CharTwoMP”).GetComponent();
charThreeMP = GameObject.Find(“CharThreeMP”).GetComponent();
currency = GameObject.Find(“Currency”).GetComponent();
location1 = GameObject.Find(“Location1”).GetComponent();
location2 = GameObject.Find(“Location2”).GetComponent();
charOneName.text = “Matt”;
charTwoName.text = “Steven”;
charThreeName.text = “Ashley”;
charOneHP.text = “240” + “/” + “250”;
charTwoHP.text = “240” + “/” + “250”;
charThreeHP.text = “240” + “/” + “250”;
charOneMP.text = “29” + “/” + “35”;
charTwoMP.text = “29” + “/” + “35”;
charThreeMP.text = “29” + “/” + “35”;
currency.text = "$ " + “12.50”;
location1.text = “Twoson Town”;
location2.text = “Town”;
}
There has to be a simpler way of doing this. I don’t want to have to put a script on each text item.
I would appreciate any help I receive. Thank you!