Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CheckSwitch()
- {
- // 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
- // to blue, which means the menu is invisible
- if (Vector2.Distance(TouchVector,SwitchObject_Vector) < 0.1 && SwitchObject.renderer.material.color == Color.yellow)
- {
- for (var t=0;t<MenuObject.Length;t++)
- {
- if (MenuObject[t].active==true) MenuObject[t].SetActiveRecursively(false); // set all Menu items to inactive
- }
- SwitchObject.renderer.material.color = Color.blue;
- time_cnt = Time.time; // store current time
- }
- if (Time.time > time_cnt) // check if time has elapsed since last time the button was used
- {
- // 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
- // to yellow, which means the menu is visible
- if (Vector2.Distance(TouchVector,SwitchObject_Vector ) < 0.1 && SwitchObject.renderer.material.color == Color.blue)
- {
- for (var h=0;h<MenuObject.Length;h++)
- {
- if (MenuObject[h].active==false) MenuObject[h].SetActiveRecursively(true); // set all Menu items to active
- }
- SwitchObject.renderer.material.color = Color.yellow;
- }
- }
- }
Add Comment
Please, Sign In to add comment