Exemplo n.º 1
0
        void OnGUI()
        {
            if (!CheckSelectedObject())
            {
                EditorGUILayout.HelpBox("Please select scriptable object instance which has a [Graph] attribute", MessageType.Info, true);
                return;
            }

            if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
            {
                Event.current.Use();
                return;
            }

            if (Event.current.type == EventType.Used)
            {
                return;
            }

            JointHighlight = (JointHighlightHolder)GUIUtility.GetStateObject(typeof(JointHighlightHolder)
                                                                             , GUIUtility.GetControlID(FocusType.Passive));

            List <Node> nodes = new List <Node>();

            OnGUIToolBar();

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Width(contentWidth), GUILayout.Height(contentHeight));

            if (connectionCollection != null)
            {
                foreach (Connection connectionGUI in connectionCollection.allConnections)
                {
                    connectionGUI.OnGUI();
                }
            }

            foreach (var graphData in CurrentGraph.ItemList)
            {
                Node nodeGUI = Node.GetInstance((ScriptableObjectNode)graphData, this);
                nodes.Add(nodeGUI);
            }

            BeginWindows();
            foreach (Node node in nodes)
            {
                node.OnGUI();
            }
            EndWindows();

            connectionCollection = new ConnectionsCollection(nodes, this);

            HandleDraggConnections(nodes, connectionCollection.LastDraggedConnection);
            EditorGUILayout.EndScrollView();
            UpdateContentSize(nodes);
        }
Exemplo n.º 2
0
        void OnGUI()
        {
            if (!CheckSelectedObject()){
                EditorGUILayout.HelpBox("Please select scriptable object instance which has a [Graph] attribute", MessageType.Info,true);
                return;
            }

            if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed"){
                Event.current.Use();
                return;
            }

            if (Event.current.type == EventType.Used){
                return;
            }

            bool firsDrawCallOnThisGraph = CurrentGraph != lastUsedGraph;
            JointHighlight = (JointHighlightHolder) GUIUtility.GetStateObject(typeof(JointHighlightHolder)
                ,GUIUtility.GetControlID(FocusType.Passive));

            List<Node> nodes  = new List<Node>();
            OnGUIToolBar();

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Width(contentWidth), GUILayout.Height(contentHeight));

            if (connectionCollection != null){
                foreach (Connection connectionGUI in connectionCollection.allConnections) {
                    connectionGUI.OnGUI();
                }
            }

            foreach(var graphData in CurrentGraph.ItemList){
                Node nodeGUI = Node.GetInstance((ScriptableObjectNode)graphData, this);
                nodes.Add(nodeGUI);
            }

            BeginWindows();
            foreach (Node node in nodes){
                node.OnGUI();
            }
            EndWindows();

            connectionCollection = new ConnectionsCollection (nodes, this);

            HandleDraggConnections(nodes, connectionCollection.LastDraggedConnection);
            EditorGUILayout.EndScrollView();
            UpdateContentSize(nodes);
            if (firsDrawCallOnThisGraph ){
                Repaint();
            }
            lastUsedGraph = CurrentGraph;
        }