Seith
1
Hello, I’m meeting a strange behavior in the editor: when I drag a prefab in the scene view, deselect and then reselect it, the prefab itself gets selected (which is great). If I click a second time, its LOD0 gets selected. Which is expected.
But when I instantiate the same prefab using this code:
GameObject go = (GameObject)Instantiate(Resources.Load("MyPrefab"));
Then when I click just once on the instantiated prefab in the scene view its LOD0 mesh gets selected, instead of the prefab itself. Is that a known bug, or am I doing something wrong?
Seith
2
Alright, I finally found out what was happening. The “Instantiate” command in fact creates an instance of the prefab BUT DOES NOT maintain a connection to the original prefab.
The command to do that is “PrefabUtility.InstantiatePrefab”. So in that case:
GameObject go = PrefabUtility.InstantiatePrefab(Resources.Load("MyPrefab") as GameObject;
Using that line of code will maintain the cloned instances’ proper behavior of one-click to select the prefab itself and a second click to select the actual mesh contained inside the prefab. Thanks for your input Sonaten. I was worried for a moment here… 