/// <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); } } }
/// <summary> /// 根据节点的字段类型调用对应的绘制接口 /// </summary> /// <param name="item"></param> void DrawNodeField(NodeFileInfor item, float pos) { switch (item.m_NodeAttribute.ValueType) { case NodeValueTypeEnum.Int: NodeDrawer_Int.Instance.DrawNodeField(item, this, pos); break; case NodeValueTypeEnum.Float: NodeDrawer_Float.Instance.DrawNodeField(item, this, pos); break; case NodeValueTypeEnum.String: NodeDrawer_String.Instance.DrawNodeField(item, this, pos); break; } }