Hi,
I’ve got some problems accessing another scripts variables. Wonder if anyone can help me out, so I post here
I have three scripts : A, B , and C.
I load script A, and in script A I change a variable in script B using my own function AccessScriptB, and it works.
The problem comes out when I try to change another variable in script B when I call function X in script C using script A. No issue when I build the project, but when the function AccessScriptB in Script A is loaded it hangs.
FYI:
I can just remove my function X from script C to script A and it worked, but I want to acces it in script C for future preparation. anyone has ideas to solve this? please help me out guys…I’m still new to programming.
Here’s some scripts from script A
function AccessScriptB() {
if( touchWithinRange scriptB.heroTrue == false)
{
scriptB.heroTrue = true;
scriptB.heroImage = heroImage1;
scriptC.X();
}
}
Script C function is
function X() { scriptB.hNU = hN;}
the function X only has that line of command since I want to change it from script C for future update preparation
touchWithinRange is a range Selection Box
hNU is a static var in Script B
heroTrue is static var in ScriptB
hN is a static var in Script C
while in script B I only shows the variables in OnGUI function
function OnGUI()
{
GUI.Label ( myRectValues, hNU, mySkin.customStyles[1] ) ;
}
that’s all I want to do, changing a variable in script B accessing from script A which calls the function in script C and displays it. Anyone can help me?