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 Vulture_6 · Sep 22, 2016 at 07:03 PM · transformbeginneraugmented realitygame objectresizing

Disable or resizing a clickable cube

Hello,

here´s my situation:

01_Start


I have an AR-Scene where a Marker contains a rotating 3D-Model of a fountain and an invisible (and clickable) cube, that surrounds the 3D-Model.

I instructed the cube to enable a canvas, that contains some information about the 3D-Model, on mousedown. Until this point everything works fine.

However, I wish to provide more information about the object on more than one page / canvas. Therefore I introduced some buttons, that basically change the visibility settings of the canvas that belong to the 3D-Model. For better understanding, have a look at the project hierachy:

02_Hierachy


The canvas that provide information for this specific object start with "01_Can..." in the hierachy; the buttons change their visibility. Scrolling through the canvas / pages also works fine.

Now imagine being on the second page and you wish to close the canvas from there (while pointing your camera to the clickable cube mentioned in the beginning. Clicking on the button closes the second page, but since you are pointing to the clickable cube, the first page is reopened and you have to close it manually (again).

To avoid this, I tried disabling the boxcollider of the cube and also rescaling the cube while one of the canvas is active - without success, I seem to be missing something.

This is the code that I used:

 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 
 public class ToggleMenu : MonoBehaviour 
 {
     // ############################
     // ## Variablendeklarationen ##
     // ############################
 
     // Schalter, der die Leinwand zu Beginn der Szene auf "aus" stellt
     public bool Bool_BrunnenSchalter;
 
     // Leinwände, die beim Anklicken erscheinen und Infos zum Brunnen ausgeben
     public Canvas Can_DE_BrunnenInfoP1;
     public Canvas Can_DE_BrunnenInfoP2;
     public Canvas Can_DE_BrunnenInfoP3;
     public Canvas Can_DE_BrunnenInfoP4;
     public Canvas Can_DE_BrunnenInfoP5;
 
     // Buttons für die Navigation durch die Infotafeln
     public Button Btn_DE_BrunnenInfoP1;
     public Button Btn_DE_BrunnenInfoP2;
     public Button Btn_DE_BrunnenInfoP3;
     public Button Btn_DE_BrunnenInfoP4;
     public Button Btn_DE_BrunnenInfoP5;
 
     // Button zum Schließen von "BrunnenInfo"
     public Button Btn_BrunnenSchliessen;
 
     // Wüfel, mit dem bei offenem Menü nicht mehr interagiert werden kann (jedoch nicht deaktiviert ist!!!)
     public GameObject BrunnenWuerfel;
 
 
     // ###########################################################################################
     // ## Zuweisung der Buttons und Dialoge beim Programmstart sowie Sichtbarkeitseinstellungen ##
     // ###########################################################################################
     void Awake()
     {
         // Sichtbarkeitseinstellung Leinwände beim Start
         Can_DE_BrunnenInfoP1.enabled = false;
         Can_DE_BrunnenInfoP2.enabled = false;
         Can_DE_BrunnenInfoP3.enabled = false;
         Can_DE_BrunnenInfoP4.enabled = false;
         Can_DE_BrunnenInfoP5.enabled = false;
 
         // Schaltereinstellung
         Bool_BrunnenSchalter = false;
     }
 
 
     void Start()
     {
 
     }
 
 
     // #######################################################
     // ## Funktion, die die Leinwand bein Anklicken anzeigt ##
     // #######################################################
     private void OnMouseDown()
     {
         if (Bool_BrunnenSchalter == false)                        // ACHTUNG: "==" statt "="
             Can_DE_BrunnenInfoP1.enabled = true;
             Can_DE_BrunnenInfoP2.enabled = false;
             Can_DE_BrunnenInfoP3.enabled = false;
             Can_DE_BrunnenInfoP4.enabled = false;
             Can_DE_BrunnenInfoP5.enabled = false;
             Bool_BrunnenSchalter = true;
 
             BrunnenWuerfel.gameObject.transform.localScale = new Vector3 (0, 0, 0);
     }
 
 
     // ########################
     // ## Aufruf von Seite 1 ##
     // ########################
     public void InfoP1_Press()
     {
         Can_DE_BrunnenInfoP1.enabled = true;
         Can_DE_BrunnenInfoP2.enabled = false;
         Can_DE_BrunnenInfoP3.enabled = false;
         Can_DE_BrunnenInfoP4.enabled = false;
         Can_DE_BrunnenInfoP5.enabled = false;
         Bool_BrunnenSchalter = true;
 
         BrunnenWuerfel.gameObject.transform.localScale = new Vector3 (0, 0, 0);
     }
 
 
     // ########################
     // ## Aufruf von Seite 2 ##
     // ########################
     public void InfoP2_Press()
     {
         Can_DE_BrunnenInfoP1.enabled = false;
         Can_DE_BrunnenInfoP2.enabled = true;
         Can_DE_BrunnenInfoP3.enabled = false;
         Can_DE_BrunnenInfoP4.enabled = false;
         Can_DE_BrunnenInfoP5.enabled = false;
         Bool_BrunnenSchalter = true;
 
         BrunnenWuerfel.gameObject.transform.localScale = new Vector3 (0, 0, 0);
     }
 
 
     // ########################
     // ## Aufruf von Seite 3 ##
     // ########################
     public void InfoP3_Press()
     {
         Can_DE_BrunnenInfoP1.enabled = false;
         Can_DE_BrunnenInfoP2.enabled = false;
         Can_DE_BrunnenInfoP3.enabled = true;
         Can_DE_BrunnenInfoP4.enabled = false;
         Can_DE_BrunnenInfoP5.enabled = false;
         Bool_BrunnenSchalter = true;
 
         BrunnenWuerfel.gameObject.transform.localScale = new Vector3 (0, 0, 0);
     }
 
 
     // ########################
     // ## Aufruf von Seite 4 ##
     // ########################
     public void InfoP4_Press()
     {
         Can_DE_BrunnenInfoP1.enabled = false;
         Can_DE_BrunnenInfoP2.enabled = false;
         Can_DE_BrunnenInfoP3.enabled = false;
         Can_DE_BrunnenInfoP4.enabled = true;
         Can_DE_BrunnenInfoP5.enabled = false;
         Bool_BrunnenSchalter = true;
 
         BrunnenWuerfel.gameObject.transform.localScale = new Vector3 (0, 0, 0);
     }
 
     // ########################
     // ## Aufruf von Seite 5 ##
     // ########################
     public void InfoP5_Press()
     {
         Can_DE_BrunnenInfoP1.enabled = false;
         Can_DE_BrunnenInfoP2.enabled = false;
         Can_DE_BrunnenInfoP3.enabled = false;
         Can_DE_BrunnenInfoP4.enabled = false;
         Can_DE_BrunnenInfoP5.enabled = true;
         Bool_BrunnenSchalter = true;
 
         BrunnenWuerfel.gameObject.transform.localScale = new Vector3 (0, 0, 0);
     }
 
 
     // ###########################################################
     // ## Funktion, die die Leinwand wieder per Button schließt ##
     // ###########################################################
     public void BrunnenSchliessen_Press()
     {
         Can_DE_BrunnenInfoP1.enabled = false;
         Can_DE_BrunnenInfoP2.enabled = false;
         Can_DE_BrunnenInfoP3.enabled = false;
         Can_DE_BrunnenInfoP4.enabled = false;
         Can_DE_BrunnenInfoP5.enabled = false;
         Bool_BrunnenSchalter = false;
 
         BrunnenWuerfel.gameObject.transform.localScale = new Vector3 (1, 1, 1);
     }
 }


How do I make the cube not interactable while one canvas is active?

FYI: the cube needs to remain active - If I close a second or later page while pointing away from the clickable cube, nothing reopens - but I cant make a user do that all the time... :D

Thanks for reading! :)

Comment
Add comment · Show 1
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 Vulture_6 · Sep 22, 2016 at 07:00 PM 0
Share

Edit: The cube carries the script with the code you that you see here.

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

2d Circle won't change size 0 Answers

OnGui.Button Lerp Object 1 Answer

Rotate Object around point and move it along sine function 1 Answer

Dragging a 2D sprite with touch 1 Answer

Object not Instantiating Correctly 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