Size of a prefab instance is always (0,0,0)

Hi there

I have prepared a simple prefab that represents my player character. I have instantiated this prefab and now want to find out the position and height of the instance via a C# script. Determining the position works fine (In the following snippets “_character” is my local variable, holding the game object = instantiated prefab):

Debug.Log("Position: " + _character.transform.position);

Displays correctly as:

Position: (2.2, 0.0, -3.0)

But it won’t work for the size of the instance:

Debug.Log("Size: " + _character.renderer.bounds.size);

Displays as:

Size: (0.0, 0.0, 0.0)

The instance has a component “Mesh Renderer” attached to it.

What am I doing wrong?

Hi there

“whydoidoit” pointed me in the right direction, his guess was absolutely correct:

Initially I had tried to determine the size at a point in time, where Unity did not yet have completely finished rendering the respective game object.
Moving the whole thing to another code position, where I was sure that Unity had finished rendering all game objects, did the trick.

Thanks a lot to “whydoidoit”! Question has been answered.