protected override void DrawInternal() { BehaviorAction selected = window.selection.Selected; if (selected == null) { GUILayout.Label("No action selected"); return; } string newName = EditorGUILayout.TextField("Action Name", selected.name); if (newName != selected.name) { selected.name = newName; MarkDataDirty(); } EditorGUILayout.Space(); GUILayout.BeginVertical(EditorStyles.helpBox); GUILayout.BeginHorizontal(); GUILayout.Label("Method"); GUILayout.FlexibleSpace(); GUILayout.Label(selected.method != null ? selected.method.ToString() : "None"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Target context type"); GUILayout.FlexibleSpace(); GUILayout.Label(selected.method != null ? selected.method.TargetContextType?.ToString() : "None"); GUILayout.EndHorizontal(); if (selected.method != null && GUILayout.Button("Remove Method")) { AssignMethod(null); } GUILayout.EndVertical(); if (selected.method == null) { GUILayout.BeginHorizontal(EditorStyles.helpBox); EditorGUIUtility.SetIconSize(Vector2.one * EditorGUIUtility.singleLineHeight); GUILayout.Label(EditorGUIUtility.IconContent("console.warnicon")); GUILayout.FlexibleSpace(); GUILayout.Label("No assigned method! This behavior action will not show up when searching", new GUIStyle(GUI.skin.label) { wordWrap = true }); GUILayout.EndHorizontal(); } }
public void AssignMethod(SerializableMethod method) { BehaviorAction selected = window.selection.Selected; if (selected == null) { EditorUtility.DisplayDialog("No action selected!", "Please select an action before assigning the method.", "ok"); return; } if (selected.method == method) { return; } if (selected.method != null && !RemoveItemWarn($"{(method == null ? "Remove" : "Replace")} method?")) { return; } if (selected.name == UntitledName && method != null) { selected.name = method.Method.Name; } selected.method = method; MarkDataDirty(); }
protected override void DrawInternal() { var imports = window.currentData.actions; Assert.IsNotNull(imports); GUILayout.BeginHorizontal(); if (GUILayout.Button("Add New")) { imports.Add(new BehaviorAction(UntitledName)); MarkDataDirty(); } GUILayout.EndHorizontal(); scrollPosition = GUILayout.BeginScrollView(scrollPosition); for (int i = 0; i < imports.Count; i++) { BehaviorAction import = imports[i]; bool selected = Selected == import; GUILayout.BeginHorizontal(EditorStyles.helpBox); GUILayout.Label(import.name); GUILayout.FlexibleSpace(); if (GUILayout.Button("Remove") && RemoveItemWarn("Remove method?")) { imports.RemoveAt(i); MarkDataDirty(); if (selected) { Selected = null; } i--; continue; } if (GUILayout.Toggle(selected, "Edit", GUI.skin.button) != selected) { Selected = selected ? null : import; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); }