Game Development Reference
In-Depth Information
Getting access to Unity
The first and simplest bridge between the platforms is to allow access to your Unity game
from a native platform. As you can see in the following diagram, the first challenge is to
enable a platform to talk to your Unity package:
On the .NET platforms such as Windows and Windows phone, the following two patterns
are used to access the game embedded within the Unity player directly from the host plat-
form:
• The UnityEngine namespace from the Unity player
• The static classes in your Unity project
Accessing the UnityEngine namespace
Once you have built a project for the .NET platforms, you have a ready-to-run solution.
The player that deploys with the project also gives you indirect access to all the compon-
ents and game objects within your scenes through the UnityEngine namespace.
For the game objects, you can simply query with the GameObject.Find method, as
shown in the following code example:
var _cube = UnityEngine.GameObject.Find("Cube");
The preceding code will give you a game object that you can manipulate however you
wish to, as if you were in Unity itself.
Alternatively, if you want to access scripts or non-standard content, you will need to cast
the objects you search for to use them properly. Refer to the following example:
Search WWH ::




Custom Search