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 user-10779 (google) · May 14, 2011 at 03:38 PM · c#javascriptfunction

How to call a c-sharp function from javascript?

Ok, the problem is i need to implement socket connections, but there i think there is no other way than implementing them on c sharp. But now i need to call the functions on my csharp file from javascript and it gives me a compile error, because it cannot find the function in chsarp file. It might be an issue related to compilation order. Can anyone suggest any solutions?

Comment
Add comment · Show 1
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 Eric5h5 · May 14, 2011 at 05:58 PM 0
Share

You shouldn't need C# to implement socket connections. See http://answers.unity3d.com/questions/58710/socket-connection-throught-javascript/58907#58907

1 Reply

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

Answer by Peter G · May 14, 2011 at 04:27 PM

Let's go through the quick check to make sure all of these statements are true:

  1. Unity can find the class. If you get an error that your type doesn't exist, then you may have typed it in wrong or you might have a compilation order problem. SEE below.

  2. You are accessing the function correctly: instance.Method() or ClassName.StaticMethod()

  3. You typed the method name in correctly (I know its obvious but its worth asking)

If none of these are true you might have an issue with compilation order.

See this page on what order scripts are compiled in. You really just need the C# script to be compiled before the js script. I would suggest either placing it in a "Plugins" folder or in "Standard Assets".

There is also a chance that you can compile them at the same level. There is no specific order that they will be compiled in, but I find often that C# scripts are compiled before js scripts on the same level. Note: That is by no means a guarantee that it will happen that way and you CANNOT rely on this random chance. I am merely stating what I observe more often than not

Comment
Add comment · 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

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

No one has followed this question yet.

Related Questions

Multiple Cars not working 1 Answer

Lower player's health from separate script. 2 Answers

Translate this statement from .js to C# 2 Answers

call a javascript function from c-sharp 2 Answers

Distribute terrain in zones 3 Answers


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