示例#1
0
        void DrawGraphSettings(Rect currentRect)
        {
            Event e = Event.current;

            EditorGUILayout.Space();

            GUI.SetNextControlName("PWName");
            graph.name = EditorGUILayout.TextField("ProceduralWorld name: ", graph.name);

            EditorGUILayout.Separator();

            //No need for the moment

            /*if (GUILayout.Button("Cleanup graphs"))
             * {
             *      PWGraph[] graphs = Resources.FindObjectsOfTypeAll< PWGraph >();
             *
             *      foreach (var graph in graphs)
             *              if (graph.objectName.Contains("(Clone)"))
             *              {
             *                      Debug.Log("destroyed graph: " + graph);
             *                      GameObject.DestroyImmediate(graph, false);
             *              }
             * }*/

            //reload and force reload buttons
            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Force reload"))
                {
                    graph.RaiseOnForceReload();
                }
                if (GUILayout.Button("Force reload Once"))
                {
                    graph.RaiseOnForceReloadOnce();
                }
            }
            EditorGUILayout.EndHorizontal();

            //unfocus all fields if we click outsize of the settings bar
            if ((e.type == EventType.MouseDown || e.type == EventType.Ignore) &&
                !GUILayoutUtility.GetLastRect().Contains(e.mousePosition) &&
                GUI.GetNameOfFocusedControl() == "PWName")
            {
                GUI.FocusControl(null);
            }

            //update the delayed changes
            delayedChanges.Update();
        }
        public virtual void Draw(Rect rect)
        {
            if (first)
            {
                OnLoadStyle();
                first = false;
            }
            onGUI(rect);
            delayedChanges.Update();

            if (oldWindowRect != Rect.zero && oldWindowRect != graphEditor.position)
            {
                OnWindowResize(oldWindowRect);
            }

            oldWindowRect = graphEditor.position;
        }
示例#3
0
        public override void OnInspectorGUI()
        {
            //if we loose the reference of our node, auto-destruct
            if (nodeRef == null)
            {
                DestroyImmediate(this);
            }

            if (!guiEnabled)
            {
                OnGUIEnable();
            }

            if (isInsideGraph)
            {
                RenderNode();
            }
            else
            {
                RenderInspector();
            }

            delayedChanges.Update();
        }
示例#4
0
        //draw the default node graph:
        public override void OnGUI()
        {
            base.OnGUI();

            if (graph == null)
            {
                RenderGraphNotFound();
                return;
            }

            //update the current GUI settings storage and clear drawed popup list:
            PWGUI.StartFrame(position);

            //set the skin for the current window
            GUI.skin = PWGUISkin;

            if (!graph.presetChoosed)
            {
                return;
            }

            RenderBackground();

            //protection against node class rename & corrupted nodes
            for (int i = 0; i < graph.nodes.Count; i++)
            {
                var node = graph.nodes[i];
                if (node == null)
                {
                    graph.nodes.RemoveAt(i);
                }
                else if (node.GetType() == typeof(BaseNode))
                {
                    graph.RemoveNode(node);
                }
            }

            //disable events if mouse is above an eventMask Rect.
            eventMasks = layout.GetRects();
            MaskEvents();

            //profiling
            Profiler.BeginSample("[PW] Graph redering (" + e.type + ")");

            Rect pos = position;

            pos.position            = Vector2.zero;
            graph.zoomPanCorrection = GUIScaleUtility.BeginScale(ref pos, pos.size / 2, 1f / graph.scale, false);
            {
                //draw the background:
                RenderBackground();

                //manage selection:
                SelectAndDrag();

                //graph rendering
                RenderOrderingGroups();
                RenderLinks();
                RenderNodes();

                //context menu
                ContextMenu();

                //fill and process remaining events if there is
                ManageEvents();

                //reset events for the next frame
                editorEvents.Reset();

                if (e.type == EventType.Repaint)
                {
                    Repaint();
                }
            }
            GUIScaleUtility.EndScale();

            Profiler.EndSample();

            //restore masked events:
            UnMaskEvents();

            //update delayedChanges
            delayedChanges.Update();
        }