I have been doinig this in the past:
// main script C#
public Text v1;
public Text v2;
public Text v3;
public Text v4;
// and so on...
void Update () {
v1.text = "v1: " + PlayerPrefs.GetInt ("v1");
v2.text = "v2: " + PlayerPrefs.GetInt ("v2");
v3.text = "v3: " + PlayerPrefs.GetInt ("v3");
v4.text = "v4: " + PlayerPrefs.GetInt ("v4");
// and so on...
// I know I could use a for loop, but that's not the point of the question.
}
Should I switch to this?
// script found on all of the text objects C#
public string name;
private Text t;
void Start () {
t = transform.GetComponent <Text> ();
}
void Update () {
t.text = name + ": " + PlayerPrefs.GetInt (name);
}
The first example seems performance heavy to me because the script executes all of the time, no matter if the children are active. But then again, I read somewhere that 1 update
with heavy tasks is better than many updates
with the heavy tasks spread out.
In the same way, it’s easier to render an object with 1000 meshes than 1000 objects with 1 mesh each.
Which way should I go?