Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Aug 17, 2013 at 07:29 AM by Fattie for the following reason:

Duplicate Question

avatar image
0
Question by howtech · Aug 15, 2013 at 09:46 AM · texturetransformchild

Why is the child transform giving me errors?

UnityException: Transform child out of bounds GUI_Buttons.Start () (at Assets/Codes/GUI_Buttons.js:12)

that is mah error

pragma strict

/icon variables are the ones that selected are is. Don't judge my groamar. var useAllVariables : boolean; var Icon: Material; var Icon2: Material; var Text: Material; var backImage: Material; var normalIcon: Material[];

function Start () { normalIcon[0] = renderer.material; normalIcon[1] = transform.GetChild(0).renderer.material; if(!useAllVariables) return; normalIcon[2] = transform.GetChild(1).renderer.material; normalIcon[3] = transform.GetChild(2).renderer.material; }

function OnMouseEnter () { renderer.material = backImage; transform.GetChild(0).renderer.material = Icon; if(!useAllVariables) return; transform.GetChild(1).renderer.material = Icon2; transform.GetChild(2).renderer.material = Text; }

function OnMouseExit () { renderer.material = normalIcon[0]; transform.GetChild(0).renderer.material = normalIcon[1]; if(!useAllVariables) return; transform.GetChild(1).renderer.material = normalIcon[2]; transform.GetChild(2).renderer.material = normalIcon[3]; }

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Paulius-Liekis · Aug 15, 2013 at 11:41 AM 1
Share

Please format your post properly. Why will anyone bother to help (i.e. spend their time) if you do not invest time your into posting a properly formatted question?

avatar image Fattie · Aug 17, 2013 at 07:29 AM 0
Share

moderators - close duplicates, and close unformatted

avatar image Paulius-Liekis · Aug 18, 2013 at 12:40 PM 0
Share

@Fattie, there is no need to punish people on the first time. Educate ins$$anonymous$$d. The goal is to build stronger community - not to be formatting police ;)

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by Sajidfarooq · Aug 15, 2013 at 12:10 PM

As already answered here: http://answers.unity3d.com/questions/261136/child-transform-out-of-bounds.html

You are trying to access a child (transform.GetChild(0) ) of a Transform without making sure that it actually does have children in the first place...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by TheKusabi · Aug 15, 2013 at 12:40 PM

Formatted for you. Next time, I suggest you do this yourself or people will not give you the time of day.

pragma strict // icon variables are the ones that selected are is. // Don't judge my groamar. var useAllVariables : boolean; var Icon: Material; var Icon2: Material; var Text: Material; var backImage: Material; var normalIcon: Material[];

function Start () { normalIcon[0] = renderer.material; normalIcon[1] = transform.GetChild(0).renderer.material; if(!useAllVariables) return; normalIcon[2] = transform.GetChild(1).renderer.material;

 normalIcon[3] = transform.GetChild(2).renderer.material; 

}

function OnMouseEnter () { renderer.material = backImage; transform.GetChild(0).renderer.material = Icon; if(!useAllVariables) return; transform.GetChild(1).renderer.material = Icon2;

 transform.GetChild(2).renderer.material = Text; 

}

function OnMouseExit () { renderer.material = normalIcon[0]; transform.GetChild(0).renderer.material = normalIcon[1]; if(!useAllVariables) return; transform.GetChild(1).renderer.material = normalIcon[2];

 transform.GetChild(2).renderer.material = normalIcon[3]; 

}

Error Message: "Transform child out of bounds GUI_Buttons.Start () (at Assets/Codes/GUI_Buttons.js:12)"

As for an answer, best guess is that the GameObject does't have three children and you are trying to access transform.GetChild(2) which is the third child. Change that number in all of the functions.

Good luck!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sajidfarooq · Aug 15, 2013 at 12:46 PM 1
Share

$$anonymous$$udos for taking the time out to do what the OP should have done in the first place. Up-voted.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rotation issue with remote players projectiles 0 Answers

Making child/parent movement smooth instead of choppy 1 Answer

Mesh Collider Does not rotate with Mesh 2 Answers

Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption. WHY??? 6 Answers

GameObject.Find("something")..how to use with transform,audiosource and texture ? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges