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 soccer1mt · Aug 26, 2016 at 04:46 AM · uicollidermenu screenworld space

Buttons still "Clickable" after disabling their parent canvas

I am using a laser pointer attached to my vive controller to select buttons off a world space canvas. I did this by attaching a box collider to each button and then using a physics collider. The problem is that when I disable one canvas to go to a different screen, the buttons for canvases that have been deactivated remain active (even though they are not visible on the screen. How do I make sure that the colliders are no longer active after I disable the parent canvas?

 using UnityEngine;
 using System.Collections;
 using UnityEngine.SceneManagement;
 
 public class ItemSelection : MonoBehaviour {
 
     public SteamVR_TrackedObject rightController;
     public Canvas MainMenu;
     public Canvas MPMenu;
     public Canvas OptionsMenu;
     public Canvas ExitMenu;
     public Canvas TutorialMenu;
 
     void Awake ()
     {
         MainMenu.enabled = true;
         MPMenu.enabled = false;
         OptionsMenu.enabled = false;
         ExitMenu.enabled = false;
         TutorialMenu.enabled = false;
         rightController = GetComponent<SteamVR_TrackedObject>();
         MainMenu = MainMenu.GetComponent<Canvas>();
         MPMenu = MPMenu.GetComponent<Canvas>();
         OptionsMenu = OptionsMenu.GetComponent<Canvas>();
         ExitMenu = ExitMenu.GetComponent<Canvas>();
         TutorialMenu = TutorialMenu.GetComponent<Canvas>();
     }
     
 
     void Update ()
     {
         if(IsTriggerDown.IsRightDown)
         {
             Debug.Log("trigTracker is starting");
             RaycastHit hit;
             Ray shootingRay = new Ray(rightController.transform.position, rightController.transform.forward);
             if (Physics.Raycast(shootingRay, out hit, 5f))
             {
                 if (hit.collider.tag == ("SPButton"))
                 {
                     SceneManager.LoadScene(1);
                     IsTriggerDown.IsRightDown = false;
                 }
                 else if (hit.collider.tag == ("MPButton"))
                 {
                     Debug.Log("You hit the MP Button");
                     MainMenu.enabled = false;
                     MPMenu.enabled = true;
                     IsTriggerDown.IsRightDown = false;
                 }
                 else if (hit.collider.tag == ("TutorialButton"))
                 {
                     MainMenu.enabled = false;
                     TutorialMenu.enabled = true;
                     IsTriggerDown.IsRightDown = false;
                     Debug.Log("You hit the Tutorial Button");
                 }
                 else if (hit.collider.tag == ("OptionsButton"))
                 {
                     MainMenu.enabled = false;
                     OptionsMenu.enabled = true;
                     IsTriggerDown.IsRightDown = false;
                     Debug.Log("You hit the Options Button");
                 }
                 if (hit.collider.tag == ("ExitButton"))
                 {
                     MainMenu.enabled = false;
                     ExitMenu.enabled = true;
                     IsTriggerDown.IsRightDown = false;
                     Debug.Log("You hit the Exit Button");
                 }
                 if (hit.collider.tag == ("ReturnMenu"))
                 {
                     MPMenu.enabled = false;
                     OptionsMenu.enabled = false;
                     ExitMenu.enabled = false;
                     TutorialMenu.enabled = false;
                     MainMenu.enabled = true;
                     IsTriggerDown.IsRightDown = false;
                     Debug.Log("You hit the Return to Menu Button");
                 }
                 if (hit.collider.tag == ("YesExButton"))
                 {
                     Application.Quit();
                     Debug.Log("You hit the Exit Button");
                 }
 
                 else
                 {
                     Debug.Log("You missed UI Buttons");
                 }
             }
         }
     }
 }
 
Comment
Add comment
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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Click on things? 0 Answers

Scrollable, clickable overworld map 0 Answers

Alternatives to Canvas Draw Order when using elements that rotate around each other 0 Answers

World Space UI facing multiple Cameras (Billboard) 0 Answers

Menu works in stand alone but not in Game view in Editor 0 Answers


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