コード例 #1
0
 public OutputPortEditorView(NodeEditorView nodeView, OutputPortReflectionInfo outputPortReflectionInfo, int portId) :
     base(nodeView)
 {
     FlowType = FlowType.Out;
     this.outputPortReflectionInfo = outputPortReflectionInfo;
     this.portId = portId;
 }
コード例 #2
0
        void InitOutputPortReflectionInfos()
        {
            MethodInfo[] methodInfos = Type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
            for (int i = 0; i < methodInfos.Length; i++)
            {
                MethodInfo methodInfo = methodInfos[i];

                object[] attributeObjects = methodInfo.GetCustomAttributes(typeof(NodeOutputPortAttribute), false);
                if (attributeObjects.Length > 0)
                {
                    OutputPortReflectionInfo outputPortReflectionInfo =
                        new OutputPortReflectionInfo(attributeObjects[0] as NodeOutputPortAttribute, methodInfo, instance);
                    outputPortInfoList.Add(outputPortReflectionInfo);
                }
            }

            outputPortInfoList.Sort((a, b) => a.outputPortAttribute.portId - b.outputPortAttribute.portId);
            for (int i = 0; i < outputPortInfoList.Count; i++)
            {
                if (outputPortInfoList[i].outputPortAttribute.portId == i)
                {
                    continue;
                }
                Debug.LogErrorFormat("类型 {0} 上使用的NodeOutputPortAttribute的portId没有从0开始连续,请检查", Type.Name);
                return;
            }
        }
コード例 #3
0
        public NodeEditorView(Vector2 graphPosition, GraphEditorWindow graph, int nodeId, NodeReflectionInfo reflectionInfo)
        {
            this.graph          = graph;
            this.NodeId         = nodeId;
            this.ReflectionInfo = reflectionInfo;

            PositionInGraph  = graphPosition;
            PositionInWindow = graph.GraphPositionToWindowPosition(graphPosition);

            viewRect = new Rect(Vector2.zero, new Vector2(200, 400));

            allPortList        = new List <PortEditorView>();
            inputPortViewList  = new List <InputPortEditorView>();
            outputPortViewList = new List <OutputPortEditorView>();

            leftPortLayoutHelper  = new PortLayoutHelper();
            rightPortLayoutHelper = new PortLayoutHelper();

            if (reflectionInfo.HasFlowInPort)
            {
                flowInPortView        = new FlowInPortEditorView(this);
                flowInPortView.portId = 0;
                allPortList.Add(flowInPortView);
            }

            if (reflectionInfo.flowOutPortDefineAttributes.Length > 0)
            {
                flowOutPortViews = new FlowOutPortEditorView[reflectionInfo.flowOutPortDefineAttributes.Length];
                for (int i = 0; i < flowOutPortViews.Length; i++)
                {
                    flowOutPortViews[i]        = new FlowOutPortEditorView(this, reflectionInfo.flowOutPortDefineAttributes[i]);
                    flowOutPortViews[i].portId = i;
                    allPortList.Add(flowOutPortViews[i]);
                }
            }
            else
            {
                flowOutPortViews = new FlowOutPortEditorView[0];
            }

            List <InputPortReflectionInfo> inputPortReflectionInfos = reflectionInfo.inputPortInfoList;

            for (int i = 0; i < inputPortReflectionInfos.Count; i++)
            {
                InputPortReflectionInfo inputPortReflectionInfo = inputPortReflectionInfos[i];
                InputPortEditorView     inputPortView           = new InputPortEditorView(this, inputPortReflectionInfo);
                inputPortView.portId = i;

                inputPortViewList.Add(inputPortView);
                allPortList.Add(inputPortView);
            }

            List <OutputPortReflectionInfo> outputPortReflectionInfos = reflectionInfo.outputPortInfoList;

            for (int i = 0; i < outputPortReflectionInfos.Count; i++)
            {
                OutputPortReflectionInfo outputPortReflectionInfo = outputPortReflectionInfos[i];
                OutputPortEditorView     outputPortView           = new OutputPortEditorView(this, outputPortReflectionInfo, i);
                outputPortView.portId = i;

                outputPortViewList.Add(outputPortView);
                allPortList.Add(outputPortView);
            }

            CalculateNodeSize();
        }