private void DrawName() { EditorGUILayout.LabelField("Name", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); { string[] nodes = GetValidReplaceNodes(FTNode.category); int curValIdx = Array.FindIndex(nodes, (x) => { return(x.Contains(FTNode.name)); }); int selValIdx = EditorGUILayout.Popup(FTNode.name, toReplaceNameIdx != -1 ? toReplaceNameIdx : curValIdx, nodes); toReplaceNameIdx = selValIdx != curValIdx ? selValIdx : -1; EditorGUI.BeginDisabledGroup(toReplaceNameIdx == -1); if (GUILayout.Button("Replace")) { if (EditorUtility.DisplayDialog("WARNING", "Are you sure to replace?", "YES", "NO")) { FTNode.name = nodes[toReplaceNameIdx]; var nodeCfg = BTEditorDefine.GetFTNodeCfg(FTNode.name); FTNode.InitWithFTNodeCfg(nodeCfg); } toReplaceNameIdx = -1; EditorGUIUtility.ExitGUI(); } EditorGUI.EndDisabledGroup(); } EditorGUILayout.EndHorizontal(); }
private void AddFTNode(string nodeName, Vector2 gpos) { var nodeCfg = BTEditorDefine.GetFTNodeCfg(nodeName); if (nodeCfg == null) { Debug.LogError("Failed to AddFTNode because cant find FTNodeCfg > " + nodeName); return; } FTNode node = (FTNode)CreateNode(typeof(FTNode), gpos); NodeEditorWindow.current.AutoConnect(node); node.InitWhenAddFromGraph(nodeCfg); FocusOnFTNode(node); }
private void DrawProperties() { FTNodeCfg nodeCfg = BTEditorDefine.GetFTNodeCfg(FTNode.name); for (int i = 0; i < FTNode.properties.Count; ++i) { FTNodeProperty prop = FTNode.properties[i]; bool isDefaultProperty = IsDefaultProperty(nodeCfg, prop.Key); FTNodePropertyCfg propCfg = BTEditorDefine.GetFTNodePropertyCfg(prop.Key, FTNode.category); EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(isDefaultProperty); { prop.Key = EditorGUILayout.TextField(prop.Key); int lastSelectTypeIndex = Array.IndexOf(FTNodeProperty.SupportTypes, prop.ValueType); int selectTypeIndex = EditorGUILayout.Popup(lastSelectTypeIndex, FTNodeProperty.SupportTypes); prop.ValueType = FTNodeProperty.SupportTypes[selectTypeIndex]; } EditorGUI.EndDisabledGroup(); if (prop.ValueType == FTNodeProperty.IntType) { prop.IntValue = EditorGUILayout.IntField(prop.IntValue); } else if (prop.ValueType == FTNodeProperty.FloatType) { // special bool isValueDisabled = false; if (FTNode.name == "CheckTargetHatred" && prop.Key == "value2") { if (FTNode.properties[1].Key == "compOperator" && (FTNode.properties[1].StringValue == "lessEqual" || FTNode.properties[1].StringValue == "greaterEqual")) { isValueDisabled = true; } } EditorGUI.BeginDisabledGroup(isValueDisabled); prop.FloatValue = EditorGUILayout.FloatField(prop.FloatValue); EditorGUI.EndDisabledGroup(); } else if (prop.ValueType == FTNodeProperty.StringType) { if (propCfg != null && propCfg.valueType == FTNodePropertyCfg.ValueType.StringEnum) { string[] defVals = propCfg.GetStringEnumValues(); int curValIdx = Array.IndexOf(defVals, prop.StringValue); if (curValIdx >= 0 && curValIdx < defVals.Length) { int selValIdx = EditorGUILayout.Popup(curValIdx, defVals); prop.StringValue = defVals[selValIdx]; } else { Debug.LogError("Failed to get value in prop cfg > " + FTNode.name + " - " + prop.StringValue); prop.StringValue = EditorGUILayout.TextField(prop.StringValue); } } else { prop.StringValue = EditorGUILayout.TextField(prop.StringValue); } } else { Debug.LogError("not implement FTNodeProperty value type > " + prop.ValueType); } EditorGUI.BeginDisabledGroup(isDefaultProperty); if (GUILayout.Button("Remove")) { FTNode.properties.Remove(prop); } EditorGUI.EndDisabledGroup(); } EditorGUILayout.EndHorizontal(); } }