public virtual void Init(ParamProperty property)
 {
     property.name    = name;
     property.type    = type;
     property.desc    = desc;
     property.parmDef = this;
 }
 public void Clone(ParamProperty src)
 {
     this.name     = src.name;
     this.desc     = src.desc;
     this.type     = src.type;
     this.strValue = src.strValue;
     this.parmDef  = src.parmDef;
 }
        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 virtual void Draw(ParamProperty property)
 {
     if (property.type == "bool")
     {
         if (property.strValue.Length == 0)
         {
             property.strValue = "false";
         }
         bool b = bool.Parse(property.strValue);
         b = EditorGUILayout.Toggle(property.desc, b);
         property.strValue = b.ToString().ToLower();
     }
     else
     {
         property.strValue = EditorGUILayout.TextField(property.desc, property.strValue);
     }
 }
        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);
                }
            }
        }
        public void PasteProperty(int nodeId, string key, string value)
        {
            if (mCurrent == null)
            {
                return;
            }
            int  idx  = int.Parse(key);
            Node node = mCurrent.GetNodeByID(nodeId);

            for (int i = 0; i < node.property.Count; ++i)
            {
                ParamProperty pro = node.property[i];

                if (i == idx)
                {
                    pro.strValue = value;
                    return;
                }
            }
        }
        public string CopyProperty(int nodeId, string key)
        {
            if (mCurrent == null)
            {
                return("");
            }
            int  idx  = int.Parse(key);
            Node node = mCurrent.GetNodeByID(nodeId);

            if (node == null)
            {
                return("");
            }
            for (int i = 0; i < node.property.Count; ++i)
            {
                ParamProperty pro = node.property[i];

                if (i == idx)
                {
                    return(pro.strValue);
                }
            }
            return("");
        }