private void CreateNewInstanceFromObject(GameObject sourceObject, int instanceIndex, Transform parentTransform, ref HAPI_Transform hapiTransform, string[] instancePrefixes, string instanceName) { GameObject newInstanceGO = null; if (HEU_EditorUtility.IsPrefabAsset(sourceObject)) { newInstanceGO = HEU_EditorUtility.InstantiatePrefab(sourceObject) as GameObject; newInstanceGO.transform.parent = parentTransform; } else { newInstanceGO = HEU_EditorUtility.InstantiateGameObject(sourceObject, parentTransform, false, false); } // To get the instance output name, we pass in the instance index. The actual name will be +1 from this. newInstanceGO.name = HEU_GeometryUtility.GetInstanceOutputName(instanceName, instancePrefixes, instanceIndex); newInstanceGO.isStatic = sourceObject.isStatic; Transform instanceTransform = newInstanceGO.transform; HEU_HAPIUtility.ApplyLocalTransfromFromHoudiniToUnityForInstance(ref hapiTransform, instanceTransform); // When cloning, the instanced part might have been made invisible, so re-enable renderer to have the cloned instance display it. HEU_GeneralUtility.SetGameObjectRenderVisiblity(newInstanceGO, true); HEU_GeneralUtility.SetGameObjectChildrenRenderVisibility(newInstanceGO, true); HEU_GeneralUtility.SetGameObjectColliderState(newInstanceGO, true); HEU_GeneralUtility.SetGameObjectChildrenColliderState(newInstanceGO, true); }
private void SetOutputVisiblity(HEU_LoadBufferBase buffer) { bool bVisibility = !buffer._bInstanced; if (HEU_GeneratedOutput.HasLODGroup(buffer._generatedOutput)) { foreach (HEU_GeneratedOutputData childOutput in buffer._generatedOutput._childOutputs) { HEU_GeneralUtility.SetGameObjectRenderVisiblity(childOutput._gameObject, bVisibility); HEU_GeneralUtility.SetGameObjectColliderState(childOutput._gameObject, bVisibility); } } else { HEU_GeneralUtility.SetGameObjectRenderVisiblity(buffer._generatedOutput._outputData._gameObject, bVisibility); HEU_GeneralUtility.SetGameObjectColliderState(buffer._generatedOutput._outputData._gameObject, bVisibility); } }