- Home /
Low-level native plugin on iOS
I have been trying to get a low native plugin working on iOS but I never seem to get the UnitySetGraphicsDevice or UnityRenderEvent callbacks. I am using modified example code from here and am receiving the SetTimeFromUnity native call but not the two rendering related callbacks. I also confirmed that GL.IssuePluginEvent is being called in my unity project but UnityRenderEvent is never called in response.
Has anyone had any luck getting the low-level interface working on iOS? Is there some sort of trick? The sample with the documentation implies it only works on Windows/Mac.
EDIT: Some clarification
I actually have native calls working fine. I was wanting info specifically on the low level rendering callbacks you can receive that were added in 3.5 (UnitySetGraphicsDevice or UnityRenderEvent callbacks) that are described in the link in my post. I need to make some native OpenGL draw calls outside of Unity and going forward using those callbacks is the only way to assure I get the callback on the rendering thread. Right now I can make the OpenGL draw calls on the same thread that I make native calls on but when multi-threading is added to iOS Unity in the future (as it currently works on Windows) I will need those low level graphics calls to work to ensure I do my drawing on the correct thread.
Did you solve this problem? I'm trying to build an iOS native plugin that will do some OpenGL rendering and I am concerned about not being on the render thread as well. I can't seem to find any complete examples for iOS.
Answer by Siney · Jul 30, 2016 at 10:04 PM
From Unity 4.5, you have to register the event.
"iOS: Added support for render events (GL.IssuePluginEvent). Please note that you need to manually register them, as iOS do not support dynamic libraries. Check trampoline for UnityRegisterRenderingPlugin function."
For example:
import
import "UnityAppController.h"
extern "C" void UnitySetGraphicsDevice(void* device, int deviceType, int eventType); extern "C" void UnityRenderEvent(int marker);
@interface MyAppController : UnityAppController { } - (void)shouldAttachRenderDelegate; @end
@implementation MyAppController
(void)shouldAttachRenderDelegate; { UnityRegisterRenderingPlugin(&UnitySetGraphicsDevice, &UnityRenderEvent); } @end So you just have to do some editing of UnityAppController.mm after you build the project. If you do "Append" it will leave your edits in place.
Your answer
Follow this Question
Related Questions
Native Alert on iOS (plugin) 1 Answer
Native GUI-Style on IOS 2 Answers
How to get local currency u3dxt 1 Answer
Access photos, videos & music from iOS and Android library? 0 Answers