Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on CreateRenderAPI #6

Closed
podborski opened this issue Jan 18, 2020 · 4 comments
Closed

Question on CreateRenderAPI #6

podborski opened this issue Jan 18, 2020 · 4 comments

Comments

@podborski
Copy link

Sorry for bothering you guys, but I really would like to understand one thing.

Can somebody explain to me why RegisterPlugin() is called only for WEBGL?

#if UNITY_WEBGL && !UNITY_EDITOR
RegisterPlugin();

I don't quite understand from the code how OnGraphicsDeviceEvent (which creates an instance of the RenderAPI) gets called.

In other words, when not using UNITY_WEBGL how does CreateRenderAPI gets called?

s_CurrentAPI = CreateRenderAPI(s_DeviceType);

I know that I am missing something, since the code seems to work just fine.

Thank you very much.

@samjacobson
Copy link

I'm not affiliated with Unity.

Unity calls UnityPluginLoad in the plugin dll when the plugin is first accessed. This calls OnGraphicsDeviceEvent directly (at the end of the function), and also registers that function with Unity here:

s_Graphics->RegisterDeviceEventCallback(OnGraphicsDeviceEvent);
so that it will be called when a graphics device event occurs (e.g. shutdown).

@podborski
Copy link
Author

@samjacobson Thank you :) This explains it. I just tested it and indeed, UnityPluginLoad gets called automatically.
Is there any documentation on it that I have missed?

@samjacobson
Copy link

https://docs.unity3d.com/Manual/NativePluginInterface.html
mentions the UnityPluginLoad.

@podborski
Copy link
Author

Wow, how could I miss that?
Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants