Exemple #1
0
        public static void Open <T>(PWGraph graph) where T : PWGraphEditor
        {
            PWGraphEditor editor = EditorWindow.GetWindow <T>();

            editor.LoadGraph(graph);
            editor.Show();
        }
Exemple #2
0
        public void Render2ResizablePanel(PWGraphEditor graphEditor, Rect position)
        {
            //update min and max positions for resizable panel
            h1.UpdateMinMax(position.width / 2, position.width - 3);
            h2.UpdateMinMax(50, position.width / 2);

            //split view and call delegates
            h1.Begin();
            Rect firstPanel = h2.Begin();

            // Debug.Log("firstPanel: " + firstPanel);
            if (onDrawSettingsBar != null)
            {
                onDrawSettingsBar(firstPanel);
            }
            Rect optionBarRect = h2.Split(resizeHandleColor);

            if (onDrawOptionBar != null)
            {
                onDrawOptionBar(optionBarRect);
            }
            optionBarRect = GUILayoutUtility.GetLastRect();
            h2.End();
            Rect secondPanel = h1.Split(resizeHandleColor);

            if (onDrawNodeSelector != null)
            {
                onDrawNodeSelector(secondPanel);
            }
            h1.End();

            if (e.type == EventType.Repaint)
            {
                //add the handleWidth to the panel for event mask + 2 pixel for UX
                firstPanel.width += h1.handleWidth + 2;
                secondPanel.xMin -= h2.handleWidth + 2;

                //update event masks with our GUI parts
                graphEditor.eventMasks[0] = firstPanel;
                graphEditor.eventMasks[1] = optionBarRect;
                graphEditor.eventMasks[2] = secondPanel;
            }

            //debug:
            // Random.InitState(42);
            // foreach (var mask in graphEditor.eventMasks)
            // EditorGUI.DrawRect(mask.Value, Random.ColorHSV());
        }
Exemple #3
0
        public static bool OnOpenAssetAttribute(int instanceId, int line)
        {
            object instance = EditorUtility.InstanceIDToObject(instanceId);

            //if selected object is not a graph
            if (!editorTypeTable.ContainsKey(instance.GetType()))
            {
                return(false);
            }

            //open Graph window:
            PWGraphEditor window = (PWGraphEditor)EditorWindow.GetWindow(editorTypeTable[instance.GetType()]);

            window.Show();
            window.LoadGraph(instance as PWGraph);

            return(false);
        }