- Home /
Why can't i access my c# class from javascript
I have a normal c# class that inherits the Mono Behaviour class and I want to use JavaScript for the AI in Eteeski's Tutorials but unity gives me an error saying: Assets/Scripts/AI/EnemyMovement.js(2,22): BCE0018: The name 'PlayerMovement' does not denote a valid type ('not found').
it is definitely spelt correctly the sooner you could help me with this the better. thanks in advance
For solved questions, you don't write "solved" in the title, you accept the answer by clicking the checkmark.
Answer by aldonaletto · Jul 08, 2012 at 04:18 AM
C# and javascript can't see each other at compile time because the compilers are different - but scripts already compiled can be accessed, no matter in which language they were written. To help solving this problem, Unity compiles scripts in 3 consecutive waves: scripts in Standard Assets, Pro Standard Assets and Plugins are compiled first, scripts in the Editor subfolders of these folders are compiled next, and scripts in other folders are compiled last (see Script Compilation in the docs). You could place the C# script in Plugins or Standard Assets, and the other scripts in another folder - Assets/Scripts, for instance.
i read about this loads of times but didn't understand it. now i do, thank you
To anyone having issues with this: make sure you do a clean compile. Seems like Unity didn't notice I moved the files (didn't trigger recompile of those files).
guys i still dont understand what to do to fix this problem how do i stop the error from co$$anonymous$$g. I have the same problem.
i did not understand the script compilation order until i found this. thank you SO much. for future use, i've bookmarked this page.
Your answer
Follow this Question
Related Questions
help with creating a static Instance in javascript 2 Answers
Flying AI Planes 0 Answers
Creation of RPG Class Stat Presets? 1 Answer
Distribute terrain in zones 3 Answers
javascript call a method from c sharp and vise versa 1 Answer