Author Unity3d brother---Leroyyang
Through the online God's information and their own collation, learn to use vs2013 simple encapsulation DLL file, convenient interface mode development, make the logic layer clearer.
Operation Steps
1. Open vs2013, new project-New class library (note that the top. NET Framework chooses the 3.5 version below, because Unity3d (the current Unity3d version is 3.5) is supported by the. NET version 3.5.
If you select the version 4.0 appears
Internal compiler error. See the console log for more information. Output was:unhandled Exception:System.TypeLoadException:Could not load type ' System.Runtime.Versioning.
Error.
)
2, after the completion of the new project, write a simple test code
Using System;
Namespace Yanglei {
public class Yl
{
public static int Attack (int hp)
{
return HP;
}
}
}
3, build the solution, find the VS Project project folder directory under E:\ProjectYang\bin\Debug DLL file
4. Import the DLL into unity and create a new folder named Plugins directory under the Asset folder in Unity
5. Create a new script in unity
Using Unityengine;
Using System.Collections;
Using Yanglei;
public class Actionscript:monobehaviour {
void Start () {
int hp = Yl.attack (100);
Debug.Log (HP);
}
}
Run results
Unity Wrapper DLL Tutorial Grooming