Understand how to run code when your application is running on a device.
You can call iOS native plug-insA set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary only when your application runs on a device or in the Simulator. Wrap native method calls in a C# layer that checks the current platform and returns placeholder values in the Unity Editor, so your scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary don’t fail. Store this C# file in your project’s Assets folder.
Use platform conditional compilation or Application.platform to branch your code.
Platform-dependent compilation is faster than checking Application.platform because it’s evaluated at compile time, rather than runtime.
Use the following pattern:
void MyMethod()
{
#if UNITY_IOS && !UNITY_EDITOR
CallNativeMethodImplementation();
#else
CallEditorMethodImplementation();
#endif
}
Alternatively, check Application.platform at runtime and return placeholder values in the Editor:
void MyMethod()
{
if (Application.platform != RuntimePlatform.OSXEditor)
{
return _GetLookupStatus();
}
else
{
return "Done";
}
}