Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've made a prefab consisting of a Cube which I've first scaled to more resemble a brick. There's also a Rigidbody added to the cube (in the prefab). Now I want to use that prefab in a c# script to make a wall out of multiple bricks.

My question is, how can I access the dimensions of my brick (width, height, the z dimension size) so that in my script I can make bricks which are placed one next to the other (and then one on top of the other)?

I've looked at the documentation for GameObject and Rigidbody but I can't find anything helpful.

Just for refference, my script so far is:

public GameObject brick;

void Start () {
        Instantiate(this.brick, new Vector3(0.01326297f, -30.07855f, 100f), Quaternion.identity);
        // int brickWidth = this.brick.????;

share|improve this question
up vote 1 down vote accepted

Have you tried using bounds ?

I guess you can achieve what you're looking for using :

float brickWidth = brick.renderer.bounds.size.x;
share|improve this answer
Thanks, that works. I just must make the brickWidth variable into a float. – Shivan Dragon Sep 6 '12 at 20:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.