Get prefab data during runtime

I have many prefabs for which I wish to check for collider.bounds.size

I don’t want to instantiate or load any of these into the scene until a prefab can be found that fits so I need to access the prefab definition during runtime.

How can I access the prefab definition itself and not any instantiated object?

I see that it can be done by dragging scripts in the inspector - I’d like to do it without that if possible. Especially since collider.bounds.size appears to report zero???
Yes… it does report zero. Same issue: http://forum.unity3d.com/threads/collider-bounds-from-a-prefab.37161/

This code returns zero and not an error, or instance of an object error, or anything… I can easily make it error out so it is finding the right gameObject which is the only one with a collider (or a different error if this child has no collider) and everything is set right in the inspector, etc…

Debug.Log("room prefab size is: " + RoomPrefab.transform.Find("Room").GetComponent<Collider>().bounds.size);

room prefab size is: (0.0, 0.0, 0.0)
UnityEngine.Debug:Log(Object)
DoorScript:doStuff() (at Assets/Resources/DoorScript.cs:77)
DoorScript:OnMouseDown() (at Assets/Resources/DoorScript.cs:56)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)

Even assigning the reference to a gameObject doesn’t seem to work and produces the same result

GameObject myRoom = RoomPrefab.transform.Find("Room").gameObject;
Debug.Log(myRoom.GetComponent<Collider>().bounds.size);

Without a way to check the prefab stats during runtime I’m looking at having to hard-code in all the data regarding each prefab into a class which is not change tolerant and is bad practice. So I’m open to suggestions regarding how such a thing should be done if there is no answer to the above.

One thing that might work around this but is terrible for performance is to instantiate each prefab in Start(), take note of the statistics and destroy it. This feels like a super ugly hack :frowning:

So I suppose it just isn’t possible as this documentation states;

“Note that this will be an empty bounding box if the collider is disabled or the game object is inactive.”

So the bounds properties of colliders only exist if the GameObject is instantiated and active.

I tested Renderer as well. Maybe no-go.

I suppose that the way that I will work around this is to have a companion prefab for each main prefab which exists only to check for collisions.

Vector3 checkerBounds = nextRoomChecker.transform.GetChild(0).transform.GetComponent<Collider>().bounds.size;
Vector3 halfCheckerBounds = checkerBounds * 0.5f;
Collider[] colliders = Physics.OverlapBox(nextRoomChecker.transform.GetChild(0).transform.GetComponent<Collider>().bounds.center, halfCheckerBounds, door.transform.parent.transform.rotation);