My apologies is this appears to be a stupid question but I have searched the forums for an answer but haven’t found one
I have an object with a C# script running on it for following a moving object around the screen. However there are times when I wish to deactivate this script for a certain amount of time and then reactivate it, all during run time.
I have a variable in the C# script that if set to “0” all its actions are deactivated and while set to “1”, run all actions associated with the script.
The problem is, how to a access and change this variable in runtime, and can I use a .js to do it?
Ive seen all the stuff on global vars in .js and understand how it works but I guess the issue is that I’m trying to cross communicate with two langs…
Just abit more info, while my scene is running and I just change that Script Run var to 0 it stops like I want it to, and takes off again when set back to 1.
I’m still searching the forum and funnily finding almost answers using my own topic title as the search param but I’m still a little confused…
Ive moved the C# script to different folders from the JS ones because apparently that’s an issue but still having a read and write problem FRAK!
a different folder won’t suffice.
The folder you put it in must be a folder thats compiled earlier.
The documentation contain informations about the compilation order in the advanced section.
Basically you would put this in the Standard Assets or plugins folder and the js script that accesses it in a folder different from the standard or pro asset or plugin folder
Well yes that probably correct hence the error message, and the only reason its in the Update is for testing.
However I am no closer to a solution, what kind of a C# function do I have to write to receive the SentMessage?
…This is just so weird, I’m used to working in DxStudio (JavaScript) Flash (ActionScript), where referencing any variable across all GameObjects is very very easy…
Two years too late, but I think its telling you that you did not identify your new variable “ScriptRun”. C is more strict with new variable declarations than JS. And yes, JS may have created the variable, but C doesnt know that. She can grab the value, but not the variable name from JS. Declare ScriptRun as a new C integer.