- Home /
Why do instantiated game objects not always render?
When I instantiate a prefab, I've noticed that some parts of that object do not render. When the same prefab is dragged onto the "Hierarchy" tab, the object (and any associated rendering components) render as expected. Why is this?
I instantiate the prefabs like this:
GameObject waypoint = Instantiate(
Resources.Load("Waypoint"),
location,
Quaternion.identity) as GameObject;
In this case, "Waypoint" is the name of the prefab.
Thanks in advance!
Answer by Jaap Kreijkamp · Jan 12, 2010 at 02:24 AM
Is this in the editor or in a build? If it's in a build then possibly the asset hasn't be included into the build as there's no visible link to it. A way to force resources to be included in a build is adding a gameobject with a simple script that has all these resources attached (script with public Transform array and in inspector add all Prefabs to it).
If it's in the editor then there's something else bothering you, guess it's debugging time. Add a Debug.Break() after the statement and look if you see anything weird in Hierarchy, Scene and Inspector about the created object.
So far, I've only seen this in the editor - I haven't tried it in a build.
Ok - tried it in a build and the same problem exists there as well.
I take it then there is no limitation on multiple renderer components in the same GameObject?
Answer by james.jeffers · Jan 13, 2010 at 12:48 AM
Gah! It was the rotation of the object - it was rendering, but the surface was not facing the camera. Thanks!