Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
avatar image
0
Question by Celdur91 · Sep 18, 2016 at 10:32 PM · childbuttonsrotate object

Button as child object

Hello. I have a little problem with my game object. I want to have a couple of child objects and this childs should be buttons. In specify: if I have 2 cubes and I click on one of them 2 buttons should appear (childs of this cube) and when I clik on another one for example 3 buttons should appear (another buttons). The problem is when I add a buttons as childs they move and rotate with parent. I added following code to button:

 void Start () {
     rotation = transform.rotation;
     position = transform.position;
 }
 
 // Update is called once per frame
 void Update () {
     transform.rotation = rotation;
     transform.position = position;
 }

This code only prevent buttons to not move but they still rotate. Is there any other way to prevent this child buttons form moving and rotating with their parent? Thank you very much for your help

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 instruct9r · Sep 19, 2016 at 12:57 AM 0
Share

Why would you want them to be children of the cubes, if they won't move with the cubes? If you don't want them to move with the cubes, don't make them children. Just position them near the cubes...

avatar image Celdur91 instruct9r · Sep 19, 2016 at 05:10 AM 0
Share

Because I want to have different pack of buttons depends on which object I click. I thought the easiest way to get it is create buttons as childs and when I click on object no.1 then (for example) button1 and button2 should appear. But when I click on object no.2 then buttons 1 and 2 should disappear and buttons 3, 4 and 5 should show. Should I just add this buttons normally and connect them with objects by script?

avatar image instruct9r Celdur91 · Sep 20, 2016 at 12:22 AM 0
Share

If i was going to do this, i was simply going to reference the UI Buttons to the script, that will show \ hide them and enable \ disable them, when the appropriate action happens. Parenting them to the objects, that you want to click (To activate the buttons) won't help you in any way, except if you want to search for some children, but that is slow, unless you have 1000 objects, that you want to click on...

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

53 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 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 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

I drag a rotated object to a parent - and it has totally different rotation. 1 Answer

Calling a function via button from instance of prefab 1 Answer

How to rotate a child object vertically with the mouse ? 1 Answer

Rotating object with onscreen button 1 Answer

Child not following parent's rotation 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