0

I was wondering, what is the most efficient way to pass boolean values between two javascript scripts in Unity. Right now the method I use - is to make a reference in script#1 to script#2 which contains the boolean, then then calling the script#2 function which contains the boolean, and the taking the value from the function. Is there an easier way? I tried to pass static bool values directly, yet is shows errors. Thank you in advance!

  • 3
    Possible duplicate of [In Unity, how can I pass values from one script to another?](http://stackoverflow.com/questions/13891892/in-unity-how-can-i-pass-values-from-one-script-to-another) – Serlite Jul 29 '16 at 18:44
  • Static boolean values may not work because they are not object-orientated. If you only use one instance of your script you should be fine though. Mind showing us a piece of code and what errors it shows? – Ian H. Jul 30 '16 at 09:41

1 Answers1

0

I have two solutions: Make a public variable in the receiving script, and change it using the sending script. You can also make a public function in the receiving script with a Boolean argument and execute it with the sending script to let them communicate in that way. Chose the solution you prefer.