Exemple #1
0
		/// <summary>
		/// Callback when asset is deleted. Removes assset from Houdini session if in Editor.
		/// </summary>
		void OnDestroy()
		{
			// Destroy the asset from session or permanently. 
			// The following checks make sure to only delete if the scene is closing, 
			// or asset has been user deleted. 
			// Skips if its just transitioning into or out of play mode.
			// TODO RUNTIME: if/when we support runtime, should only do the Application.isEditor check if in Editor			
			if( _houdiniAsset != null && HEU_EditorUtility.IsEditorNotInPlayModeAndNotGoingToPlayMode())
			{
				// Delete mesh data if this asset hasn't been saved and it is a user invoked delete event.
				// Otherwise just remove from session.
				// TODO: for saved assets, we need to handle case where user deletes but does not save scene after
				if (!_houdiniAsset.IsAssetSavedInScene() && (Event.current != null && (Event.current.commandName.Equals("Delete") || Event.current.commandName.Equals("SoftDelete"))))
				{
					_houdiniAsset.DestroyGeneratedMeshData(bRegisterUndo: true);
				}

				_houdiniAsset.DeleteAllGeneratedData();

				// TODO: Handle Event.current.commandName.Equals("Duplicate")
			}
		}