I am using my own native plugin (trying to use Metal) to do rendering on iOS devices. In this plugin, I created the UnityPluginLoad / UnityPluginUnload function as what described in Unity - Manual: Low-level native plug-in interface (I noticed that it mentioned that iOS version of the plugin will be available soon. Can you please provide an ETA on that?) However, UnityPluginLoad() is not called when using the plugin, although other functions could be called from Unity C# script without problems.
Since the game will be released soon, I am desperately looking for solutions/workarounds.
The code is as following…
#ifndef SimplePlugin_hpp
#define SimplePlugin_hpp
#include "Unity/IUnityGraphics.h"
#include <stdio.h>
#include <assert.h>
#define LOG(...) printf("GAMERENDER: "); printf(__VA_ARGS__); printf("\n");
class GameRender
{
};
extern "C" UNITY_INTERFACE_EXPORT GameRender* UNITY_INTERFACE_API CreateGameRender()
{
LOG("GameLibPlugin::CreateGameRender");
return new GameRender();
}
extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginLoad(IUnityInterfaces* unityInterfaces)
{
LOG("UnityPluginLoad");
assert(false);
}
extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginUnload()
{
LOG("UnityPluginUnload");
assert(false);
}
#endif /* SimplePlugin_hpp */
The output is…
2017-01-23 18:39:53.374002 ProductName[2974:1396051] [DYMTLInitPlatform] platform initialization successful
2017-01-23 18:39:53.437198 ProductName[2974:1395942] → registered mono modules 0x100880420
2017-01-23 18:39:53.589918 ProductName[2974:1395942] You’ve implemented -[ application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add “remote-notification” to the list of your supported UIBackgroundModes in your Info.plist.
→ applicationDidFinishLaunching()
2017-01-23 18:39:53.629072 ProductName[2974:1395942] Metal GPU Frame Capture Enabled
2017-01-23 18:39:53.629476 ProductName[2974:1395942] Metal API Validation Disabled
→ applicationDidBecomeActive()
GfxDevice: creating device client; threaded=1
Init: screen size 1080x1920
Initializing Metal device caps: Apple A10 GPU
Initialize engine version: 5.5.0f3 (38b4efef76f0)
UnloadTime: 0.236750 ms
gameLib = CreateGameRender()
SimplePluginWrapper:Start()
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
GAMERENDER: GameLibPlugin::CreateGameRender
Setting up 1 worker threads for Enlighten.
Thread → id: 16f463000 → priority: 1
→ applicationWillResignActive()
→ applicationDidEnterBackground()
It shows that UnityPluginLoad was not called, while CreateGameRender was called successfully.
I’m using Unity 5.5.0f3. Any insights on this issue? Thank you very much!