Hello,
I am having a weird issue with public static GameObject [ ] using C#…
A first public static GameObject [ ] made of Instance(Resource.Load()).
Kind of template array I am using as anoriginal list with all the GameObjects.
Once it is made, I never edit it.
Lets call it : “Character.TemplateLs”
The second public static GameObject [ ] is made from the first one.
Lets call it : “Team.goLs”
From script : Team.goLs = Character.TemplateLs.
Now if I edit one row of the goLs, it also edit the TemplateLs.
This is what I call weird.
I never got this issue before and have no idea what is happening.
This is how I found the issue
GameObject original = Character.TemplateLs[11]; // called "go_template_11"
GameObject edit = GameObject.Find ("go_otherObject");
Debug.Log ("Character.TemplateLs[11] = " + Character.TemplateLs[11].name + ";");
Team.goLs[index] = edit;
Debug.Log ("Character.TemplateLs[11] = " + Character.TemplateLs[11] .name + ";");
Character.TemplateLs[11] = original;
Debug.Log ("Character. TemplateLs[11] = " + Character.TemplateLs[11].name + ";");
Debug.Log ("Team.goLs[index] = " + Team.goLs[index].name + ";");
It prints the following :
Character.TemplateLs[11] = go_template_11;
Character.TemplateLs[11] = go_otherObject;
Character.TemplateLs[11] = go_template_11
Team.goLs[index] = go_template_11;
Then what is happening?
Do an array could be the instance of another array?
Do I miss an important point with C#?
Thanks!!