Guest User

Untitled

a guest
May 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function CheckSwitch()
  2. {
  3.  
  4.    // Check if the button is set to yellow, if so all items are active, ... On touch set all items to false, and set button color
  5.    // to blue, which means the menu is invisible
  6.    
  7.  
  8.    if (Vector2.Distance(TouchVector,SwitchObject_Vector) < 0.1 && SwitchObject.renderer.material.color == Color.yellow)
  9.      {  
  10.  
  11.          for (var t=0;t<MenuObject.Length;t++)
  12.          {
  13.            if (MenuObject[t].active==true) MenuObject[t].SetActiveRecursively(false);   // set all Menu items to inactive
  14.          }
  15.    
  16.          SwitchObject.renderer.material.color = Color.blue;  
  17.          
  18.          time_cnt = Time.time;   // store current time
  19.          
  20.      }
  21.  
  22.      
  23.      
  24.      
  25.      if (Time.time > time_cnt)   // check if time has elapsed since last time the button was used
  26.      {
  27.      
  28.      // Check if the button is set to blue, if so all items are inactive, ... On touch set all items to true, and set button color
  29.      // to yellow, which means the menu is visible
  30.      
  31.       if (Vector2.Distance(TouchVector,SwitchObject_Vector ) < 0.1 && SwitchObject.renderer.material.color == Color.blue)
  32.        {  
  33.    
  34.        
  35.          for (var h=0;h<MenuObject.Length;h++)
  36.          {
  37.            if (MenuObject[h].active==false) MenuObject[h].SetActiveRecursively(true);  // set all Menu items to active
  38.          }
  39.        
  40.          SwitchObject.renderer.material.color = Color.yellow;  
  41.        }
  42.        
  43.      }
  44.  
  45.  
  46. }
Add Comment
Please, Sign In to add comment