JSBinding + SharpKit / Setting up SharpKit project

IMPORTANT

we are going to set up SharpKit project because we are going to follow this recommended workflow:

  1. write a C# MonoBehaviour file as usual (let's call it A)
  2. attach script A to gameObject (let's call it GO), set up public variables in the Inspector
  3. select gameObject go and click menu JSB | JSB/Copy Selected GameObjects MonoBehaviours to replace A with JSComponent
  4. get A.javascript: open Visual Studio solution from Unity and build SharpKit project.
  5. bingo! you now have a JavaScript version GO. if you save it as prefab, you can download this prefab through WWW (no requiring uses to re-download whole game).

 

1. install sharpkit
download sharpkit_5_4_9.exe installer from https://github.com/SharpKit/SharpKit/releases (about 10MB).

2. install UnityVS
it's a free tool, google 'visual studio tools for unity' to find download url.


import UnityVS package after installation.
(it's under installing directory, named 'Visual Studio 201x Tools.unitypackage')

3. open unity project in Visual Studio

 

now there are 2 projects in the solution:

 

4. add sharpkit project to solution:

r-click on solution -> add -> new project

 

5. edit SharpKitProj.csproj file, add these lines:

<ItemGroup>

  <Compile Include="..\Assets\**\*.cs">

    <Link>%(RecursiveDir)%(FileName)</Link>

  </Compile>

</ItemGroup>

 

it adds all .cs files under project Assets folder to SharpKit project (only link, no copy).

 

 

5. close solution and reopen it with unity

 

6. add these dlls to SharpKit project REFERENCES:

UNITY_INSTALL_DIR/Data/Managed/UnityEditor.dll

UNITY_INSTALL_DIR/Data/Managed/UnityEngine.dll

 

7. add compiling flags to SharpKit project:

UNITY_EDITOR

UNITY_5_1 (when you are running Unity 5.1, add UNITY_4_5 if under Unity4.5, for example)

 

8. build SharpKit project.

 this step will compile all C# classes with JsType attribute to JavaScript file.

-------------------------------------------------------------

 

back home

JSBinding + SharpKit / Home

你可能感兴趣的:(project)