private bool DrawDetailsEnvironment() { bool bChanged = false; { string oldPath = HEU_PluginSettings.HoudiniEngineEnvFilePath; string fileExt = "env"; using (new EditorGUILayout.HorizontalScope()) { string newPath = EditorGUILayout.DelayedTextField(new GUIContent("Houdini Env File", "Assets/ relative path to unity_houdini.env file containing environment paths"), oldPath); GUIStyle buttonStyle = HEU_EditorUI.GetNewButtonStyle_MarginPadding(0, 0); if (GUILayout.Button("...", buttonStyle, GUILayout.Width(30), GUILayout.Height(18))) { string openFilePath = UnityEditor.EditorUtility.OpenFilePanel("Select Houdini Env file", newPath, fileExt); if (!string.IsNullOrEmpty(openFilePath)) { newPath = openFilePath; } } if (!newPath.Equals(oldPath)) { HEU_PluginSettings.HoudiniEngineEnvFilePath = newPath; bChanged = true; } GUILayout.Space(5); if (GUILayout.Button(_refreshContent, buttonStyle, GUILayout.Width(40), GUILayout.Height(18))) { HEU_PluginStorage.Instance.LoadAssetEnvironmentPaths(); } } } HEU_EditorUI.DrawSeparator(); Dictionary<string, string> envMap = HEU_PluginStorage.Instance.GetEnvironmentPathMap(); if (envMap == null) { HEU_EditorUI.DrawHeadingLabel("No environment mapped paths found!"); } else { HEU_EditorUI.DrawHeadingLabel("Enviornment Mapped Paths:"); EditorGUILayout.LabelField("The following mappings will be applied to assets loaded from outside the Assets/ folder."); foreach (KeyValuePair<string, string> pair in envMap) { EditorGUILayout.LabelField(string.Format("{0} = {1}", pair.Key, pair.Value)); } HEU_EditorUI.DrawSeparator(); } return bChanged; }
/// <summary> /// Displays a dropdown list of TOP network names, and shows the selected TOP network info /// </summary> private void DrawSelectedTOPNetwork() { HEU_EditorUI.DrawHeadingLabel("Internal TOP Networks"); int numTopNodes = _assetLink._topNetworkNames.Length; if (numTopNodes > 0) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.PrefixLabel(_topNetworkChooseLabel); int numTOPs = _assetLink._topNetworkNames.Length; int selectedIndex = Mathf.Clamp(_assetLink.SelectedTOPNetwork, 0, numTopNodes - 1); int newSelectedIndex = EditorGUILayout.Popup(selectedIndex, _assetLink._topNetworkNames); if (newSelectedIndex != selectedIndex) { _assetLink.SelectTOPNetwork(newSelectedIndex); } } EditorGUILayout.Space(); using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(_buttonDirtyAllContent, GUILayout.MaxHeight(_largButtonHeight))) { _assetLink.DirtyAll(); } if (GUILayout.Button(_buttonCookAllContent, GUILayout.MaxHeight(_largButtonHeight))) { _assetLink.CookOutput(); } } EditorGUILayout.Space(); using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(_buttonPauseCookContent)) { _assetLink.PauseCook(); } if (GUILayout.Button(_buttonCancelCookContent)) { _assetLink.CancelCook(); } } } else { EditorGUILayout.PrefixLabel(_topNetworkNoneLabel); } }
private void DrawCurvesSection(HEU_HoudiniAsset asset, SerializedObject assetObject) { if (asset.GetEditableCurveCount() <= 0) { return; } GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.fontSize = 11; buttonStyle.alignment = TextAnchor.MiddleCenter; buttonStyle.fixedHeight = 24; buttonStyle.margin.left = 34; HEU_EditorUI.BeginSection(); { SerializedProperty showCurvesProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_showCurvesSection"); if (showCurvesProperty != null) { showCurvesProperty.boolValue = HEU_EditorUI.DrawFoldOut(showCurvesProperty.boolValue, "CURVES"); if (showCurvesProperty.boolValue) { SerializedProperty curveEditorProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveEditorEnabled"); if (curveEditorProperty != null) { EditorGUILayout.PropertyField(curveEditorProperty); } HEU_EditorUI.DrawHeadingLabel("Collision Settings"); EditorGUI.indentLevel++; string projectLabel = "Project Curves To "; List<HEU_Curve> curves = asset.GetCurves(); SerializedProperty curveCollisionProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveDrawCollision"); if (curveCollisionProperty != null) { EditorGUILayout.PropertyField(curveCollisionProperty, new GUIContent("Collision Type")); if (curveCollisionProperty.enumValueIndex == (int)HEU_Curve.CurveDrawCollision.COLLIDERS) { HEU_EditorUtility.EditorDrawSerializedProperty(assetObject, "_curveDrawColliders", label: "Colliders"); projectLabel += "Colliders"; } else if (curveCollisionProperty.enumValueIndex == (int)HEU_Curve.CurveDrawCollision.LAYERMASK) { HEU_EditorUtility.EditorDrawSerializedProperty(assetObject, "_curveDrawLayerMask", label: "Layer Mask"); projectLabel += "Layer"; } HEU_EditorUI.DrawSeparator(); EditorGUI.indentLevel--; HEU_EditorUI.DrawHeadingLabel("Projection Settings"); EditorGUI.indentLevel++; HEU_EditorUtility.EditorDrawSerializedProperty(assetObject, "_curveProjectDirection", label: "Project Direction", tooltip: "The ray cast direction for projecting the curve points."); HEU_EditorUtility.EditorDrawFloatProperty(assetObject, "_curveProjectMaxDistance", label: "Project Max Distance", tooltip: "The maximum ray cast distance for projecting the curve points."); _projectCurvePointsButton.text = projectLabel; if (GUILayout.Button(_projectCurvePointsButton, buttonStyle, GUILayout.MaxWidth(180))) { SerializedProperty projectDirProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveProjectDirection"); SerializedProperty maxDistanceProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveProjectMaxDistance"); Vector3 projectDir = projectDirProperty != null ? projectDirProperty.vector3Value : Vector3.down; float maxDistance = maxDistanceProperty != null ? maxDistanceProperty.floatValue : 0; for (int i = 0; i < curves.Count; ++i) { curves[i].ProjectToColliders(asset, projectDir, maxDistance); } } } EditorGUI.indentLevel--; HEU_EditorUI.DrawSeparator(); for (int i = 0; i < curves.Count; ++i) { if (curves[i].Parameters != null) { DrawParameters(curves[i].Parameters, ref _curveParameterEditor); } } } } } HEU_EditorUI.EndSection(); HEU_EditorUI.DrawSeparator(); }
/// <summary> /// Draw the UI for the given input node /// </summary> /// <param name="inputNode"></param> public static void EditorDrawInputNode(HEU_InputNode inputNode) { int plusButtonWidth = 20; const string inputTypeTooltip = @"Input type of the object. The HDA type can accept any object with a HEU_HoudiniAssetRoot component. (Including curves) The UNITY_MESH type can accept any GameObject (Including Terrain, HEU_BoundingVolumes)."; GUIContent inputTypeLabel = new GUIContent("Input Type", inputTypeTooltip); GUIContent translateLabel = new GUIContent(" Translate"); GUIContent rotateLabel = new GUIContent(" Rotate"); GUIContent scaleLabel = new GUIContent(" Scale"); PopulateCache(inputNode); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); string labelName = inputNode.LabelName; if (!string.IsNullOrEmpty(labelName)) { EditorGUILayout.LabelField(labelName); } EditorGUI.indentLevel++; HEU_InputNode.InputObjectType inputObjectType = (HEU_InputNode.InputObjectType)inputNode._uiCache._inputObjectTypeProperty.intValue; HEU_InputNode.InputObjectType userSelectedInputObjectType = (HEU_InputNode.InputObjectType)EditorGUILayout.EnumPopup(inputTypeLabel, inputObjectType); if (userSelectedInputObjectType != inputObjectType) { SerializedProperty pendingInputObjectTypeProperty = HEU_EditorUtility.GetSerializedProperty(inputNode._uiCache._inputNodeSerializedObject, "_pendingInputObjectType"); if (pendingInputObjectTypeProperty != null) { pendingInputObjectTypeProperty.intValue = (int)userSelectedInputObjectType; } } else { EditorGUILayout.PropertyField(inputNode._uiCache._keepWorldTransformProperty); EditorGUILayout.PropertyField(inputNode._uiCache._packBeforeMergeProperty); if (HEU_InputNode.GetInternalObjectType(inputObjectType) == HEU_InputNode.InternalObjectType.HDA) { SerializedProperty inputAssetsProperty = inputNode._uiCache._inputAssetsProperty; if (inputAssetsProperty != null) { int inputCount = inputAssetsProperty.arraySize; bool bSkipElements = false; HEU_EditorUI.DrawSeparator(); EditorGUILayout.LabelField(string.Format("{0} input objects", inputCount)); using (var hs1 = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("Add Slot")) { inputAssetsProperty.InsertArrayElementAtIndex(inputCount); bSkipElements = true; } if (GUILayout.Button("Clear")) { inputAssetsProperty.ClearArray(); bSkipElements = true; } } DrawSelectionWindow(HEU_InputNode.InputObjectType.HDA, inputNode); if (!bSkipElements) { using (var vs1 = new EditorGUILayout.VerticalScope()) { for (int i = 0; i < inputCount; ++i) { using (var hs2 = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Input " + (i + 1)); if (GUILayout.Button("+", GUILayout.Width(plusButtonWidth))) { inputAssetsProperty.InsertArrayElementAtIndex(i); break; } if (GUILayout.Button("-", GUILayout.Width(plusButtonWidth))) { inputAssetsProperty.DeleteArrayElementAtIndex(i); break; } } EditorGUI.indentLevel++; using (var vs4 = new EditorGUILayout.VerticalScope()) { if (i < inputNode._uiCache._inputAssetCache.Count) { HEU_InputNodeUICache.HEU_InputAssetUICache assetCache = inputNode._uiCache._inputAssetCache[i]; UnityEngine.Object setObject = EditorGUILayout.ObjectField(assetCache._gameObjectProperty.objectReferenceValue, typeof(HEU_HoudiniAssetRoot), true); if (setObject != assetCache._gameObjectProperty.objectReferenceValue) { GameObject inputGO = setObject != null ? (setObject as HEU_HoudiniAssetRoot).gameObject : null; // Check not setting same asset as self if (inputGO == null || inputGO != inputNode.ParentAsset.RootGameObject) { assetCache._gameObjectProperty.objectReferenceValue = inputGO; } } } } EditorGUI.indentLevel--; } } } } } else if (HEU_InputNode.GetInternalObjectType(inputObjectType) == HEU_InputNode.InternalObjectType.UNITY_MESH) { SerializedProperty inputObjectsProperty = inputNode._uiCache._inputObjectsProperty; if (inputObjectsProperty != null) { bool bSkipElements = false; HEU_EditorUI.DrawSeparator(); EditorGUILayout.LabelField(string.Format("{0} input objects", inputObjectsProperty.arraySize)); using (var hs1 = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("Add Slot")) { inputObjectsProperty.arraySize++; FixUpScaleProperty(inputObjectsProperty, inputObjectsProperty.arraySize - 1); bSkipElements = true; } if (GUILayout.Button("Clear")) { inputObjectsProperty.ClearArray(); bSkipElements = true; } } DrawSelectionWindow(inputObjectType, inputNode); if (inputObjectType == HEU_InputNode.InputObjectType.UNITY_MESH && inputNode.MeshSettings != null) { HEU_EditorUI.DrawHeadingLabel("Mesh settings"); EditorGUI.indentLevel++; { UnityEditor.SerializedProperty exportCollidersProperty = inputNode._uiCache._meshSettingsProperty.FindPropertyRelative("_exportColliders"); exportCollidersProperty.boolValue = HEU_EditorUI.DrawToggleLeft(exportCollidersProperty.boolValue, _meshExportCollidersContent.text, _meshExportCollidersContent.tooltip); } EditorGUI.indentLevel--; } else if (inputObjectType == HEU_InputNode.InputObjectType.TILEMAP && inputNode.TilemapSettings != null) { HEU_EditorUI.DrawHeadingLabel("Tilemap settings"); EditorGUI.indentLevel++; { UnityEditor.SerializedProperty createGroupsForTilesProperty = inputNode._uiCache._tilemapSettingsProperty.FindPropertyRelative("_createGroupsForTiles"); UnityEditor.SerializedProperty exportUnusedTilesProperty = inputNode._uiCache._tilemapSettingsProperty.FindPropertyRelative("_exportUnusedTiles"); UnityEditor.SerializedProperty applyTileColorProperty = inputNode._uiCache._tilemapSettingsProperty.FindPropertyRelative("_applyTileColor"); UnityEditor.SerializedProperty applyTilemapOrientationProperty = inputNode._uiCache._tilemapSettingsProperty.FindPropertyRelative("_applyTilemapOrientation"); createGroupsForTilesProperty.boolValue = HEU_EditorUI.DrawToggleLeft(createGroupsForTilesProperty.boolValue, _tilemapCreateGroupsContent.text, _tilemapCreateGroupsContent.tooltip); exportUnusedTilesProperty.boolValue = HEU_EditorUI.DrawToggleLeft(exportUnusedTilesProperty.boolValue, _tilemapExportUnusedTilesContent.text, _tilemapExportUnusedTilesContent.tooltip); applyTileColorProperty.boolValue = HEU_EditorUI.DrawToggleLeft(applyTileColorProperty.boolValue, _tilemapColorContent.text, _tilemapColorContent.tooltip); applyTilemapOrientationProperty.boolValue = HEU_EditorUI.DrawToggleLeft(applyTilemapOrientationProperty.boolValue, _tilemapOrientationContent.text, _tilemapOrientationContent.tooltip); } EditorGUI.indentLevel--; } if (!bSkipElements) { using (var vs1 = new EditorGUILayout.VerticalScope()) { int inputCount = inputObjectsProperty.arraySize; for (int i = 0; i < inputCount; ++i) { using (var hs2 = new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Input " + (i + 1)); { if (GUILayout.Button("+", GUILayout.Width(plusButtonWidth))) { inputObjectsProperty.InsertArrayElementAtIndex(i); FixUpScaleProperty(inputObjectsProperty, i); break; } if (GUILayout.Button("-", GUILayout.Width(plusButtonWidth))) { inputObjectsProperty.DeleteArrayElementAtIndex(i); break; } } } EditorGUI.indentLevel++; using (var vs4 = new EditorGUILayout.VerticalScope()) { if (i < inputNode._uiCache._inputObjectCache.Count && i < inputNode.InputObjects.Count) { HEU_InputNodeUICache.HEU_InputObjectUICache objectCache = inputNode._uiCache._inputObjectCache[i]; GameObject oldObject = inputNode.InputObjects[i]._gameObject; GameObject newObject = null; switch (inputObjectType) { case HEU_InputNode.InputObjectType.TERRAIN: inputNode.InputObjects[i]._terrainReference = EditorGUILayout.ObjectField(inputNode.InputObjects[i]._terrainReference, typeof(Terrain), true) as Terrain; if (inputNode.InputObjects[i]._terrainReference != null) { newObject = inputNode.InputObjects[i]._terrainReference.gameObject; } break; case HEU_InputNode.InputObjectType.BOUNDING_BOX: inputNode.InputObjects[i]._boundingVolumeReference = EditorGUILayout.ObjectField(inputNode.InputObjects[i]._boundingVolumeReference, typeof(HEU_BoundingVolume), true) as HEU_BoundingVolume; if (inputNode.InputObjects[i]._boundingVolumeReference != null) { newObject = inputNode.InputObjects[i]._boundingVolumeReference.gameObject; } break; case HEU_InputNode.InputObjectType.TILEMAP: inputNode.InputObjects[i]._tilemapReference = EditorGUILayout.ObjectField(inputNode.InputObjects[i]._tilemapReference, typeof(Tilemap), true) as Tilemap; if (inputNode.InputObjects[i]._tilemapReference != null) { newObject = inputNode.InputObjects[i]._tilemapReference.gameObject; } break; default: newObject = EditorGUILayout.ObjectField(inputNode.InputObjects[i]._gameObject, typeof(GameObject), true) as GameObject; break; } if (oldObject != newObject) { Undo.RecordObject(inputNode, "GameObject Assign"); inputNode.InputObjects[i]._gameObject = newObject; // Set the reference to avoid strange bugs when switching input type modes inputNode.InputObjects[i].SetReferencesFromGameObject(); EditorUtility.SetDirty(inputNode); } using (new EditorGUI.DisabledScope(!inputNode._uiCache._keepWorldTransformProperty.boolValue)) { objectCache._transformOffsetProperty.boolValue = HEU_EditorUI.DrawToggleLeft(objectCache._transformOffsetProperty.boolValue, "Transform Offset"); if (objectCache._transformOffsetProperty.boolValue) { objectCache._translateProperty.vector3Value = EditorGUILayout.Vector3Field(translateLabel, objectCache._translateProperty.vector3Value); objectCache._rotateProperty.vector3Value = EditorGUILayout.Vector3Field(rotateLabel, objectCache._rotateProperty.vector3Value); objectCache._scaleProperty.vector3Value = EditorGUILayout.Vector3Field(scaleLabel, objectCache._scaleProperty.vector3Value); } } } } EditorGUI.indentLevel--; } } } } } } EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); if (EditorGUI.EndChangeCheck()) { inputNode._uiCache._inputNodeSerializedObject.ApplyModifiedProperties(); // When cooking, this will force input data to be uploaded inputNode.RequiresUpload = true; inputNode.ClearUICache(); } }
private void DrawViewModeInfo() { float uiWidth = _editorUIRect.width * _infoPanelSettingsWidth; char upArrow = '\u25B2'; char downArrow = '\u25BC'; float arrayWidth = 25; GUIStyle editNodesBoxStyle = new GUIStyle(GUI.skin.textArea); GUIStyle entryStyle = new GUIStyle(GUI.skin.box); using (var hs = new EditorGUILayout.HorizontalScope()) { using (var vs = new EditorGUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.MaxWidth(uiWidth))) { EditorGUILayout.LabelField("This tool allows to Paint & Edit POINT attributes of Editable nodes."); EditorGUILayout.LabelField("Painting vertex colors is directly supported if a Paint SOP is made editable."); EditorGUILayout.LabelField("Use node list on the right to re-order editable nodes by order of edit operations."); EditorGUILayout.LabelField("Nodes that take inputs from other editable nodes should come after them in the list."); } using (var vs = new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { // Draw each editable node (attribute store), along with buttons to re-order the node. using (var hs2 = new EditorGUILayout.HorizontalScope()) { HEU_EditorUI.DrawHeadingLabel("EDIT ORDER"); SerializedProperty cookUpstreamSerializedProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_alwaysCookUpstream"); if (cookUpstreamSerializedProperty != null) { EditorGUILayout.PropertyField(cookUpstreamSerializedProperty, new GUIContent("Always Cook Inputs", "For multiple editable nodes, this forces each one to always cook upstream inputs first before applying edits."), GUILayout.Width(168)); } } using (var vs2 = new EditorGUILayout.VerticalScope(editNodesBoxStyle)) { using (var scrollScope = new EditorGUILayout.ScrollViewScope(_editNodeScrollPos)) { _editNodeScrollPos = scrollScope.scrollPosition; int numStores = _attributesStores.Count; for (int i = 0; i < numStores; ++i) { using (var hsi = new EditorGUILayout.HorizontalScope(entryStyle)) { if (GUILayout.Button(upArrow.ToString(), GUILayout.MaxWidth(arrayWidth))) { if (i > 0) { _asset.ReorderAttributeStore(i, i - 1); } } if (GUILayout.Button(downArrow.ToString(), GUILayout.MaxWidth(arrayWidth))) { if (i < numStores - 1) { _asset.ReorderAttributeStore(i, i + 1); } } EditorGUILayout.LabelField(_attributesStores[i].GeoName); } } } } } } }