Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Using Toggle Hololens

Discussion in 'VR' started by saifshk17, May 1, 2018.

  1. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Hello everyone,

    I have designed a game using toggle on Unity. I want to deploy it and work on Hololens. What functions should I alter for the user to tap on the Toggle? I have tried OnInputClicked but nothing works. Can someone help me out?

    Code (CSharp):
    1.  void Update()
    2.     {
    3.  
    4.      
    5.             tog1.image.enabled = true;
    6.             tog1.interactable = true;
    7.             Initial.text = null;
    8.             tog1.isOn = false;
    9.             myText.text = "Pick Item #1";
    10.             myText.color = Color.white;
    11.             myText.fontSize = 20;
    12.             cube.SetActive(true);
    13.          
    14.  
    15.             tog1.onValueChanged.AddListener(delegate
    16.             {
    17.                 StartCoroutine(ToggleValueChanged(tog1));
    18.             });
    19.        
    20.     }
    21.  
    22. IEnumerator ToggleValueChanged(Toggle change)
    23.     {
    24.  
    25.      
    26.         if(nextIn == false)
    27.         {
    28.      
    29.        
    30.            
    31.                // cube.SetActive(false);
    32.             tog1.image.enabled = false;
    33.        
    34.    
    35.             myText.text = "Item #1 Picked";
    36.             yield return new WaitForSeconds(1f);
    37.             myText.text = "Start with Item #2";
    38.             tog1.image.enabled = true;
    39.             cube1.SetActive(true);
    40.             yield return new WaitForSeconds(1);
    41.            
    42.                 tog1.onValueChanged.AddListener(delegate
    43.                 {
    44.                     StartCoroutine(ToggleValueChanged1(tog1));
    45.  
    46.                 });
    47.  
    48.              
    49.            
    50.             nextIn = true;
    51.  
    52.         }