Okay So I was writing a script in which I was attempting to lock camera movement when a GUI pulls up. The problem I am having is that I have multiple GUI’s that all need to affect camera movement, but when I apply the locking scripts to the script that displays the gui to multiple objects, only one out of the say, five objects actually works. The scripts don’t break the gui’s but they don’t use the locking motion. Here’s the two scripts below.
GUI Object 1:
var information: String;
var script: MouseLookPlus;
var script2: MouseLookPlus;
private var guiOn = false;
private var rect: Rect;
function Mouse1 () {
script = GameObject.Find("Main Camera").GetComponent(MouseLookPlus);
script.enabled = false;
script2 = GameObject.Find("First Person Controller").GetComponent(MouseLookPlus);
script2.enabled = false;
}
function Mouse11 () {
script = GameObject.Find("Main Camera").GetComponent(MouseLookPlus);
script.enabled = true;
script2 = GameObject.Find("First Person Controller").GetComponent(MouseLookPlus);
script2.enabled = true;
}
function OnMouseDown () {
guiOn = true;
rect = Rect(Screen.width/2-120,Screen.height/2-100,300,300);
}
function OnGUI () {
if (guiOn){
Mouse1();
GUI.Label(rect, information);
if (GUI.Button(Rect(Screen.width/2-0,Screen.height/2-50,75,50), "False")) {
guiOn = false;
}
if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2-50,75,50), "True")) {
animation.Play ("dooropen1");
guiOn = false;
}
}
else {
Mouse11 ();
}
}
GUI Object 2:
var information: String;
var script: MouseLookPlus;
var script2: MouseLookPlus;
private var guiOn = false;
private var rect: Rect;
function Mouse2 () {
script = GameObject.Find("Main Camera").GetComponent(MouseLookPlus);
script.enabled = false;
script2 = GameObject.Find("First Person Controller").GetComponent(MouseLookPlus);
script2.enabled = false;
}
function Mouse22 () {
script = GameObject.Find("Main Camera").GetComponent(MouseLookPlus);
script.enabled = true;
script2 = GameObject.Find("First Person Controller").GetComponent(MouseLookPlus);
script2.enabled = true;
}
function OnMouseDown () {
guiOn = true;
rect = Rect(Screen.width/2-120,Screen.height/2-100,300,300);
}
function OnGUI () {
if (guiOn){
Mouse2();
GUI.Label(rect, information);
if (GUI.Button(Rect(Screen.width/2-0,Screen.height/2-50,75,50), "False")) {
guiOn = false;
}
if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2-50,75,50), "True")) {
animation.Play ("dooropen2");
guiOn = false;
}
}
else {
Mouse22 ();
}
}
I’m not getting any error, and the code renders, just doesn’t work properly, are the locking scripts possibly conflicting with each other? Is there a script I can tie to just the first person controller when a gui is on? Help would be appreciated.