Unity Wrapper DLL Tutorial Grooming

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.