/// <summary> /// Destroy all generated data. /// </summary> public void DestroyAllData() { HEU_PartData.DestroyParts(_parts); if (_inputNode != null) { HEU_SessionBase session = null; if (ParentAsset != null) { ParentAsset.RemoveInputNode(_inputNode); session = ParentAsset.GetAssetSession(false); } _inputNode.DestroyAllData(session); HEU_GeneralUtility.DestroyImmediate(_inputNode); _inputNode = null; } if (_geoCurve != null) { if (ParentAsset != null) { ParentAsset.RemoveCurve(_geoCurve); } _geoCurve.DestroyAllData(); HEU_GeneralUtility.DestroyImmediate(_geoCurve); _geoCurve = null; } DestroyVolumeCache(); }
private void DestroyEditPointBoxMesh() { if(_editPointBoxMesh != null) { HEU_GeneralUtility.DestroyImmediate(_editPointBoxMesh); _editPointBoxMesh = null; } }
public static void DestroyNonAssetMaterial(Material material, bool bRegisterUndo) { // If the material is not part of the asset database then delete it if (material != null && !HEU_AssetDatabase.ContainsAsset(material)) { //Debug.LogFormat("Destroying non-asset material {0}", material.name); HEU_GeneralUtility.DestroyImmediate(material, false, bRegisterUndo: bRegisterUndo); } }
public void DestroyVolumeCache() { if (_volumeCache != null) { ParentAsset.RemoveVolumeCache(_volumeCache); HEU_GeneralUtility.DestroyImmediate(_volumeCache); _volumeCache = null; } }
public static void DestroyGeneratedOutputData(HEU_GeneratedOutputData generatedOutputData, bool bDontDeletePersistantResources) { // Generated Material references HEU_GeneratedOutput.ClearGeneratedMaterialReferences(generatedOutputData); // Components HEU_GeneralUtility.DestroyGeneratedMeshMaterialsLODGroups(generatedOutputData._gameObject, bDontDeletePersistantResources); // Gameobject HEU_GeneralUtility.DestroyImmediate(generatedOutputData._gameObject); }
/// <summary> /// Destroy all data. /// </summary> internal void DestroyAllData(bool bIsRebuild = false) { if (_geoNodes != null) { for (int i = 0; i < _geoNodes.Count; ++i) { _geoNodes[i].DestroyAllData(bIsRebuild); HEU_GeneralUtility.DestroyImmediate(_geoNodes[i]); } _geoNodes.Clear(); } }
/// <summary> /// Destroy all data. /// </summary> public void DestroyAllData() { if (_geoNodes != null) { for (int i = 0; i < _geoNodes.Count; ++i) { _geoNodes[i].DestroyAllData(); HEU_GeneralUtility.DestroyImmediate(_geoNodes[i]); } _geoNodes.Clear(); } }
public static void DestroyBakedGameObjectsWithEndName(List<GameObject> gameObjectsToDestroy, string endName) { int numLeft = gameObjectsToDestroy.Count; for (int i = 0; i < numLeft; ++i) { GameObject deleteGO = gameObjectsToDestroy[i]; if (string.IsNullOrEmpty(endName) || deleteGO.name.EndsWith(endName)) { gameObjectsToDestroy[i] = null; HEU_PartData.DestroyExistingGeneratedComponentsMeshData(deleteGO, true); HEU_GeneralUtility.DestroyImmediate(deleteGO); } } }
public static void ClearTOPNodeWorkItemResults(HEU_TOPNodeData topNode) { int numResults = topNode._workResults.Count; for (int i = 0; i < numResults; ++i) { DestroyWorkItemResultData(topNode, topNode._workResults[i]); } topNode._workResults.Clear(); if (topNode._workResultParentGO != null) { HEU_GeneralUtility.DestroyImmediate(topNode._workResultParentGO); } }
public static void DestroyGeneratedOutput(HEU_GeneratedOutput generatedOutput) { int numChildren = generatedOutput._childOutputs != null ? generatedOutput._childOutputs.Count : 0; for (int i = 0; i < numChildren; ++i) { if (generatedOutput._childOutputs[i] != null && generatedOutput._childOutputs[i]._gameObject != null) { HEU_GeneralUtility.DestroyImmediate(generatedOutput._childOutputs[i]._gameObject); } } generatedOutput._childOutputs.Clear(); HEU_GeneralUtility.DestroyImmediate(generatedOutput._outputData._gameObject); generatedOutput._outputData._gameObject = null; generatedOutput._outputData._renderMaterials = null; }
public void DestroyVolumeCache() { if (_volumeCaches != null) { int numCaches = _volumeCaches.Count; for (int i = 0; i < numCaches; ++i) { if (_volumeCaches[i] != null) { ParentAsset.RemoveVolumeCache(_volumeCaches[i]); HEU_GeneralUtility.DestroyImmediate(_volumeCaches[i]); _volumeCaches[i] = null; } } _volumeCaches = null; } }
public static void DestroyLODGroup(GameObject targetGO, bool bDontDeletePersistantResources) { LODGroup lodGroup = targetGO.GetComponent<LODGroup>(); if (lodGroup != null) { List<GameObject> childrenGO = GetChildGameObjects(targetGO); if (childrenGO != null) { for (int i = 0; i < childrenGO.Count; ++i) { if (childrenGO[i].gameObject != targetGO) { DestroyGeneratedMeshMaterialsLODGroups(childrenGO[i], bDontDeletePersistantResources); HEU_GeneralUtility.DestroyImmediate(childrenGO[i]); } } } DestroyImmediate(lodGroup); } }
private static void DestroyWorkItemResultData(HEU_TOPNodeData topNode, HEU_TOPWorkResult result) { if (result._generatedGOs != null) { int numGOs = result._generatedGOs.Count; for (int i = 0; i < numGOs; ++i) { HEU_GeoSync geoSync = result._generatedGOs[i].GetComponent<HEU_GeoSync>(); if (geoSync != null) { geoSync.Unload(); } //Debug.LogFormat("Destroy result: " + result._generatedGOs[i].name); HEU_GeneralUtility.DestroyImmediate(result._generatedGOs[i]); result._generatedGOs[i] = null; } result._generatedGOs.Clear(); } }
/// <summary> /// Removes all Houdini Engine data from this asset. /// Leaves this gameobject and its children including Unity-specific /// components like geometry, materials, etc. /// </summary> public void RemoveHoudiniEngineAssetData() { HEU_EditorUtility.UndoRecordObject(this, "Clear References"); // TODO: try Undo.RegisterCompleteObjectUndo or RegisterFullObjectHierarchyUndo if (_houdiniAsset != null) { // We'll do a simple DestroyImmediate. // No need to destroy the object, geo nodes, and parts // since Unity's GC will handle them. GameObject tempGO = _houdiniAsset.gameObject; _houdiniAsset = null; HEU_GeneralUtility.DestroyImmediate(tempGO, bRegisterUndo:true); } ClearHoudiniEngineReferences(); DestroyRootComponent(this); HEU_EditorUtility.UndoCollapseCurrentGroup(); }
/// <summary> /// Destroy any terrain components and data on given gameObject. /// </summary> /// <param name="gameObject"></param> public static void DestroyTerrainComponents(GameObject gameObject) { if(gameObject == null) { return; } Terrain terrain = gameObject.GetComponent<Terrain>(); if(terrain != null) { if (terrain.terrainData != null) { HEU_AssetDatabase.DeleteAsset(terrain.terrainData); HEU_GeneralUtility.DestroyImmediate(terrain.terrainData, true); terrain.terrainData = null; } DestroyImmediate(terrain); } DestroyComponent<TerrainCollider>(gameObject); }
/// <summary> /// Destroys the Collider components that were generated and stored in outputData. /// Specially handles MeshColliders for the contained mesh. /// </summary> /// <param name="outputData">Contains the generated list of Colliders</param> public static void DestroyAllGeneratedColliders(HEU_GeneratedOutputData outputData) { if (outputData._colliders != null) { int numExisting = outputData._colliders.Count; for (int i = 0; i < numExisting; ++i) { if (outputData._colliders[i] != null) { if (outputData._colliders[i].GetType() == typeof(MeshCollider)) { HEU_GeneralUtility.DestroyMeshCollider(outputData._colliders[i] as MeshCollider, true); } else { HEU_GeneralUtility.DestroyImmediate(outputData._colliders[i], true); } } } outputData._colliders.Clear(); } }
private void GenerateInstancesFromAssetPaths(HEU_LoadBufferInstancer instancerBuffer, Transform instanceRootTransform) { // For single asset, this is set when its impoted GameObject singleAssetGO = null; // For multi assets, keep track of loaded objects so we only need to load once for each object Dictionary<string, GameObject> loadedUnityObjectMap = new Dictionary<string, GameObject>(); // Temporary empty gameobject in case the specified Unity asset is not found GameObject tempGO = null; if (instancerBuffer._assetPaths.Length == 1) { // Single asset path if (!string.IsNullOrEmpty(instancerBuffer._assetPaths[0])) { HEU_AssetDatabase.ImportAsset(instancerBuffer._assetPaths[0], HEU_AssetDatabase.HEU_ImportAssetOptions.Default); singleAssetGO = HEU_AssetDatabase.LoadAssetAtPath(instancerBuffer._assetPaths[0], typeof(GameObject)) as GameObject; } if (singleAssetGO == null) { Debug.LogErrorFormat("Asset at path {0} not found. Unable to create instances for {1}.", instancerBuffer._assetPaths[0], instancerBuffer._name); return; } } int numInstancesCreated = 0; int numInstances = instancerBuffer._instanceTransforms.Length; for (int i = 0; i < numInstances; ++i) { // Reset to the single asset for each instance allows which is null if using multi asset // therefore forcing the instance asset to be found GameObject unitySrcGO = singleAssetGO; if (unitySrcGO == null) { // If not using single asset, then there must be an asset path for each instance if (string.IsNullOrEmpty(instancerBuffer._assetPaths[i])) { continue; } if (!loadedUnityObjectMap.TryGetValue(instancerBuffer._assetPaths[i], out unitySrcGO)) { // Try loading it //HEU_AssetDatabase.ImportAsset(instancerBuffer._assetPaths[i], HEU_AssetDatabase.HEU_ImportAssetOptions.Default); unitySrcGO = HEU_AssetDatabase.LoadAssetAtPath(instancerBuffer._assetPaths[i], typeof(GameObject)) as GameObject; if (unitySrcGO == null) { Debug.LogErrorFormat("Unable to load asset at {0} for instancing!", instancerBuffer._assetPaths[i]); // Even though the source Unity object is not found, we should create an object instance info to track it if (tempGO == null) { tempGO = new GameObject(); } unitySrcGO = tempGO; } // Adding to map even if not found so we don't flood the log with the same error message loadedUnityObjectMap.Add(instancerBuffer._assetPaths[i], unitySrcGO); } } CreateNewInstanceFromObject(unitySrcGO, (numInstancesCreated + 1), instanceRootTransform, ref instancerBuffer._instanceTransforms[i], instancerBuffer._instancePrefixes, instancerBuffer._name); numInstancesCreated++; } if (tempGO != null) { HEU_GeneralUtility.DestroyImmediate(tempGO, bRegisterUndo: false); } }
public static void DestroyRootComponent(HEU_HoudiniAssetRoot assetRoot) { HEU_GeneralUtility.DestroyImmediate(assetRoot, bRegisterUndo:true); }
/// <summary> /// Destroy the given game object, including its internal mesh and any shared materials. /// </summary> /// <param name="gameObect">Game object to destroy</param> public static void DestroyGameObject(GameObject gameObect, bool bRegisterUndo = false) // TODO: remove default bRegisterUndo arg { HEU_GeneralUtility.DestroyImmediate(gameObect, bAllowDestroyingAssets: true, bRegisterUndo: bRegisterUndo); }