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
1
Question by RKS324 · Dec 02, 2011 at 05:04 PM · plugindll

Mfc dll file can use as unity plugin?

I have an MFC dll file and source project. I wonder can i use it as an unity plugin file? Then how can I use it? Need help.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by aldonaletto · Dec 03, 2011 at 12:28 AM

In principle, you can use any DLL file as a plugin in Unity - this is a .NET feature, and is accessible via C# scripts.
You must write a C# script to import the functions, like this one:

using UnityEngine; using System.Collections; using System.Runtime.InteropServices;

public class MyDll : MonoBehaviour {

 [DllImport("MyDllFile")]
 public static extern int Function1(int v1);

 [DllImport("MyDllFile")]
 public static extern float Function2(float v2);

} This script imports the functions Function1 and Function2 from the DLL file "MyDllFile.dll" stored in the Plugins folder.
Since the functions are defined as static in the MyDll script, you can use them in other scripts as MyDll.Function1(), MyDll.Function2() etc.
NOTE: Unfortunately, JS and CS scripts don't see each other at compile time, thus JS users (like me) will have some trouble to use imported functions: it's necessary to save the script above in the Plugins folder, and the JS scripts in some other folder compiled after Plugins (see Script Compilation to learn more about this).

Comment
Add comment · Show 2 · 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 RKS324 · Dec 03, 2011 at 12:58 AM 0
Share

Can I use Standard $$anonymous$$FC API function such as LoadLibrary?

avatar image aldonaletto · Dec 03, 2011 at 10:40 AM 0
Share

I had some experience using specific plugins that I wrote in Delphi's Pascal, but honestly know nothing about $$anonymous$$FC functions. If LoadLibrary will link to a second DLL, you may have problems - see this question: http://answers.unity3d.com/questions/187694/dllnotfound-when-the-plugin-c-dll-links-another-c.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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Distributing Precompiled Scripts 1 Answer

Sending and receiving variable-length arrays to and from DLL 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Can I use my own input device? 4 Answers

reference my .dll 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