Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Moohasha · Apr 22, 2012 at 02:27 AM · c#javascript

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?

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lttldude · Apr 22, 2012 at 02:46 AM 0
Share

maybe this: http://unity3d.com/support/documentation/Components/class-ScriptExecution.html

avatar image Moohasha · Apr 22, 2012 at 03:50 AM 0
Share

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.

avatar image Lttldude · Apr 22, 2012 at 03:59 AM 0
Share

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?

avatar image Moohasha · Apr 22, 2012 at 12:34 PM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Apr 22, 2012 at 05:37 AM

http://unity3d.com/support/documentation/ScriptReference/index.Script_compilation_28Advanced29.html

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Moohasha · Apr 22, 2012 at 12:36 PM 0
Share

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?

avatar image Eric5h5 · Apr 22, 2012 at 12:40 PM 0
Share

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

avatar image Moohasha · Apr 22, 2012 at 12:53 PM 0
Share

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

avatar image Fleischer · Aug 28, 2014 at 02:32 PM 0
Share

The link does not work. Seems that now the reference was moved to http://docs.unity3d.com/$$anonymous$$anual/ScriptCompileOrderFolders.html

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

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

How to call a c-sharp function from javascript? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges