I’m having a really weird issue right now. For some reason when I try calling a function from another script it will call the function but won’t trigger my while statement. Which if I call the function from the main script the while statement always gets called and the function plays through as expected. I noticed when calling the function from another script it does change my first boolean to true, which it should but then after that it just doesn’t call my while statement. Not sure what could be wrong since the function works perfectly fine when called in the main script where the functions located.
You probably need it to be public. I think it’s accessing the while loop, but it isn’t changing those variables. You could put a debug inside the while loop to test it. I don’t use js, so maybe I’m wrong about that.
If it changed slotWindow, it pretty much had to go into the yield, because that was the condition needed. Did you try a Debug.Log(“in while loop”);, inside the while loop? Are you using a debugger and it just skips it or what?
What I was saying in my original post is if I call that function from inside of my first script then the function calls everything. If the function is called from a different script then it just activates the first piece of code slotWindow =true; The while loop should be activating the same way no matter where the function is being called from.
In c#, it has to be a public function, but they give errors and whatnot. I know I’ve gotten them before, also when trying to change variables that aren’t public, but I think js variables are public by default.
This is from the script reference:
function Update () {
// To access public variables and functions // in another script attached to the same game object. // (ScriptName is the name of the javascript file) var other : ScriptName = gameObject.GetComponent(ScriptName);
// Call the function DoSomething on the script other.DoSomething ();
// set another variable in the other script instance other.someVariable = 5;
}