private void CreateNewInstanceFromObject(GameObject assetSourceGO, int instanceIndex, Transform parentTransform, ref HAPI_Transform hapiTransform, string[] instancePrefixes, string instanceName, GameObject collisionSourceGO) { GameObject newInstanceGO = null; if (HEU_EditorUtility.IsPrefabAsset(assetSourceGO)) { newInstanceGO = HEU_EditorUtility.InstantiatePrefab(assetSourceGO) as GameObject; newInstanceGO.transform.parent = parentTransform; } else { newInstanceGO = HEU_EditorUtility.InstantiateGameObject(assetSourceGO, parentTransform, false, false); } if (collisionSourceGO != null) { HEU_GeneralUtility.ReplaceColliderMeshFromMeshFilter(newInstanceGO, collisionSourceGO); } // 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 = assetSourceGO.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); }