From c44da0f15cbc3ddef49294d727c6d3a4e7431257 Mon Sep 17 00:00:00 2001 From: Egor Date: Mon, 19 Feb 2018 21:38:48 -0800 Subject: Fixed crash in Unity emulator on Android when changing device orientation --- unityplugin/GhostCubePlugin/PluginSource/src/RenderingPlugin.cpp | 4 ++++ unityplugin/UnityEmulator/src/UnityGraphicsGLCoreES_Emulator.cpp | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'unityplugin') diff --git a/unityplugin/GhostCubePlugin/PluginSource/src/RenderingPlugin.cpp b/unityplugin/GhostCubePlugin/PluginSource/src/RenderingPlugin.cpp index 878c28e..7b71f16 100644 --- a/unityplugin/GhostCubePlugin/PluginSource/src/RenderingPlugin.cpp +++ b/unityplugin/GhostCubePlugin/PluginSource/src/RenderingPlugin.cpp @@ -72,6 +72,8 @@ extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginLoad(IUnit extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginUnload() { s_Graphics->UnregisterDeviceEventCallback(OnGraphicsDeviceEvent); + s_Graphics = nullptr; + s_UnityInterfaces = nullptr; } #if UNITY_WEBGL @@ -164,6 +166,8 @@ static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType ev s_CurrentAPI.reset(); } s_DeviceType = kUnityGfxRendererNull; + g_RenderTargetHandle = nullptr; + g_DepthBufferHandle = nullptr; } else if (s_CurrentAPI) { diff --git a/unityplugin/UnityEmulator/src/UnityGraphicsGLCoreES_Emulator.cpp b/unityplugin/UnityEmulator/src/UnityGraphicsGLCoreES_Emulator.cpp index 8edeb78..19744b0 100644 --- a/unityplugin/UnityEmulator/src/UnityGraphicsGLCoreES_Emulator.cpp +++ b/unityplugin/UnityEmulator/src/UnityGraphicsGLCoreES_Emulator.cpp @@ -11,8 +11,6 @@ std::unique_ptr UnityGraphicsGLCoreES_Emulator::m_Graphics UnityGraphicsGLCoreES_Emulator::UnityGraphicsGLCoreES_Emulator() { - VERIFY(!m_GraphicsImpl, "Another emulator has already been initialized"); - m_GraphicsImpl.reset( new UnityGraphicsGL_Impl ); //GeUnityInterfaces().RegisterInterface(IUnityGraphicsGLCoreES__GUID, GetUnityGraphicsAPIInterface()); } @@ -22,7 +20,9 @@ void UnityGraphicsGLCoreES_Emulator::InitGLContext(void *pNativeWndHandle, #endif int MajorVersion, int MinorVersion) { - m_GraphicsImpl->InitGLContext(pNativeWndHandle, + VERIFY(!m_GraphicsImpl, "Another emulator has already been initialized"); + m_GraphicsImpl.reset( new UnityGraphicsGL_Impl ); + m_GraphicsImpl->InitGLContext(pNativeWndHandle, #if PLATFORM_LINUX pDisplay, #endif -- cgit v1.2.3