Esempio n. 1
0
 public NodeFileInfor(NodeAttribute attribute, FieldInfo field, NodeActionParent script, Type type)
 {
     m_NodeAttribute = attribute;
     m_FieldInfo     = field;
     m_Script        = script;
     m_RealType      = type;
 }
        public NodeParent m_EditorNode;         //编辑器视图对象

        public EditorRecordNode(ActionTreeNode node, Vector2 mousPos)
        {
            m_Node    = node;
            m_ShowPos = mousPos;
            m_UID     = GenerateUID.GetUID64();

            Debug.Log("m_Node.m_AttachType=" + m_Node.m_AttachType + "mousPos=" + mousPos);
            object obj = m_Node.m_AttachType.Assembly.CreateInstance(m_Node.m_AttachType.Name);

            if (obj == null)
            {
                Debug.LogError(" m_Node.m_AttachType=" + m_Node.m_AttachType);
                return;
            }
            m_ActionScript = obj  as NodeActionParent;
            m_EditorNode   = new NodeParent(m_ActionScript);
            var attributes = m_Node.m_AttachType.GetCustomAttributes(false).OfType <BehaviorActionAttribute>();

            foreach (var item in attributes)
            {
                if (m_ActionScript.m_BehaviorActionAttribute == null)
                {
                    m_ActionScript.m_BehaviorActionAttribute = item;
                }
                //   Debug.Log("zz " + item.ActionArrangement);
            }
            //   m_ShowNode.m_BehaviorActionAttribute = attributes[0];
            m_EditorNode.m_Pos = mousPos;
        }
Esempio n. 3
0
 /// <summary>
 /// 获取所有标记为NodeAttribute 特性的字段
 /// </summary>
 protected virtual void GetAllNodeField(NodeActionParent scriptAction)
 {
     m_AllNodeFiled.Clear();
     FieldInfo[] allfields = scriptAction.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
     foreach (FieldInfo field in allfields)
     {
         NodeAttribute attribute = Attribute.GetCustomAttribute(field, typeof(NodeAttribute)) as NodeAttribute;
         if (attribute != null)
         {
             Debug.Log("GetAllNodeField   " + attribute.Name + "  " + field.Name);
             GetNodeWidth(attribute);
             m_NodeHeightScale += GetNodeHeight(attribute);
             NodeFileInfor infor = new NodeFileInfor(attribute, field, scriptAction, scriptAction.GetType());
             m_AllNodeFiled.Add(infor);
         }
     }
 }
Esempio n. 4
0
        public NodeParent(NodeActionParent scriptObj)
        {
            FieldInfo[] allfields = scriptObj.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            foreach (FieldInfo field in allfields)
            {
                NodeAttribute attribute = Attribute.GetCustomAttribute(field, typeof(NodeAttribute)) as NodeAttribute;
                if (attribute != null)
                {
                    object Value = field.GetValue(scriptObj);
                    if (Value == null)
                    {
                        field.SetValue(scriptObj, attribute.DefaultValue);  //如果没有设置默认值则使用特性中定义的默认值
                        //Debug.Log(">>>>  " + field.Name);
                    }

                    if (attribute.InOut != NodeInOutEnum.None)
                    {
                        NodeLineInfor nodeLine = new NodeLineInfor(field, attribute.InOut, attribute.SignalConnect, this);
                        m_AllNodeLinesInfor.Add(field, nodeLine);
                    }//记录所有的节点
                }
            }
        }