Exemple #1
0
        protected virtual void ParseEventValue(XmlElement elm, Node node)
        {
            string        evtName = elm.GetAttribute("name");
            EventProperty evtPro  = node.GetEventProperty(evtName);

            if (evtPro == null)
            {
                UnityEngine.Debug.LogError("can not find event:" + evtName);
                return;
            }
            evtPro.strValue = elm.GetAttribute("value");
            evtPro.param.Clear();
            GlobalEventDef evtDef = editor.GetGlobalEventDef(evtPro.strValue);

            if (evtDef == null)
            {
                UnityEngine.Debug.LogError("can not find event def:" + evtPro.strValue);
                return;
            }
            evtDef.Init(evtPro);
            for (int i = 0; i < editor.globalEventDef.Count; ++i)
            {
                if (editor.globalEventDef[i].name == evtPro.strValue)
                {
                    evtPro.selectIdx = i;
                    return;
                }
            }
        }
 public virtual void Draw(EventProperty eventPro)
 {
     if (eventPro.editorParams)
     {
         eventPro.isFoldout = EditorGUILayout.Foldout(eventPro.isFoldout, eventPro.desc + "参数");
         if (eventPro.isFoldout)
         {
             foreach (ParamProperty p in eventPro.param)
             {
                 p.parmDef.Draw(p);
             }
         }
     }
 }
        public virtual void Init(Node node)
        {
            node.name  = this.name;
            node.desc  = this.desc;
            node.type  = this.type;
            node.color = this.color;
            //input
            foreach (Input o in this.input)
            {
                PreNode preNode = new PreNode(node);
                preNode.inIdx       = node.preNodeList.Count;
                preNode.name        = o.name;
                preNode.desc        = o.desc;
                preNode.connectType = o.connectType;
                preNode.connectDef  = NodeFlowEditorWindow.instance.GetConnectionDef(preNode.connectType);
                node.preNodeList.Add(preNode);
            }
            //output
            foreach (Output o in this.output)
            {
                NextNode nextNode = new NextNode(node);
                nextNode.outIdx      = node.nextNodeList.Count;
                nextNode.name        = o.name;
                nextNode.desc        = o.desc;
                nextNode.connectType = o.connectType;
                nextNode.connectDef  = NodeFlowEditorWindow.instance.GetConnectionDef(nextNode.connectType);
                node.nextNodeList.Add(nextNode);
            }

            //param
            foreach (Param p in this.param)
            {
                ParamProperty nodePro = new ParamProperty();
                p.Init(nodePro);
                node.property.Add(nodePro);
            }

            //event
            foreach (EventInfo evt  in this.events)
            {
                EventProperty eventPro = new EventProperty();
                eventPro.name         = evt.name;
                eventPro.strValue     = "";
                eventPro.editorParams = evt.editorParams;
                eventPro.eventDef     = null;
                eventPro.desc         = evt.desc;
                node.eventProperty.Add(eventPro);
            }
        }
        public void Clone(EventProperty src)
        {
            this.name         = src.name;
            this.desc         = src.desc;
            this.strValue     = src.strValue;
            this.editorParams = src.editorParams;
            this.eventDef     = src.eventDef;
            this.selectIdx    = src.selectIdx;

            param.Clear();
            foreach (ParamProperty srcP in src.param)
            {
                ParamProperty thisP = new ParamProperty();
                thisP.Clone(srcP);
                param.Add(thisP);
            }
        }
        public List <Param> paramList = new List <Param>();  // name , type

        public virtual void Init(EventProperty pro)
        {
            pro.strValue = name;
            pro.eventDef = this;

            pro.param.Clear();
            if (pro.editorParams)
            {
                foreach (Param p in paramList)
                {
                    ParamProperty param = new ParamProperty();
                    p.Init(param);

                    pro.param.Add(param);
                }
            }
        }
        public static void Show(Node node)
        {
            if (node == null)
            {
                lastNode = node;
                return;
            }

            if (lastNode != node)
            {
                GUI.FocusControl("-1");
                lastNode = node;
            }

            for (int i = 0; i < node.property.Count; ++i)
            {
                GUI.SetNextControlName(i.ToString());
                ParamProperty pro = node.property[i];
                pro.parmDef.Draw(pro);
            }

            for (int i = 0; i < node.eventProperty.Count; ++i)
            {
                GUI.SetNextControlName(i.ToString());
                EventProperty pro     = node.eventProperty[i];
                int           lastIdx = pro.selectIdx;
                pro.selectIdx = EditorGUILayout.Popup(pro.desc, pro.selectIdx, NodeFlowEditorWindow.instance.globalEventList);
                if (pro.selectIdx != lastIdx)
                {
                    pro.param.Clear();
                    GlobalEventDef eventDef = NodeFlowEditorWindow.instance.globalEventDef[pro.selectIdx];
                    if (eventDef != null)
                    {
                        eventDef.Init(pro);
                    }
                }

                if (pro.eventDef != null)
                {
                    pro.eventDef.Draw(pro);
                }
            }
        }
Exemple #7
0
        protected virtual void ParseEventParamValue(XmlElement elm, Node node)
        {
            string        evtName = elm.GetAttribute("event");
            EventProperty evtPro  = node.GetEventProperty(evtName);

            if (evtPro == null)
            {
                UnityEngine.Debug.LogError("can not find event:" + evtName);
                return;
            }
            string name = elm.GetAttribute("name");
            string type = elm.GetAttribute("type");

            foreach (ParamProperty pro in evtPro.param)
            {
                if (pro.name == name && pro.type == type)
                {
                    pro.strValue = elm.GetAttribute("value");
                    return;
                }
            }
            UnityEngine.Debug.LogError("ParseParamValue() error!");
        }