예제 #1
0
 private void Init(QVariableState state, GVariableModel model)
 {
     state.Model = model;
     OnTypeChanged(state, type);
     state.onTypeChanged = OnTypeChanged;
     state.onSubStateAdd = OnSubStateAdd;
     state.onSubStateDel = OnSubStateDel;
 }
예제 #2
0
        private void OnSubStateAdd(QVariableState state)
        {
            GVariableModel model = new GVariableModel(target);

            model.state = state;
            Init(model.state, model);
            lstSubModel.Add(model);
        }
예제 #3
0
        private void OnTypeChanged(QVariableState state, string value)
        {
            state.Model.type = value;
            state.Model.name = GetName(string.Format("{0}{1}", GConfigure.GetShortTypeName(state.Model.type), GConfigure.RemoveFrontTypeName(target.name)), target);
            state.SetName(state.Model.name);
            state.Model.isUI    = false;
            state.isSelectEvent = false;
            if (!IsUIType(state.Model.type))
            {
                state.Model.eventType             =
                    state.Model.variableEvent     =
                        state.Model.actionName    =
                            state.Model.eventName = string.Empty;
                return;
            }
            var uiType = (UIType)Enum.Parse(typeof(UIType), state.Model.type);

            state.Model.variableEvent = string.Empty;
            switch (uiType)
            {
            case UIType.Button:
                state.Model.variableEvent = "onClick";
                break;

            case UIType.InputField:
                state.Model.variableEvent = "onEndEdit";
                break;

            case UIType.ScrollRect:
            case UIType.Dropdown:
            case UIType.Scrollbar:
            case UIType.Slider:
            case UIType.Toggle:
                state.Model.variableEvent = "onValueChanged";
                break;
            }


            if (state.Model.variableEvent != string.Empty)
            {
                state.isSelectEvent    = true;
                state.Model.eventType  = parameters[(int)uiType];
                state.Model.actionName = state.Model.variableEvent.Insert(state.Model.variableEvent.Length, state.attributeName);
                state.Model.eventName  = GGlobalFun.GetFirstUpper(state.Model.actionName);
            }

            //Debug.LogError(state.Model.actionName + "---" + state.Model.variableEvent + "---" + state.attributeName);
        }
예제 #4
0
        public void Init()
        {
            GScriptInfo so = null;

            if (FileHelper.IsExists(GConfigure.InfoPath))
            {
                so = AssetDatabase.LoadAssetAtPath <GScriptInfo>(GConfigure.InfoPath);
            }
            if (so == null)
            {
                return;
            }

            var fields = so.GetFieldInfos(GConfigure.selectTransform.name);

            for (int i = 0; i < fields.Length; i++)
            {
                var obj = GConfigure.selectTransform.Find(fields[i].path);
                if (obj == null)
                {
                    continue;
                }
                var v = this[obj];
                v.state.isVariable    = true;
                v.state.isAttribute   = fields[i].mainAttrInfo.isAttr;
                v.state.attributeName = fields[i].mainAttrInfo.name;
                v.state.isEvent       = fields[i].mainAttrInfo.isEvent;
                v.type = fields[i].mainAttrInfo.type;
                v.state.SetIndex(fields[i].mainAttrInfo.type, obj);
                v.LstSubModel.Clear();
                v.state.LstSubState.Clear();
                for (int j = 0; j < fields[i].subField.Count; j++)
                {
                    var subState = new QVariableState();
                    subState.isVariable  = true;
                    subState.isAttribute = fields[i].subField[j].isAttr;

                    subState.isEvent = fields[i].subField[j].isEvent;
                    subState.SetIndex(fields[i].subField[j].type, obj);
                    v.AddSubState(subState);
                    subState.Model.type    = fields[i].subField[j].type;
                    subState.attributeName = fields[i].subField[j].name;
                }
            }

            GConfigure.Version = so.GetVersion(GConfigure.selectTransform.name);
        }
예제 #5
0
        public bool Update(Transform t, int depth)
        {
            var rect = EditorGUILayout.BeginHorizontal();

            {
                if (isVariable)
                {
                    EditorGUI.DrawRect(rect, new Color(0, 0.5f, 0, 0.3f));
                }

                if (parentState != null)
                {
                    EditorGUILayout.LabelField("----", GConfigureDefine.toggleMaxWidth);
                    if (GUILayout.Button("-", GConfigureDefine.plusMaxWidth))
                    {
                        parentState.lstSubState.Remove(this);
                        //删去一个sub
                        //parentState.lsts
                        parentState.onSubStateDel(this);
                    }
                }

                isVariable = EditorGUILayout.ToggleLeft("变量", isVariable, GConfigureDefine.toggleMaxWidth);

                if (!isVariable)
                {
                    isAttribute = false;
                    isEvent     = false;
                    lstSubState.Clear();
                    // if (parentState != null)
                    //     parentState.onSubStateChanged();
                }

                {
                    GUI.enabled = isVariable;
                    isAttribute = EditorGUILayout.ToggleLeft("属性器", isAttribute, GConfigureDefine.toggleMaxWidth);

                    GUI.enabled = !isVariable ? false : isSelectEvent;
                    isEvent     = EditorGUILayout.ToggleLeft("事件", isEvent, GConfigureDefine.toggleMaxWidth);

                    GUI.enabled = true;
                    if (parentState == null)
                    {
                        if (isVariable && GUILayout.Button("+", GConfigureDefine.plusMaxWidth))
                        {
                            var subState = new QVariableState();
                            subState.comNames    = comNames;
                            subState.isVariable  = true;
                            subState.parentState = this;
                            lstSubState.Add(subState);
                            onSubStateAdd(subState);
                            //添加一个sub
                        }
                    }
                }

                attributeName = EditorGUILayout.TextField(attributeName, GConfigureDefine.attriNameMaxWidth);

                oldIndex = index;
                comNames = GGlobalFun.GetComponentsName(t);

                index = EditorGUILayout.Popup(index, comNames, GConfigureDefine.popupMaxWidth);

                if (oldIndex != index)
                {
                    onTypeChanged(this, comNames[index]);
                }

                GUILayout.Space(depth * GConfigureDefine.space);

                if (t.childCount > 0)
                {
                    isOpen = EditorGUILayout.Foldout(isOpen, t.name, true);
                }
                else
                {
                    EditorGUILayout.LabelField(t.name);
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            for (int i = 0; i < lstSubState.Count; i++)
            {
                EditorGUILayout.BeginVertical();
                lstSubState[i].Update(t, depth);
                EditorGUILayout.EndVertical();
            }


            return(isOpen);
        }
예제 #6
0
 private void OnSubStateDel(QVariableState state)
 {
     lstSubModel.Remove(state.Model);
 }
예제 #7
0
 public void AddSubState(QVariableState subState)
 {
     subState.ParentState = state;
     state.LstSubState.Add(subState);
     OnSubStateAdd(subState);
 }