- Home /
Cant get C# to talk to JavaScript
Hello,
I have a C# script that needs to get a variable from a JavaScript script. Here is a snippet of my C# script:
itm.knifeInventory = StoryControl.inventoryKnife;
StoryControl.inventoryKnife is a JS variable, but I get a "The name 'StoryControl' does not exist in the current context"? How can I grab the variable from the JS without using a GetComponent (because the scripts are not on the same object)
Thanks
Answer by xeophin · Mar 17, 2011 at 11:29 AM
The JS has to compile before the C# script. On this page of the documentation you get a detailed description of the compile order in Unity.
Answer by Lab013 · Mar 16, 2011 at 11:57 PM
Put the C# script in the Standard Assets folder.
Im still getting a "The name "StoryControl" does not exist int eh current context" ...?
Answer by e-bonneville · Mar 17, 2011 at 01:58 AM
Put the C# script in the Standard Assets folder and make sure your JS file is outside of the Standard Assets folder. ;)
Your answer
Follow this Question
Related Questions
Moving from JS to C#, what should I know? 1 Answer
c# to JavaScript how? 3 Answers
Multiple Cars not working 1 Answer
Code not working in C# 1 Answer
Translating js to c#, getting NULLReferenceExeption 2 Answers