/* * This file is part of the "House of the Future" showcase project by M2H (http://www.M2H.nl) * The original author of this code Mike Hergaarden. * Feel free to use this code for your own projects, drop me a line if you made something exciting! */ #pragma strict function Awake(){ SwitchMouse(); } function Update(){ if(Input.GetKeyDown(KeyCode.Escape)){ SwitchMouse(); } if(Input.GetMouseButtonDown(0)){ if(!Screen.lockCursor){ SwitchMouse(); } } } function SwitchMouse(){ if(Screen.lockCursor){ Screen.lockCursor=false; Screen.showCursor=true; }else{ yield; // MainMenu needs time to click on the exit button. yield; // ..this is bad practise! Screen.lockCursor=true; Screen.showCursor=false; } }