Esempio n. 1
0
        /// <summary>
        /// Destroy the shared memory space and temporary scene objects
        /// </summary>
        public void Teardown()
        {
            if (!IsRunning)
            {
                return;
            }

            IsRunning = false;

            AssemblyReloadEvents.beforeAssemblyReload -= OnBeforeAssemblyReload;
            EditorApplication.update        -= OnEditorUpdate;
            SceneManager.activeSceneChanged -= OnSceneUnloaded;
            EditorSceneManager.activeSceneChangedInEditMode -= OnSceneUnloaded;

            // Notify Blender if we're shutting down from the Unity side
            if (IsConnected)
            {
                messages.WriteDisconnect();
                OnDisconnectFromBlender();
            }
            else
            {
                // Still clear if we're not connected - we might've torn down
                // the connection uncleanly and have some persisted data to clean up.
                Clear();
            }

            // Dispose shared memory
            messages?.Dispose();
            messages = null;

            pixelsProducer?.Dispose();
            pixelsProducer = null;
        }
Esempio n. 2
0
        /// <summary>
        /// Destroy the shared memory space and temporary scene objects
        /// </summary>
        public void Teardown()
        {
            AssemblyReloadEvents.beforeAssemblyReload -= OnBeforeAssemblyReload;
            EditorApplication.update -= OnEditorUpdate;

            // Notify Blender if we're shutting down from the Unity side
            if (IsConnected)
            {
                messages.WriteDisconnect();
                OnDisconnectFromBlender();
            }
            else
            {
                // Still clear if we're not connected - we might've torn down
                // the connection uncleanly and have some persisted data to clean up.
                Clear();
            }

            IsSetup = false;

            Debug.Log("Tearing down shared memory space");

            // Dispose shared memory
            messages?.Dispose();
            messages = null;

            pixelsProducer?.Dispose();
            pixelsProducer = null;
        }
Esempio n. 3
0
        /// <summary>
        /// Dispose shared memory and shutdown communication to Unity.
        ///
        /// Anything from Unity's side would get cleaned up.
        /// </summary>
        public void Disconnect()
        {
            messages?.WriteDisconnect();

            IsConnectedToUnity        = false;
            IsConnectedToSharedMemory = false;

            messages?.Dispose();
            messages = null;

            pixelsConsumer?.Dispose();
            pixelsConsumer = null;
        }