I'm getting the following error: "Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption."
This happens when i call the HUDText.Add function, and the error comes from this line:
t.parent = parent.transform;
in the function "static public GameObject AddChild (GameObject parent)" in NGUITools.cs.
Here is my code for handling this. (the dmgTextPrefab is a prefab that is added to my script in the editor):
NGUITools.AddChild(GameObject.Find("UI Root (2D)"), dmgTextPrefab);
dmgText = dmgTextPrefab.GetComponent<HUDText>();
dmgText.Add(-dmg, Color.red, 0.5f);
When i Instantiate the prefab (i end up with double prefabs in the scene) and use the instantiated prefab instead it works fine. Any idea what is causing this?
EDIT: Seems like the AddChild function is instantiating the gameobject as well, so no need for me to do it. All good.