- Home /
Calling C# Classes from JS
I'm using an extension that is written in C#, but I want to access classes from it in a JS script. I found somewhere else that in order to do this, the C# code must be compiled first, and the way to ensure that is to place it in the Plugins, Standard Assets, or Pro Standard Assets folders. The only problem is that once I do that, the editor for the extension stops working. It just says "multi-object editing not supported". But once I move the code back out into its own folder, the editor works again (but now I can't access it from a JS script).
Is there a better way to access C# classes from a JS script? Or a better way to ensure that the C# code gets compiled first?
Hey, that's cool and good to know, but the problem isn't with execution order, it's with compilation order. I don't get as far as executing because my script won't compile.
It seems like it has to be in the plugin folder then. Hmmmm. So this extension extends the editor or something and you want to access it's static functions? What and how exactly are you using this extension?
No, the extension allows me to perform A* path planning (I don't have the pro version of Unity). It includes and editor that lets you define the graph.
I have a static function in my own class that I want to be able to call from elsewhere to tell all objects to regenerate a new path. $$anonymous$$Y static function invokes the A* path planning methods in the extension.
Because the extension is written in C#, my class is in C#, meaning that whatever calls my static function has to be in C# unless I can figure this problem out.
Answer by Eric5h5 · Apr 22, 2012 at 05:37 AM
So do I HAVE to move the C# code somewhere else to ensure it compiles first if I want to call it from a JS script? If so, any idea why moving it into the Plugins folder would somehow break the editor?
Yes, that's what the docs say. There's no particular reason to put it in the Plugins folder though.
Okay, well I guess I'll play around with the project and the extension and try to figure out why the editor stops working once I move it into one of those folders. (btw, I just said Plugins folder because I'm trying to avoid putting stuff that didn't come from Unity in the Standard Assets folder. ;)
The link does not work. Seems that now the reference was moved to http://docs.unity3d.com/$$anonymous$$anual/ScriptCompileOrderFolders.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613070611im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Get game component type? 1 Answer
[C#] PlayerRelativeControl conversion errors 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers