public override void OnInspectorGUI()
        {
            if (Event.current.isMouse)
            {
                Repaint();
            }

            UndoManager.CheckUndo(bb, "Global Blackboard");
            GUI.backgroundColor = GlobalBlackboard.allGlobals.Find(b => b.name == bb.name && b != bb)? Color.red : Color.white;
            bb.name             = EditorGUILayout.TextField("Unique Name", bb.name);
            GUI.backgroundColor = Color.white;

            bb.dontDestroy = EditorGUILayout.Toggle("DontDestroyOnLoad", bb.dontDestroy);
            if (GUI.changed)
            {
                UndoManager.CheckDirty(bb);
            }


            BlackboardEditor.ShowVariables(bb, bb);
            EditorUtils.EndOfInspector();
            if (Application.isPlaying)
            {
                Repaint();
            }
        }
Ejemplo n.º 2
0
 public override void OnInspectorGUI()
 {
     BlackboardEditor.ShowVariables(bb, bb);
     EditorUtils.EndOfInspector();
     if (Application.isPlaying || Event.current.isMouse)
     {
         Repaint();
     }
 }
Ejemplo n.º 3
0
        void OnGUI()
        {
            if (bb == null || EditorApplication.isCompiling)
            {
                return;
            }
            if (EditorGUIUtility.isProSkin)
            {
                GUI.Box(new Rect(0, 0, Screen.width, Screen.height), string.Empty, Styles.shadowedBackground);
            }
            scrollPos = GUILayout.BeginScrollView(scrollPos);
            GUILayout.Space(15);
            Prefs.showBlackboard = GUILayout.Toggle(Prefs.showBlackboard, "ShowCanvasBlackBoard");

            if (GraphEditor.currentGraph == null)
            {
                GUILayout.Label("No current NodeCanvas Graph open");
                return;
            }

            if (EditorApplication.isCompiling)
            {
                ShowNotification(new GUIContent("Compiling Please Wait..."));
                return;
            }

            currentSelection = GraphEditorUtility.activeElement;

            //if ( currentSelection == null ) {
            //    GUILayout.Label("No Node Selected in Canvas");
            //    return;
            //}


            GUILayout.Space(5);
            BlackboardEditor.ShowVariables(bb, bb);
            EditorUtils.EndOfInspector();
            if (Application.isPlaying || Event.current.isMouse)
            {
                Repaint();
            }
            //if ( currentSelection is Node ) {
            //    var node = (Node)currentSelection;
            //    Title(node.name);
            //    Node.ShowNodeInspectorGUI(node);
            //}

            //if ( currentSelection is Connection ) {
            //    Title("Connection");
            //    Connection.ShowConnectionInspectorGUI(currentSelection as Connection);
            //}

            EditorUtils.EndOfInspector();
            GUILayout.EndScrollView();
        }
Ejemplo n.º 4
0
        public override void OnInspectorGUI()
        {
            GUI.color = GUI.color.WithAlpha(parentBlackboardProp.objectReferenceValue ? 1 : 0.6f);
            EditorGUILayout.PropertyField(parentBlackboardProp, EditorUtils.GetTempContent("Parent Asset Blackboard", null, "Optional Parent Asset Blackboard to 'inherit' variables from."));
            serializedObject.ApplyModifiedProperties();
            GUI.color = Color.white;

            BlackboardEditor.ShowVariables(bb);
            EditorUtils.EndOfInspector();
            if (Event.current.isMouse)
            {
                Repaint();
            }
        }
        public override BlackboardSource OnGUI(GUIContent content, BlackboardSource instance)
        {
            if (instance != null)
            {
                BlackboardEditor.ShowVariables(instance, contextUnityObject);
                return(instance);
            }

            if (GUILayout.Button("Create Blackboard"))
            {
                instance = new BlackboardSource();
            }

            return(instance);
        }
Ejemplo n.º 6
0
        public override void OnInspectorGUI()
        {
            if (Event.current.isMouse)
            {
                Repaint();
            }

            //bb.name = EditorGUILayout.TextField("Name", bb.name);
            BlackboardEditor.ShowVariables(bb, bb);
            EditorUtils.EndOfInspector();
            if (Application.isPlaying)
            {
                Repaint();
            }
        }
        public override void OnInspectorGUI()
        {
            if (Event.current.isMouse)
            {
                Repaint();
            }

            GUI.backgroundColor = GlobalBlackboard.allGlobals.Find(b => b.name == bb.name && b != bb)? Color.red : Color.white;
            bb.name             = EditorGUILayout.TextField("Unique Name", bb.name);
            GUI.backgroundColor = Color.white;

            BlackboardEditor.ShowVariables(bb, bb);
            EditorUtils.EndOfInspector();
            if (Application.isPlaying)
            {
                Repaint();
            }
        }
        public override void OnInspectorGUI()
        {
            EditorGUILayout.PropertyField(identifierProp);
            var existing = GlobalBlackboard.Find(bb.name);

            if (existing != bb && existing != null && !EditorUtility.IsPersistent(bb))
            {
                EditorUtils.MarkLastFieldError("Another Global Blackboard has the same identifier name. Please rename either.");
            }
            EditorGUILayout.PropertyField(dontDestroyProp);

            BlackboardEditor.ShowVariables(bb);
            EditorUtils.EndOfInspector();
            serializedObject.ApplyModifiedProperties();
            if (Event.current.isMouse)
            {
                Repaint();
            }
        }
        public override void OnInspectorGUI()
        {
            var Parent = (Struct)EditorGUILayout.ObjectField("Parent", bb.Parent, typeof(Struct), false);

            if (Parent != bb.Parent && Parent == bb)
            {
                Debug.LogError("The parent node cannot be itself");
            }
            if (Parent != bb)
            {
                bb.Parent = Parent;
            }
            bb.IsStatic = EditorGUILayout.Toggle("Static", bb.IsStatic);
            BlackboardEditor.ShowVariables(bb, bb);
            EditorUtils.EndOfInspector();
            if (Application.isPlaying || Event.current.isMouse)
            {
                Repaint();
            }
        }
Ejemplo n.º 10
0
		//Show the target blackboard window
		static Rect ShowBlackboardGUIPanel(Graph graph, Vector2 canvasMousePos){
			var blackboardPanel = default(Rect);
			if (graph.blackboard == null){
				return blackboardPanel;
			}

			blackboardPanel.xMin = screenWidth - NCPrefs.blackboardPanelWidth;
			blackboardPanel.yMin = 30;
			blackboardPanel.xMax = screenWidth - 20;
			blackboardPanel.height = blackboardPanelHeight;
			
			var resizeRect = Rect.MinMaxRect(blackboardPanel.xMin-2, blackboardPanel.yMin, blackboardPanel.xMin+2, blackboardPanel.yMax);
			EditorGUIUtility.AddCursorRect(resizeRect, MouseCursor.ResizeHorizontal);
			if (e.type == EventType.MouseDown && resizeRect.Contains(e.mousePosition)){isResizingBlackboardPanel = true; e.Use();}
			if (isResizingBlackboardPanel && e.type == EventType.Layout){ NCPrefs.blackboardPanelWidth -= e.delta.x; }
			if (e.rawType == EventType.MouseUp){ isResizingBlackboardPanel = false; }

			var headerRect = new Rect(blackboardPanel.x, blackboardPanel.y, blackboardPanel.width, 30);
			EditorGUIUtility.AddCursorRect(headerRect, MouseCursor.Link);
			if (GUI.Button(headerRect, string.Empty, CanvasStyles.button)){
				NCPrefs.showBlackboard = !NCPrefs.showBlackboard;
			}

			GUI.Box(blackboardPanel, string.Empty, CanvasStyles.windowShadow);
			var title = graph.blackboard == graph.localBlackboard? string.Format("Local {0} Variables", graph.GetType().Name) : "Variables";
			if (NCPrefs.showBlackboard){

				var viewRect = new Rect(blackboardPanel.x, blackboardPanel.y, blackboardPanel.width + 16, screenHeight - blackboardPanel.y - 30);
				var r = new Rect(blackboardPanel.x - 3, blackboardPanel.y, blackboardPanel.width, blackboardPanel.height);
				blackboardPanelScrollPos = GUI.BeginScrollView(viewRect, blackboardPanelScrollPos, r);

				GUILayout.BeginArea(blackboardPanel, title, CanvasStyles.editorPanel);
				GUILayout.Space(5);

				BlackboardEditor.ShowVariables(graph.blackboard, graph.blackboard == graph.localBlackboard? graph : graph.blackboard as Object );
				EditorUtils.EndOfInspector();
				if (e.type == EventType.Repaint){
					blackboardPanelHeight = GUILayoutUtility.GetLastRect().yMax + 5;
				}
				GUILayout.EndArea();
				GUI.EndScrollView();

			} else {

				blackboardPanelHeight = 55;
				GUILayout.BeginArea(blackboardPanel, title, CanvasStyles.editorPanel);
				GUI.color = new Color(1,1,1,0.2f);
				if (GUILayout.Button("...", CanvasStyles.button)){
					NCPrefs.showBlackboard = true;
				}
				GUILayout.EndArea();
				GUI.color = Color.white;
			}
			
			if (graph.canAcceptVariableDrops && BlackboardEditor.pickedVariable != null && BlackboardEditor.pickedVariableBlackboard == graph.blackboard){
				GUI.Label(new Rect(e.mousePosition.x + 15, e.mousePosition.y, 100, 18), "Drop Variable", CanvasStyles.label);
				if (e.type == EventType.MouseUp && !blackboardPanel.Contains(e.mousePosition)){
					graph.CallbackOnVariableDropInGraph(BlackboardEditor.pickedVariable, canvasMousePos);
					BlackboardEditor.ResetPick();
				}
			}

			return blackboardPanel;
		}
        //blackboard inspector panel
        static Rect ShowBlackboardGUIPanel(Graph graph, Vector2 canvasMousePos)
        {
            var blackboardPanel = default(Rect);

            if (graph.blackboard == null)
            {
                blackboardPanelHeight = 0;
                return(blackboardPanel);
            }

            GUI.BeginClip(canvasRect);

            var scrollWidth  = blackboardPanelNeedsScroller ? 16 : 0;
            var posX         = scrollWidth + 5;
            var posY         = PANELS_Y;
            var headerHeight = 30;

            blackboardPanel.x      = canvasRect.xMax - Prefs.blackboardPanelWidth - posX - canvasRect.x;
            blackboardPanel.y      = posY;
            blackboardPanel.width  = Prefs.blackboardPanelWidth;
            blackboardPanel.height = blackboardPanelHeight;

            var resizeRect = Rect.MinMaxRect(blackboardPanel.xMin - 2, blackboardPanel.yMin, blackboardPanel.xMin + 2, blackboardPanel.yMax);

            EditorGUIUtility.AddCursorRect(resizeRect, MouseCursor.ResizeHorizontal);
            if (e.type == EventType.MouseDown && resizeRect.Contains(e.mousePosition))
            {
                isResizingBlackboardPanel = true; e.Use();
            }
            if (isResizingBlackboardPanel && e.type == EventType.Layout)
            {
                Prefs.blackboardPanelWidth -= e.delta.x;
            }
            if (e.rawType == EventType.MouseUp)
            {
                isResizingBlackboardPanel = false;
            }

            var headerRect = new Rect(blackboardPanel.x, blackboardPanel.y, blackboardPanel.width, 30);

            EditorGUIUtility.AddCursorRect(headerRect, MouseCursor.Link);
            if (GUI.Button(headerRect, string.Empty, GUIStyle.none))
            {
                Prefs.showBlackboard = !Prefs.showBlackboard;
            }

            var groupRect = blackboardPanel.ExpandBy(0, 0, scrollWidth, 0);

            GUI.Box(groupRect, string.Empty, StyleSheet.windowShadow);
            GUI.Box(groupRect, "Blackboard Variables", StyleSheet.editorPanel);

            GUI.BeginGroup(groupRect);
            if (Prefs.showBlackboard)
            {
                var contentRect = Rect.MinMaxRect(2, headerHeight, blackboardPanel.width - 2, blackboardPanel.height);
                var position    = Rect.MinMaxRect(0, headerHeight, blackboardPanel.width + scrollWidth, Mathf.Min(blackboardPanel.height, canvasRect.height - posX) + scrollWidth);
                var viewRect    = Rect.MinMaxRect(0, headerHeight, blackboardPanel.width, blackboardPanel.height);
                blackboardPanelNeedsScroller = position.height < viewRect.height;
                blackboardPanelScrollPos     = GUI.BeginScrollView(position, blackboardPanelScrollPos, viewRect, false, false);
                GUILayout.BeginArea(contentRect);

                BlackboardEditor.ShowVariables(graph.blackboard, graph);
                EditorUtils.EndOfInspector();
                if (e.type == EventType.Repaint)
                {
                    blackboardPanelHeight = GUILayoutUtility.GetLastRect().yMax + headerHeight + 5;
                }

                GUILayout.EndArea();
                GUI.EndScrollView();
            }
            else
            {
                blackboardPanelHeight = 55;
                var contentRect = Rect.MinMaxRect(0, headerHeight, blackboardPanel.width, blackboardPanel.height);
                EditorGUIUtility.AddCursorRect(contentRect, MouseCursor.Link);
                if (GUI.Button(contentRect, "<b>...</b>", Styles.centerLabel))
                {
                    Prefs.showBlackboard = true;
                }
            }

            GUI.EndGroup();
            GUI.EndClip();

            blackboardPanel.x += canvasRect.x;
            blackboardPanel.y += canvasRect.y;

            if (graph.canAcceptVariableDrops && BlackboardEditor.pickedVariable != null && BlackboardEditor.pickedVariableBlackboard.IsPartOf(graph.blackboard))
            {
                GUI.Label(new Rect(e.mousePosition.x + 15, e.mousePosition.y, 100, 18), "Drop Variable", StyleSheet.labelOnCanvas);
                if (e.type == EventType.MouseUp && !blackboardPanel.Contains(e.mousePosition))
                {
                    graph.CallbackOnVariableDropInGraph(BlackboardEditor.pickedVariableBlackboard, BlackboardEditor.pickedVariable, canvasMousePos);
                    BlackboardEditor.ResetPick();
                }
            }

            return(blackboardPanel);
        }
 public override void OnInspectorGUI()
 {
     BlackboardEditor.ShowVariables(bb);
     EditorUtils.EndOfInspector();
     Repaint();
 }
Ejemplo n.º 13
0
 public void ShowBlackboardGUI()
 {
     BlackboardEditor.ShowVariables(graph.blackboard, graph);
 }