Esempio n. 1
0
        void OpenAddNodeWindow(object mousePositionObject)
        {
            Vector2 mousePosition = (Vector2)mousePositionObject;

            try
            {
                PopupWindow.Show(new Rect(mousePosition + position.position, new Vector2(200, 0)), new AddNodePopupWindow(type =>
                {
                    if (data.CheckDuplicateEntranceNode(type))
                    {
                        EditorUtility.DisplayDialog("重复入口类型", "每一种入口节点只允许存在一个", "ok");
                        return;
                    }

                    //重置tip显示
                    currentHoverNodeView = null;
                    currentHoverPortView = null;
                    startHoverdTime      = EditorApplication.timeSinceStartup;

                    int newId = data.GetNewNodeId();
                    NodeReflectionInfo reflectionInfo = new NodeReflectionInfo(type);
                    NodeEditorView nodeEditorView     = new NodeEditorView(WindowPositionToGraphPosition(mousePosition), this, newId,
                                                                           reflectionInfo);
                    data.CurrentNodeList.Add(nodeEditorView);
                }));
            }
            catch
            {
            }
        }
Esempio n. 2
0
        private static NodeEditorView ParseNodeInfo(NodeConfigInfo nodeConfigInfo, GraphEditorWindow graph)
        {
            string nodeTypeName = nodeConfigInfo.nodeClassTypeName;
            Type   nodeType     = Type.GetType(nodeTypeName + ",Assembly-CSharp");

            if (nodeType == null)
            {
                Debug.LogErrorFormat("无法载入类型{0} ,该节点被跳过", nodeTypeName);
                return(null);
            }

            NodeReflectionInfo reflectionInfo = new NodeReflectionInfo(nodeType);
            NodeEditorView     nodeView       =
                new NodeEditorView(nodeConfigInfo.positionInGraph, graph, nodeConfigInfo.nodeId, reflectionInfo);

            return(nodeView);
        }
Esempio n. 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();
        }