x


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?

more ▼

asked Apr 22 '12 at 02:27 AM

Moohasha gravatar image

Moohasha
117 3 8 12

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.

Apr 22 '12 at 03:50 AM Moohasha

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?

Apr 22 '12 at 03:59 AM Lttldude

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. MY 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.

Apr 22 '12 at 12:34 PM Moohasha
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
more ▼

answered Apr 22 '12 at 05:37 AM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

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?

Apr 22 '12 at 12:36 PM Moohasha

Yes, that's what the docs say. There's no particular reason to put it in the Plugins folder though.

Apr 22 '12 at 12:40 PM Eric5h5

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. ;)

Apr 22 '12 at 12:53 PM Moohasha
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4167
x3461
x255

asked: Apr 22 '12 at 02:27 AM

Seen: 1795 times

Last Updated: Apr 22 '12 at 12:53 PM