private void SetupGameObjectAndTransform(HEU_PartData partData, HEU_HoudiniAsset parentAsset) { // Set a valid gameobject for this part if (partData.OutputGameObject == null) { partData.SetGameObject(new GameObject()); } // The parent is either the asset root, OR if this is instanced and not visible, then the HDA data is the parent // The parent transform is either the asset root (for a display node), // or the HDA_Data gameobject (for instanced, not visible, intermediate, editable non-display nodes) Transform partTransform = partData.OutputGameObject.transform; if (partData.IsPartInstanced() || (_containerObjectNode.IsInstanced() && !_containerObjectNode.IsVisible()) || partData.IsPartCurve() || (IsIntermediateOrEditable() && !Displayable)) { partTransform.parent = parentAsset.OwnerGameObject.transform; } else { partTransform.parent = parentAsset.RootGameObject.transform; } partData.OutputGameObject.isStatic = partTransform.parent.gameObject.isStatic; // Reset to origin partTransform.localPosition = Vector3.zero; partTransform.localRotation = Quaternion.identity; partTransform.localScale = Vector3.one; }
public void GetPartsByOutputType(List <HEU_PartData> meshParts, List <HEU_PartData> volumeParts) { int numParts = _parts.Count; for (int i = 0; i < numParts; ++i) { HEU_PartData part = _parts[i]; if (part.IsPartMesh() || part.IsPartCurve()) { meshParts.Add(part); } else if (part.IsPartVolume()) { volumeParts.Add(part); } } }
private void SetupGameObjectAndTransform(HEU_PartData partData, HEU_HoudiniAsset parentAsset) { // Checking for nulls for undo safety if (partData == null || parentAsset == null || parentAsset.OwnerGameObject == null || parentAsset.RootGameObject == null) { return; } // Set a valid gameobject for this part if (partData.OutputGameObject == null) { partData.SetGameObject(HEU_GeneralUtility.CreateNewGameObject()); } // The parent is either the asset root, OR if this is instanced and not visible, then the HDA data is the parent // The parent transform is either the asset root (for a display node), // or the HDA_Data gameobject (for instanced, not visible, intermediate, editable non-display nodes) Transform partTransform = partData.OutputGameObject.transform; if (partData.IsPartInstanced() || (_containerObjectNode.IsInstanced() && !_containerObjectNode.IsVisible()) || partData.IsPartCurve() || (IsIntermediateOrEditable() && !Displayable)) { partTransform.parent = parentAsset.OwnerGameObject.transform; } else { partTransform.parent = parentAsset.RootGameObject.transform; } HEU_GeneralUtility.CopyFlags(partTransform.parent.gameObject, partData.OutputGameObject, true); // Reset to origin partTransform.localPosition = Vector3.zero; partTransform.localRotation = Quaternion.identity; partTransform.localScale = Vector3.one; // Destroy the children generated from ComposeNChildren HEU_GeneralUtility.DestroyAutoGeneratedChildren(partData.OutputGameObject); }