private var inCutScene: boolean = false;
function OnGUI(){
if (!inCutScene){
// Your GUI goes here
}
}
function BeginCutScene (){
inCutScene = true;
// your cutscene begins here
}
function EndCutScene (){
inCutScene = false;
}
Call BeginCutScene() when you start and EndCutScene() when you are done. No GUI...
EDIT
Or, as was suggested in the comments:
private var inCutScene: boolean = false;
function OnGUI(){
if (inCutScene) return;
// Your GUI code here...
}
function BeginCutScene (){
inCutScene = true;
// your cutscene begins here
}
function EndCutScene (){
inCutScene = false;
}
This is the correct way of doing it, since Unity GUI is immediate-mode. You could simplify this by instead of checking if(!inCutscene){doSomething();} but instead saying if(inCutscene) return; at the top of OnGUI(). This will do the same thing, but is actually a lot easier to throw in and pull out while still maintaining clean code.
You can deactivate the GUI on a particular camera in the Inspector. So just click on the camera in your scene that is the cut scene camera - and just deselect the GUI element.
OnGUI will still render when the GUI Layer component of a camera is there or not. Removing/disabling it only works for GUITextures/GUIText. OnGUI is drawn after all of the Cameras are rendered in that frame, and therefore is separate from the camera.
This is the correct way of doing it, since Unity GUI is immediate-mode. You could simplify this by instead of checking if(!inCutscene){doSomething();} but instead saying if(inCutscene) return; at the top of OnGUI(). This will do the same thing, but is actually a lot easier to throw in and pull out while still maintaining clean code.
– equalsequalsGood Point! I've edited my answer to show this option, as it makes very good sense.
– anon65157660