/// <summary> /// Callback when asset is deleted. Removes assset from Houdini session if in Editor. /// </summary> void OnDestroy() { if (_houdiniAsset != null && _houdiniAsset.PauseCooking == true) { return; } // 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.DeleteAssetCacheData(bRegisterUndo: true); } if (Event.current != null && Event.current.commandName.Equals("SoftDelete")) { // Don't delete data so that you can undo! _houdiniAsset.SetSoftDeleted(); } else { _houdiniAsset.DeleteAllGeneratedData(bIsRebuild: false); } } }