Hi!
EDIT: Well, the problem is that the game object scales down to 0, not a rendering problem. I’m not the only one having this problem (can we consider it an Unity issue?). If I reset the scale to the one the game object should have everything is solved. But is there any way to prevent this? Should I change the parenting procedure to anything else to not changing scale on the process?
I’m trying to change a GameObject parent during runtime. I can do it, but the problem is that the GameObject visually disappears (it stills exists).
Here is my code where I create it (from a Object pool):
public static SlimeController NewSlime(Transform parent = null, Vector3 position = default(Vector3), Quaternion rotation = default(Quaternion)) {
SlimeController results = Instantiate(Instance.slime);
Transform transform = results.GetComponent<Transform>();
transform.parent = parent;
transform.localPosition = position;
transform.rotation = rotation;
return results;
}
After this, it is now a child of the specified parent object.
This is the code where the Slime is parent-switched (inside SlimeController script):
public override bool Lock (HexController hex) {
bool success = base.Lock (hex);
if (!success) { return false; }
Transform transform = this.GetComponent<Transform>();
transform.parent = this.hex.transform;
transform.localPosition = default(Vector3);
return true;
}
Now the slime parent is the desired one, even its at the specified location (which is the same of the parent), but the slime disappears (visually). It still exists, I can see it at the Hierarchy tab, select it and keeps behaving as expected.
Any ideas of what i’m doing wrong?
Thanks a lot!