When I load a prefab sprite using…
GameObject g = Instantiate (Resources.Load ("Prefabs/" + unitName )) as GameObject;
…the child object is not rendered. When searching for answers there were many posts on this. However none of the solutions fixed my problem.
- the instantiation is not done in Awake() so that can’t be the problem.
- The child prefab is not rotated during the instantiation.
- I changed the sorting layer of both the parent and child prefab but the child remained invisble.
- The order in layer of the parent prefab is 2 and the child is 3 so that should be OK as well.
- In scene view I am able to click on the child prefab. So during instantiation it’s placed in the right position and rotation.
- When I manually drag the prefab into the scene it’s displayed correctly.
Does anyone have a clue what could be the problem here ? Thanks so much for any help.
i just spent hour trying to solve this problem. and i finally got it.
for me this was the problem.
Step one : make sure your object is for sure in camera view.
Step two: make sure your object is in front of background/ not on it not behind it.
Step three: remake your prefab
and my objects are now instantiated and visible…
@blober81 I know this is super late but I had the same exact problem and it was really frustrating. I’m surprised no one answered this question but this is how I solved it:
I put the spawn point under a sprite. You can leave the sprite field in the sprite renderer empty and it looks like a regular empty 2d point.
I was just trying random shit and have no idea why this works.
This may be a bit late but I’ll put this here for others who come across this thread
if the z position of the spawn point and the player are not both equal to 0 then it will spawn invisible
hope this fixes your problem