Ejemplo n.º 1
0
    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;
    }
Ejemplo n.º 2
0
    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}");
        }
    }