protected virtual void OnEnable() { if (SelectedView == null) { LeftSelectIndx = 1; } string groupPath = GetGroupPath(); if (!string.IsNullOrEmpty(groupPath)) { Group = AssetDatabase.LoadAssetAtPath <StateGraphGroup>(groupPath); if (Group == null) { Group = CreateInstance <StateGraphGroup>(); Group.Groups.Add("Default"); AssetDatabase.CreateAsset(Group, groupPath); } } EditorApplication.playModeStateChanged -= WaitSave; }
public override void OnInspectorGUI() { GUILayout.Label("组仅为显示用,只能增加和修改名字,不能删除"); StateGraphGroup owner = target as StateGraphGroup; for (int i = 0; i < owner.Groups.Count; ++i) { string name = owner.Groups[i]; EditorGUI.BeginChangeCheck(); name = EditorGUILayout.TextField(i.ToString(), name); if (EditorGUI.EndChangeCheck()) { OnModify(); owner.Groups[i] = name; } } if (GUILayout.Button("添加")) { OnModify(); int newId = owner.Groups.Count; owner.Groups.Add($"Group {newId}"); } }