I got a prefab which is inactive.
In this prefab I got a GameObject that jumps to the root hierarchy as soon as I activate my prefab.
How to prevent this, and what can cause it?
I got a prefab which is inactive.
In this prefab I got a GameObject that jumps to the root hierarchy as soon as I activate my prefab.
How to prevent this, and what can cause it?
Like a child of the prefab that sets its parent to null, in a script? Something like that?
No is like tis:
–Main Camera
–Puzzle
-Puzzle Controller
-Light
Puzzle is inactive since the level picks which prefab should be active.
Puzzle object has a camera.
As soon as the Puzzle gameobject is activated the situation becomes:
–Main Camera
–Puzzle Controller
–Puzzle
-Light
Something, either itself or something else, must be setting the parent. Find in Files for SetParent() and make sure you’re getting accurate results, as passing a null value will deparent it from everything.
There is no SetParent() (unfortunatly)
GameObject rootObj = GameObject.Find("PuzzleRoot");
GameObject camera = GameObject.Find ("Main Camera");
GameObject MyJigsaw = rootObj.transform.Find ("JigsawPuzzleJP").gameObject;
GameObject MyMP = rootObj.transform.Find ("JigsawPuzzleMP").gameObject;
GameObject MyPP = rootObj.transform.Find ("JigsawPuzzlePP").gameObject;
GameObject MySP = rootObj.transform.Find ("JigsawPuzzleSP").gameObject;
GameObject PuzzleP;
Texture2D LImage;
switch(_level.PuzzleType)
{
case "Jigsaw":
Destroy (MyMP);
Destroy (MyPP);
Destroy (MySP);
camera.SetActive (false);
MyJigsaw.SetActive (true);
as you see in original structure I forgot to mention that the actual prefab is under PuzzleRoot
like so
—PuzzleRoot
–JigsawPuzzleJP
-PuzzleP
I dont know how to set the PuzzleP object to MyJigsaw as parent manually since I assume that might solve it…
tried reversing the process by making the active components inactive after I found them with GameObjects.Find
that does not make any change…
getting really confused now