예제 #1
0
    /// <summary>
    /// 初始化ACT项的属性,从文件目录加载配置
    /// </summary>
    /// <param name="groupName">Act 的分组</param>
    /// <param name="actName">Act 的名称</param>
    public void InitActItemProperty(string groupName, string actName)
    {
        this.actGroup = groupName;
        this.actName  = actName;

        //加载文件
        string relativePath = string.Concat("Act/", groupName, "/", actName, ".act");

        object[] property = localDataHelper.Import(relativePath);
        widgetList.Clear();

        if (property == null)
        {
            return;                         //新建的文件没有本地数据
        }
        int index = 0;

        foreach (object obj in property)
        {
            EditorWidgetState widget = new EditorWidgetState();
            widget.Entity  = obj;
            widget.FoldOut = index == 0;

            EditorGUIUtil.FindAllWidget(new List <EditorWidgetState>(), widget, widget.Entity);

            index++;
            widgetList.Add(widget);
        }
    }
예제 #2
0
    /// <summary>
    /// 添加新的模块
    /// </summary>
    private void onAddNewModuleGUI()
    {
        EditorGUIUtil.DrawHeader("Add New Module");
        //添加模块视图
        GUILayout.BeginHorizontal("AS TextArea", GUILayout.Height(30));
        selectEnum = (ActModuleEnum)EditorGUILayout.EnumPopup("新模块", selectEnum, GUILayout.MaxWidth(Screen.width * 0.5f));

        GUI.backgroundColor = Color.green;
        if (GUILayout.Button("Add", GUILayout.Width(60)))
        {
            if (string.IsNullOrEmpty(actName))
            {
                return;
            }

            EditorWidgetState widget = new EditorWidgetState();
            widget.Entity  = Activator.CreateInstance(moduleMap[selectEnum]);
            widget.FoldOut = true;

            EditorGUIUtil.FindAllWidget(new List <EditorWidgetState>(), widget, widget.Entity);

            widgetList.Add(widget);
        }
        GUI.backgroundColor = Color.white;

        GUILayout.EndHorizontal();
    }