x


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!

more ▼

asked Jan 12 '10 at 02:14 AM

james.jeffers gravatar image

james.jeffers
5 3 4 4

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Jan 12 '10 at 02:24 AM

Jaap Kreijkamp gravatar image

Jaap Kreijkamp
6.4k 20 26 70

So far, I've only seen this in the editor - I haven't tried it in a build.

Jan 13 '10 at 12:09 AM james.jeffers

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?

Jan 13 '10 at 12:35 AM james.jeffers
(comments are locked)
10|3000 characters needed characters left

Gah! It was the rotation of the object - it was rendering, but the surface was not facing the camera. Thanks!

more ▼

answered Jan 13 '10 at 12:48 AM

james.jeffers gravatar image

james.jeffers
5 3 4 4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1672
x1254
x336

asked: Jan 12 '10 at 02:14 AM

Seen: 2515 times

Last Updated: Jan 12 '10 at 11:25 AM