Objective:
When you publish WP8 apps with unity, you often encounter situations where the API isn't working, such as popping the MessageBox, not using String.Compare (String,string,bool), and so on. So how do we solve these problems? One of the solutions is to make plugins. There is an article in Unity Manual: http://docs.unity3d.com/Manual/wp8-plugins-guide-csharp.html is about making Unity's WP8 plugin. I'll describe the process in Chinese. Because of limited capacity, if there is anything wrong, I hope you great God help ha! Thank you!
1. Create a new blank solution as shown in:
2, to the Blank solution, add a project
3, this new project is a C # class library project, we name it Fakedll, in particular, to choose the. NET Framework 3.5, as shown:
4. After this project is built, we will add a C # WP8 class Library project to that solution. Note At this time, you should choose the. NET Framework 4.5 and later, we are named Realdll:
5. The following is the most critical step: Change the "assembly name" and "Default namespace" in the two class library properties to the name of the solution, as shown in:
Because the default namespace is changed, the corresponding changes are made in class as well.
6, the next is to write code, we fakedll the class to write unity can use some of the functions, in the Realdll class write WP in the actual use, as shown in the following code:
Fakedll:
Realdll:
7. Select two items to generate the DLL, as shown in:
The generated DLLs are located at: realdll:\unitywpplugins\realdll\bin\debug; Fakedll:\unitywpplugins\fakedll\bin\debug, copy the two fakedll generated files to the Assets/plugins folder in Unity, Copy the two files generated by Realdll to the Assets/plugins/wp8 folder in unity, as shown in:
8. Finally in unity we can invoke the GetDevice method in Class1 under the Unitywpplugins namespace. The results are as follows on the Unity editor and WP Real machine:
Code:
Editor:
WP8:
This method is also useful for making Windows Store apps and Windows Universal apps.
Create a WP8 plugin for unity