Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8405125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:46:15+00:00 2026-06-09T22:46:15+00:00

I have three child game objects(as you can see in below picture with Red

  • 0

I have three child game objects(as you can see in below picture with Red, Pink & Blue). They are child of parent game object Green.

I don’t know, how to calculate size of Parent(Green) GameObject?

I am creating all these game objects at runtime using this code:

GameObject CreatePattern(int difficultyLevel)    
    {    
        GameObject gameObjectTemp = new GameObject();    
        SinglePattern singlePattern;    
        gameObjectTemp = (GameObject) Instantiate(gameObjectTemp);   


        singlePattern = freeRunDataHandler.GetSinglePatternRandom(1);    
        GameObject gameObjectSingleObject = null;    
        foreach (SingleObject singleObject in singlePattern.singleObjectList)    
        {
                gameObjectSingleObject = GetGameObjectByCategory(singleObject.catergory, singleObject.type);

            if (gameObjectSingleObject != null)    
            {    
                gameObjectSingleObject = (GameObject) Instantiate(gameObjectSingleObject, new Vector3(singleObject.positionX, singleObject.positionY, singleObject.positionZ), Quaternion.identity);    
                gameObjectSingleObject.transform.localScale = new Vector3(singleObject.length, 1, singleObject.width);    
                gameObjectSingleObject.transform.parent = gameObjectTemp.transform;    
            }    
        }        

        return gameObjectTemp;    
    }

This function returns parent(Green) gameObject after adding all childs. My Parent(Green) have nothing attached to it not even any component(BoxCollider, MeshFilter, MeshRenderer, etc..).

I had attached BoxCollider, MeshRenderer & MeshFilter(Just for testing) & i tried on parent:

parent.collider.bounds.size.x  ----- > box collider
parent.renderer.bounds.size.x  ----- > mesh renderer

But nothing works. There return 1 or zero in cases.
Please help me in how to get size of Parent(Green) GameObject?

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:46:16+00:00Added an answer on June 9, 2026 at 10:46 pm

    By size do you mean the bounds? If so, it should be a lot simpler than you’ve made it. My code is untested, I don’t have Unity handy but this should work. It assumes ‘parent’ is a game object in your hierarchy and that it has ‘children’ under it in the hierarchy.

    Bounds bounds = parent.renderer.bounds;
    foreach (Transform child in parent.transform)
    {
        bounds.encapsulate(child.gameObject.renderer.bounds);
    }
    

    Update:

    Alternatively, if you don’t want a parent with a renderer:

    // First find a center for your bounds.
    Vector3 center = Vector3.zero;
    
    foreach (Transform child in parent.transform)
    {
        center += child.gameObject.renderer.bounds.center;   
    }
    center /= parent.transform.childCount; //center is average center of children
    
    //Now you have a center, calculate the bounds by creating a zero sized 'Bounds', 
    Bounds bounds = new Bounds(center,Vector3.zero); 
    
    foreach (Transform child in parent.transform)
    {
        bounds.encapsulate(child.gameObject.renderer.bounds);   
    }
    

    You mentioned not wanting to use a parent/child hierarchy. If you don’t go that route you need to either add the “children” to some sort of array or you’ll have to use the GameObject.Find() method to find each child by name. If you name something like “child_1”, “child_2” you could look them up fairly easily but it’s a hack of a lot simpler to simply create a parent object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a parent FragmentActivity with three child Tab Fragments. When a Submit button
If I have a parent table and a child table where there can be
Lets say I have a parent item and three child items in sitecore cms
I have a parent div that is filled with multiple child divs (see here
So I have three div's One parent and two child. The parent is as
Ok, I have three tables. The parent table is Listings and two child tables
I have three domain objects: Child, Classroom and ChildClassroom. Here are lists of each:
Say I have a parent div with three child divs. Is there a way
I have three forms: Form1 (Which is Mdi) Form2 (child of mdi) Form3 (child
I have an xml document with three child elements repeating in any order. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.