private void destroyEverything() { // Unregister delegates properly GetTextureByOnRenderImage getTextureComponent = gameObject.GetComponent <GetTextureByOnRenderImage>(); if (getTextureComponent != null) { getTextureComponent.UnregisterDelegates(); } if (!EditorApplication.isPlayingOrWillChangePlaymode) { ComponentManager.DestroyManagedComponent <GetTextureByOnRenderImage>(gameObject, null); } NativePluginBridge.SYPHON.ShutdownGLCoreServer(); serverCreated = false; // Release the camera. var componentCamera = GetComponent <Camera>(); componentCamera.targetTexture = null; componentCamera.ResetAspect(); // Release temporary assets. if (_gammaMaterial) { DestroyImmediate(_gammaMaterial); } _gammaMaterial = null; }
private void DestroyManagedComponents(System.Action callback) { // TODO: switch from callback hell to async ComponentManager.DestroyManagedComponent <OpenGLCoreSyphon>(gameObject, () => { ComponentManager.DestroyManagedComponent <MetalSyphon>(gameObject, () => { ComponentManager.DestroyManagedComponent <NdiSender>(gameObject, () => { ComponentManager.DestroyManagedComponent <SpoutSender>(gameObject, () => { callback?.Invoke(); }); }); }); }); }
void OnDestroy() { // Don't bother to destroy managed components in case of game starting if (EditorApplication.isPlayingOrWillChangePlaymode) { return; } else { // OnDestroy method doesnt really like callbacks or passing the gameObject // So manual destroy of everything without callbacks ComponentManager.DestroyManagedComponent <OpenGLCoreSyphon>(gameObject, null); ComponentManager.DestroyManagedComponent <MetalSyphon>(gameObject, null); ComponentManager.DestroyManagedComponent <NdiSender>(gameObject, null); ComponentManager.DestroyManagedComponent <SpoutSender>(gameObject, null); } }
private void destroyEverything() { // Unregister delegates properly GetTextureByOnRenderImage getTextureComponent = gameObject.GetComponent <GetTextureByOnRenderImage>(); if (getTextureComponent != null) { getTextureComponent.UnregisterDelegates(); } // Don't bother to destroy managed components in case of game starting if (EditorApplication.isPlayingOrWillChangePlaymode) { ComponentManager.DestroyManagedComponent <GetTextureByOnRenderImage>(gameObject, null); } GraphicEventManager.IssuePluginEvent((int)SyphonGraphicEvent.StopServer, System.IntPtr.Zero); if (metalServerTexture != null) { if (Application.isPlaying) { DestroyImmediate(metalServerTexture); } else { DestroyImmediate(metalServerTexture); } } metalServerTexture = null; // Dispose the internal objects. if (metalBlitMaterial != null) { if (Application.isPlaying) { DestroyImmediate(metalBlitMaterial); } else { DestroyImmediate(metalBlitMaterial); } } }
private void destroyEverything() { // Make sure to unregister GetTextureByAsyncReadback getTextureComponent = gameObject.GetComponent <GetTextureByAsyncReadback>(); if (getTextureComponent != null) { getTextureComponent.UnregisterDelegates(); } // Don't bother to destroy managed components in case of game starting if (!EditorApplication.isPlayingOrWillChangePlaymode) { ComponentManager.DestroyManagedComponent <GetTextureByAsyncReadback>(gameObject, null); } if (ndiSender != IntPtr.Zero) { NativePluginBridge.NDI.DestroySender(ndiSender); ndiSender = IntPtr.Zero; } }
private void DestroyEverything() { if (spoutSender != System.IntPtr.Zero) { GraphicEventManager.IssuePluginEvent((int)SpoutGraphicEvent.Dispose, spoutSender); spoutSender = System.IntPtr.Zero; } // Unregister delegates properly GetTextureByOnRenderImage getTextureComponent = gameObject.GetComponent <GetTextureByOnRenderImage>(); if (getTextureComponent != null) { getTextureComponent.UnregisterDelegates(); } // Don't bother to destroy managed components in case of game starting if (!EditorApplication.isPlayingOrWillChangePlaymode) { ComponentManager.DestroyManagedComponent <GetTextureByOnRenderImage>(gameObject, null); } Utils.DestroyUnityObject(blitMaterial); Utils.DestroyUnityObject(sharedTexture); }