Unity code C# packaged as dll

1 Create a project after the Visual studio software is opened

 

2 and select the class library type

3 Write a simple code to see the effect (it will report an error), mainly because the class library is not added, and using UnityEngine; reference space

 

 

 

4 Add class library, reference space

It is found that an error will still be reported, which requires adding the application library unityengine.dll, the method is as follows

 

Find UnityEngine.dll in the installed unity directory. After adding it, you will find that the red report disappears.

 

 

5 Right-click the solution to generate a solution

Before this, you need to select the version of .framwork to run, which needs to be consistent with the version requirements of unity, mine is under .framwork3.5

 

 

 

6. At this time, you can find the dll file in the project and add it to unity

Calling dlls in code requires using namespace

 

 

 Note: Methods in C# functions packaged as dlls must use static public methods

 

 

This is the link I made: https://pan.baidu.com/s/1i3LBHrkQOg7eCh9Sf-EQVw Password: aqvp

What is the best way, please leave a message

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325302736&siteId=291194637