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 hs · Dec 26, 2012 at 02:27 PM · pluginplugins

Is there any method to callback from plugin (Windows)?

Hi there,

This is on Windows

I want to integrate a library into Unity. This library can receive some events. I want to pass these events into Unity. Can I call C# functions from C just like C's callback functions? Is using UnitySendMessage the only way to send back messages into Unity? If so, can UnitySendMessage be used in Windows? Thanks.

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 Fattie · Dec 26, 2012 at 02:29 PM 0
Share

just FWIW you may like to look at the prime1 page (they are the leaders in Unity plugin technology!) You'll see from their docs how to use delegates, etc.

2 Replies

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

Answer by hs · Jan 04, 2013 at 11:44 AM

I find the answer from Unity Forum. http://forum.unity3d.com/threads/89930-Communicating-C-with-C

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
avatar image
0

Answer by $$anonymous$$ · Dec 26, 2012 at 02:38 PM

I just recently answered the same question which can be found here: relevant answer

I think that's exactly what you are looking for :) It's all I've had a need for when developing plugins, and as Fattie said, I, too looked at the prime1 documentation to see how they implemented it on the Unity script side, and it's all entirely possible with the use of UnitySendMessage.

Comment
Add comment · Show 5 · 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 Bunny83 · Dec 26, 2012 at 04:43 PM 0
Share

That's quite pointless. Beside the fact that the iOS version of the unity engine provides the UnitySend$$anonymous$$essage function (which actually works similar to Send$$anonymous$$essage in the web player object), as far as I know it's not available for windows. Since iOS uses xcode it was quite simple to add this function to their engine. On all other platforms the unity engine was never ment to be used from external applications / plugins.

Next point is that UnitySend$$anonymous$$essage has quit an overhead since it has to find the game object first. It also delays each callback one frame. Since Unity uses a single thread for scripting and made the API not thread safe it's pointless to use callbacks. Your plugin either provides instant result by returning something to the caller, or you have to poll your plugin every frame.

Prime31 mainly develops for $$anonymous$$ac and iOS. I haven't seen any evidence that UnitySend$$anonymous$$essage will work on Android. On Android there are other alternatives, but the question here was about a windows build.

avatar image Fattie · Dec 26, 2012 at 04:47 PM 1
Share

what is "score" dude ??

avatar image Bunny83 · Dec 26, 2012 at 08:19 PM 0
Share

Sorry, but my tablet don't know "xcode" :D That auto-correction is annoying sometimes... I fixed it :)

avatar image Fattie · Dec 26, 2012 at 08:34 PM 0
Share

Ah - interestingly, when you edited that, it did NOT send a new copy (well not to me anyway). Previously, if one edited a typo in a comment, it would somewhat annoyingly send the new version to everyone. Perhaps they've made a change. Cheers

(We live in the age of "annoying autocorrection" :) )

avatar image hs · Dec 27, 2012 at 02:05 AM 0
Share

Hi All,

Actually, I have read Unity manual about "Plugins (Pro/$$anonymous$$obile-Only Feature)", "Building Plugins for Desktop Platforms", "Building Plugins for iOS", and "Building Plugins for Android". I know I can use UnitySend$$anonymous$$essage for iOS plugin, but I cannot find the same method for windows plugin (as Bunny83 mentioned).

According to your previous discussions, it seems C# delegate is a possible solution. Can anyone give me some examples or links? Especially, how to pass C# delegate into C API in Unity?

Thanks.

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

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

FileNotFoundException: Could not load file or assembly 0 Answers

Native Android plugin CPU subfolder approach not working 1 Answer

Android Activity equal in ios 0 Answers

Starting Writing Unity Plugins 2 Answers

Using AndroidJavaClass in a java Unity3d plugin 0 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