public void OnGUI()
        {
            if (this.m_Object.targetObject == null)
            {
                this.Init();
            }
            if (NavMeshEditorWindow.s_Styles == null)
            {
                NavMeshEditorWindow.s_Styles = new NavMeshEditorWindow.Styles();
            }
            this.m_Object.Update();
            EditorGUILayout.Space();
            this.ModeToggle();
            EditorGUILayout.Space();
            this.m_ScrollPos = EditorGUILayout.BeginScrollView(this.m_ScrollPos, new GUILayoutOption[0]);
            switch (this.m_Mode)
            {
            case NavMeshEditorWindow.Mode.ObjectSettings:
                NavMeshEditorWindow.ObjectSettings();
                break;

            case NavMeshEditorWindow.Mode.BakeSettings:
                this.BakeSettings();
                break;

            case NavMeshEditorWindow.Mode.AreaSettings:
                this.AreaSettings();
                break;
            }
            EditorGUILayout.EndScrollView();
            NavMeshEditorWindow.BakeButtons();
            this.m_Object.ApplyModifiedProperties();
        }
示例#2
0
 public void OnGUI()
 {
     EditorGUILayout.Space();
     this.ModeToggle();
     EditorGUILayout.Space();
     this.InitProjectSettings();
     this.m_ScrollPos = EditorGUILayout.BeginScrollView(this.m_ScrollPos, new GUILayoutOption[0]);
     NavMeshEditorWindow.Mode mode = this.m_Mode;
     if (mode != NavMeshEditorWindow.Mode.ObjectSettings)
     {
         if (mode != NavMeshEditorWindow.Mode.SceneBakeSettings)
         {
             if (mode == NavMeshEditorWindow.Mode.AreaSettings)
             {
                 this.AreaSettings();
             }
         }
         else
         {
             this.SceneBakeSettings();
         }
     }
     else
     {
         NavMeshEditorWindow.ObjectSettings();
     }
     EditorGUILayout.EndScrollView();
     NavMeshEditorWindow.BakeButtons();
 }
示例#3
0
        private static IEnumerable <GameObject> GetObjectsRecurse(GameObject root)
        {
            List <GameObject> list = new List <GameObject>
            {
                root
            };
            IEnumerator enumerator = root.transform.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    Transform transform = (Transform)enumerator.Current;
                    list.AddRange(NavMeshEditorWindow.GetObjectsRecurse(transform.gameObject));
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
            return(list);
        }
示例#4
0
        private static void ObjectSettings()
        {
            bool flag = true;

            SceneModeUtility.SearchBar(new Type[]
            {
                typeof(MeshRenderer),
                typeof(Terrain)
            });
            EditorGUILayout.Space();
            GameObject[]   array;
            MeshRenderer[] selectedObjectsOfType = SceneModeUtility.GetSelectedObjectsOfType <MeshRenderer>(out array, new Type[0]);
            if (array.Length > 0)
            {
                flag = false;
                NavMeshEditorWindow.ObjectSettings(selectedObjectsOfType, array);
            }
            Terrain[] selectedObjectsOfType2 = SceneModeUtility.GetSelectedObjectsOfType <Terrain>(out array, new Type[0]);
            if (array.Length > 0)
            {
                flag = false;
                NavMeshEditorWindow.ObjectSettings(selectedObjectsOfType2, array);
            }
            if (flag)
            {
                GUILayout.Label("Select a MeshRenderer or a Terrain from the scene.", EditorStyles.helpBox, new GUILayoutOption[0]);
            }
        }
示例#5
0
        private static void ObjectSettings()
        {
            bool flag = true;

            SceneModeUtility.SearchBar(typeof(MeshRenderer), typeof(Terrain));
            EditorGUILayout.Space();
            GameObject[]   gameObjects;
            MeshRenderer[] selectedObjectsOfType1 = SceneModeUtility.GetSelectedObjectsOfType <MeshRenderer>(out gameObjects);
            if (gameObjects.Length > 0)
            {
                flag = false;
                NavMeshEditorWindow.ObjectSettings((UnityEngine.Object[])selectedObjectsOfType1, gameObjects);
            }
            Terrain[] selectedObjectsOfType2 = SceneModeUtility.GetSelectedObjectsOfType <Terrain>(out gameObjects);
            if (gameObjects.Length > 0)
            {
                flag = false;
                NavMeshEditorWindow.ObjectSettings((UnityEngine.Object[])selectedObjectsOfType2, gameObjects);
            }
            if (!flag)
            {
                return;
            }
            GUILayout.Label("Select a MeshRenderer or a Terrain from the scene.", EditorStyles.helpBox, new GUILayoutOption[0]);
        }
示例#6
0
 public void OnEnable()
 {
     base.titleContent = base.GetLocalizedTitleContent();
     NavMeshEditorWindow.s_NavMeshEditorWindow = this;
     EditorApplication.searchChanged           = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.searchChanged, new EditorApplication.CallbackFunction(base.Repaint));
     SceneView.onSceneGUIDelegate = (SceneView.OnSceneFunc)Delegate.Combine(SceneView.onSceneGUIDelegate, new SceneView.OnSceneFunc(this.OnSceneViewGUI));
     this.UpdateSelectedAgentAndObstacleState();
     base.Repaint();
 }
		public void OnEnable()
		{
			NavMeshEditorWindow.s_NavMeshEditorWindow = this;
			this.Init();
			EditorApplication.searchChanged = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.searchChanged, new EditorApplication.CallbackFunction(base.Repaint));
			SceneView.onSceneGUIDelegate = (SceneView.OnSceneFunc)Delegate.Combine(SceneView.onSceneGUIDelegate, new SceneView.OnSceneFunc(this.OnSceneViewGUI));
			this.UpdateSelectedAgentAndObstacleState();
			base.Repaint();
		}
示例#8
0
 public void OnBecameInvisible()
 {
     if (this.m_BecameVisibleCalled)
     {
         NavMeshVisualizationSettings.showNavigation--;
         NavMeshEditorWindow.RepaintSceneAndGameViews();
         this.m_BecameVisibleCalled = false;
     }
 }
 public void OnBecameVisible()
 {
     if (NavMeshVisualizationSettings.showNavigation)
     {
         return;
     }
     NavMeshVisualizationSettings.showNavigation = true;
     NavMeshEditorWindow.RepaintSceneAndGameViews();
 }
示例#10
0
        public static void SetupWindow()
        {
            NavMeshEditorWindow window = EditorWindow.GetWindow <NavMeshEditorWindow>(new Type[]
            {
                typeof(InspectorWindow)
            });

            window.minSize = new Vector2(300f, 360f);
        }
        public static void SetupWindow()
        {
            NavMeshEditorWindow window = EditorWindow.GetWindow <NavMeshEditorWindow>(new Type[]
            {
                typeof(InspectorWindow)
            });

            window.title   = EditorGUIUtility.TextContent("NavmeshEditor.WindowTitle").text;
            window.minSize = new Vector2(300f, 360f);
        }
示例#12
0
 public void OnEnable()
 {
     this.titleContent = this.GetLocalizedTitleContent();
     NavMeshEditorWindow.s_NavMeshEditorWindow = this;
     this.Init();
     EditorApplication.searchChanged += new EditorApplication.CallbackFunction(((EditorWindow)this).Repaint);
     SceneView.onSceneGUIDelegate    += new SceneView.OnSceneFunc(this.OnSceneViewGUI);
     this.UpdateSelectedAgentAndObstacleState();
     this.Repaint();
 }
 public void OnEnable()
 {
   this.titleContent = this.GetLocalizedTitleContent();
   NavMeshEditorWindow.s_NavMeshEditorWindow = this;
   this.Init();
   EditorApplication.searchChanged += new EditorApplication.CallbackFunction(((EditorWindow) this).Repaint);
   SceneView.onSceneGUIDelegate += new SceneView.OnSceneFunc(this.OnSceneViewGUI);
   this.UpdateSelectedAgentAndObstacleState();
   this.Repaint();
 }
示例#14
0
        private static void DisplayControls(UnityEngine.Object target, SceneView sceneView)
        {
            EditorGUIUtility.labelWidth = 150f;
            bool flag        = false;
            bool showNavMesh = NavMeshVisualizationSettings.showNavMesh;

            if (showNavMesh != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("Show NavMesh"), showNavMesh, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showNavMesh = !showNavMesh;
                flag = true;
            }
            EditorGUI.BeginDisabledGroup(!NavMeshVisualizationSettings.hasHeightMesh);
            bool showHeightMesh = NavMeshVisualizationSettings.showHeightMesh;

            if (showHeightMesh != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("Show HeightMesh"), showHeightMesh, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showHeightMesh = !showHeightMesh;
                flag = true;
            }
            EditorGUI.EndDisabledGroup();
            if (Unsupported.IsDeveloperBuild())
            {
                GUILayout.Label("Internal");
                bool showNavMeshPortals = NavMeshVisualizationSettings.showNavMeshPortals;
                if (showNavMeshPortals != EditorGUILayout.Toggle(new GUIContent("Show NavMesh Portals"), showNavMeshPortals, new GUILayoutOption[0]))
                {
                    NavMeshVisualizationSettings.showNavMeshPortals = !showNavMeshPortals;
                    flag = true;
                }
                bool showNavMeshLinks = NavMeshVisualizationSettings.showNavMeshLinks;
                if (showNavMeshLinks != EditorGUILayout.Toggle(new GUIContent("Show NavMesh Links"), showNavMeshLinks, new GUILayoutOption[0]))
                {
                    NavMeshVisualizationSettings.showNavMeshLinks = !showNavMeshLinks;
                    flag = true;
                }
                bool showProximityGrid = NavMeshVisualizationSettings.showProximityGrid;
                if (showProximityGrid != EditorGUILayout.Toggle(new GUIContent("Show Proximity Grid"), showProximityGrid, new GUILayoutOption[0]))
                {
                    NavMeshVisualizationSettings.showProximityGrid = !showProximityGrid;
                    flag = true;
                }
                bool heightMeshBvTree = NavMeshVisualizationSettings.showHeightMeshBVTree;
                if (heightMeshBvTree != EditorGUILayout.Toggle(new GUIContent("Show HeightMesh BV-Tree"), heightMeshBvTree, new GUILayoutOption[0]))
                {
                    NavMeshVisualizationSettings.showHeightMeshBVTree = !heightMeshBvTree;
                    flag = true;
                }
            }
            if (!flag)
            {
                return;
            }
            NavMeshEditorWindow.RepaintSceneAndGameViews();
        }
示例#15
0
        public void OnEnable()
        {
            titleContent                     = GetLocalizedTitleContent();
            s_NavMeshEditorWindow            = this;
            EditorApplication.searchChanged += Repaint;
            SceneView.onSceneGUIDelegate    += OnSceneViewGUI;

            UpdateSelectedAgentAndObstacleState();

            Repaint();
        }
        private static IEnumerable <GameObject> GetObjectsRecurse(GameObject root)
        {
            List <GameObject> list = new List <GameObject>
            {
                root
            };

            foreach (Transform transform in root.transform)
            {
                list.AddRange(NavMeshEditorWindow.GetObjectsRecurse(transform.gameObject));
            }
            return(list);
        }
示例#17
0
 public void OnBecameVisible()
 {
     if (!this.m_BecameVisibleCalled)
     {
         bool flag = NavMeshVisualizationSettings.showNavigation == 0;
         NavMeshVisualizationSettings.showNavigation++;
         if (flag)
         {
             NavMeshEditorWindow.RepaintSceneAndGameViews();
         }
         this.m_BecameVisibleCalled = true;
     }
 }
示例#18
0
        private static void SetNavMeshArea(int area, bool includeChildren)
        {
            List <GameObject> objects = NavMeshEditorWindow.GetObjects(includeChildren);

            if (objects.Count > 0)
            {
                Undo.RecordObjects(objects.ToArray(), "Change NavMesh area");
                foreach (GameObject current in objects)
                {
                    GameObjectUtility.SetNavMeshArea(current, area);
                }
            }
        }
示例#19
0
        private static List <GameObject> GetObjects(bool includeChildren)
        {
            if (!includeChildren)
            {
                return(new List <GameObject>((IEnumerable <GameObject>)Selection.gameObjects));
            }
            List <GameObject> gameObjectList = new List <GameObject>();

            foreach (GameObject gameObject in Selection.gameObjects)
            {
                gameObjectList.AddRange(NavMeshEditorWindow.GetObjectsRecurse(gameObject));
            }
            return(gameObjectList);
        }
 private static List <GameObject> GetObjects(bool includeChildren)
 {
     if (includeChildren)
     {
         List <GameObject> list        = new List <GameObject>();
         GameObject[]      gameObjects = Selection.gameObjects;
         for (int i = 0; i < gameObjects.Length; i++)
         {
             GameObject root = gameObjects[i];
             list.AddRange(NavMeshEditorWindow.GetObjectsRecurse(root));
         }
         return(list);
     }
     return(new List <GameObject>(Selection.gameObjects));
 }
示例#21
0
        public void OnEnable()
        {
            titleContent                     = GetLocalizedTitleContent();
            s_NavMeshEditorWindow            = this;
            EditorApplication.searchChanged += Repaint;
            SceneView.duringSceneGui        += OnSceneViewGUI;

            UpdateSelectedAgentAndObstacleState();

            Repaint();


            m_DisplayControlsOverlayWindow         = new OverlayWindow(EditorGUIUtility.TrTextContent("Navmesh Display"), DisplayControls, (int)SceneViewOverlay.Ordering.NavMesh, null, SceneViewOverlay.WindowDisplayOption.OneWindowPerTarget);
            m_DisplayAgentControlsOverlayWindow    = new OverlayWindow(EditorGUIUtility.TrTextContent("Agent Display"), DisplayAgentControls, (int)SceneViewOverlay.Ordering.NavMesh, null, SceneViewOverlay.WindowDisplayOption.OneWindowPerTarget);
            m_DisplayObstacleControlsOverlayWindow = new OverlayWindow(EditorGUIUtility.TrTextContent("Obstacle Display"), DisplayObstacleControls, (int)SceneViewOverlay.Ordering.NavMesh, null, SceneViewOverlay.WindowDisplayOption.OneWindowPerTarget);
        }
示例#22
0
        private static void DisplayObstacleControls(UnityEngine.Object target, SceneView sceneView)
        {
            EditorGUIUtility.labelWidth = 150f;
            bool flag = false;
            bool showObstacleCarveHull = NavMeshVisualizationSettings.showObstacleCarveHull;

            if (showObstacleCarveHull != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("Show Carve Hull|Shows the hull used to carve the obstacle from navmesh."), showObstacleCarveHull, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showObstacleCarveHull = !showObstacleCarveHull;
                flag = true;
            }
            if (flag)
            {
                NavMeshEditorWindow.RepaintSceneAndGameViews();
            }
        }
示例#23
0
        private static void SetNavMeshArea(int area, bool includeChildren)
        {
            List <GameObject> objects = NavMeshEditorWindow.GetObjects(includeChildren);

            if (objects.Count <= 0)
            {
                return;
            }
            Undo.RecordObjects((UnityEngine.Object[])objects.ToArray(), "Change NavMesh area");
            using (List <GameObject> .Enumerator enumerator = objects.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    GameObjectUtility.SetNavMeshArea(enumerator.Current, area);
                }
            }
        }
示例#24
0
 private void OnInspectorUpdate()
 {
     if (this.m_SelectedNavMeshAgentCount > 0)
     {
         if (this.m_HasPendingAgentDebugInfo != NavMeshVisualizationSettings.hasPendingAgentDebugInfo)
         {
             if (!this.m_HasRepaintedForPendingAgentDebugInfo)
             {
                 this.m_HasRepaintedForPendingAgentDebugInfo = true;
                 NavMeshEditorWindow.RepaintSceneAndGameViews();
             }
         }
         else
         {
             this.m_HasRepaintedForPendingAgentDebugInfo = false;
         }
     }
 }
        private static void ObjectSettings(UnityEngine.Object[] components, GameObject[] gos)
        {
            EditorGUILayout.MultiSelectionObjectTitleBar(components);
            SerializedObject serializedObject = new SerializedObject(gos);

            EditorGUI.BeginDisabledGroup(!SceneModeUtility.StaticFlagField("Navigation Static", serializedObject.FindProperty("m_StaticEditorFlags"), 8));
            SceneModeUtility.StaticFlagField("Generate OffMeshLinks", serializedObject.FindProperty("m_StaticEditorFlags"), 32);
            SerializedProperty serializedProperty = serializedObject.FindProperty("m_NavMeshLayer");

            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = serializedProperty.hasMultipleDifferentValues;
            string[] navMeshAreaNames = GameObjectUtility.GetNavMeshAreaNames();
            int      navMeshArea      = GameObjectUtility.GetNavMeshArea(gos[0]);
            int      selectedIndex    = -1;

            for (int i = 0; i < navMeshAreaNames.Length; i++)
            {
                if (GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[i]) == navMeshArea)
                {
                    selectedIndex = i;
                    break;
                }
            }
            int num = EditorGUILayout.Popup("Navigation Area", selectedIndex, navMeshAreaNames, new GUILayoutOption[0]);

            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                int navMeshAreaFromName = GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[num]);
                GameObjectUtility.ShouldIncludeChildren shouldIncludeChildren = GameObjectUtility.DisplayUpdateChildrenDialogIfNeeded(Selection.gameObjects, "Change Navigation Area", "Do you want change the navigation area to " + navMeshAreaNames[num] + " for all the child objects as well?");
                if (shouldIncludeChildren != GameObjectUtility.ShouldIncludeChildren.Cancel)
                {
                    serializedProperty.intValue = navMeshAreaFromName;
                    NavMeshEditorWindow.SetNavMeshArea(navMeshAreaFromName, shouldIncludeChildren == GameObjectUtility.ShouldIncludeChildren.IncludeChildren);
                }
            }
            EditorGUI.EndDisabledGroup();
            serializedObject.ApplyModifiedProperties();
        }
示例#26
0
 public void OnDisable()
 {
     s_NavMeshEditorWindow            = null;
     EditorApplication.searchChanged -= Repaint;
     SceneView.onSceneGUIDelegate    -= OnSceneViewGUI;
 }
 public void OnBecameInvisible()
 {
     NavMeshVisualizationSettings.showNavigation = false;
     NavMeshEditorWindow.RepaintSceneAndGameViews();
 }
示例#28
0
 public void OnDisable()
 {
     s_NavMeshEditorWindow            = null;
     EditorApplication.searchChanged -= Repaint;
     SceneView.duringSceneGui        -= OnSceneViewGUI;
 }
        private static void DisplayAgentControls(UnityEngine.Object target, SceneView sceneView)
        {
            EditorGUIUtility.labelWidth = 150f;
            bool flag = false;

            if (Event.current.type == EventType.Layout)
            {
                NavMeshEditorWindow.s_NavMeshEditorWindow.m_HasPendingAgentDebugInfo = NavMeshVisualizationSettings.hasPendingAgentDebugInfo;
            }
            bool showAgentPath = NavMeshVisualizationSettings.showAgentPath;

            if (showAgentPath != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("NavMeshEditorWindow.ShowAgentPath"), showAgentPath, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showAgentPath = !showAgentPath;
                flag = true;
            }
            bool showAgentPathInfo = NavMeshVisualizationSettings.showAgentPathInfo;

            if (showAgentPathInfo != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("NavMeshEditorWindow.ShowAgentPathInfo"), showAgentPathInfo, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showAgentPathInfo = !showAgentPathInfo;
                flag = true;
            }
            bool showAgentNeighbours = NavMeshVisualizationSettings.showAgentNeighbours;

            if (showAgentNeighbours != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("NavMeshEditorWindow.ShowAgentNeighbours"), showAgentNeighbours, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showAgentNeighbours = !showAgentNeighbours;
                flag = true;
            }
            bool showAgentWalls = NavMeshVisualizationSettings.showAgentWalls;

            if (showAgentWalls != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("NavMeshEditorWindow.ShowAgentWalls"), showAgentWalls, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showAgentWalls = !showAgentWalls;
                flag = true;
            }
            bool showAgentAvoidance = NavMeshVisualizationSettings.showAgentAvoidance;

            if (showAgentAvoidance != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("NavMeshEditorWindow.ShowAgentAvoidance"), showAgentAvoidance, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showAgentAvoidance = !showAgentAvoidance;
                flag = true;
            }
            if (showAgentAvoidance)
            {
                if (NavMeshEditorWindow.s_NavMeshEditorWindow.m_HasPendingAgentDebugInfo)
                {
                    EditorGUILayout.BeginVertical(new GUILayoutOption[]
                    {
                        GUILayout.MaxWidth(165f)
                    });
                    EditorGUILayout.HelpBox("Avoidance display is not valid until after next game update.", MessageType.Warning);
                    EditorGUILayout.EndVertical();
                }
                if (NavMeshEditorWindow.s_NavMeshEditorWindow.m_SelectedNavMeshAgentCount > 10)
                {
                    EditorGUILayout.BeginVertical(new GUILayoutOption[]
                    {
                        GUILayout.MaxWidth(165f)
                    });
                    EditorGUILayout.HelpBox(string.Concat(new object[]
                    {
                        "Avoidance visualization can be drawn for ",
                        10,
                        " agents (",
                        NavMeshEditorWindow.s_NavMeshEditorWindow.m_SelectedNavMeshAgentCount,
                        " selected)."
                    }), MessageType.Warning);
                    EditorGUILayout.EndVertical();
                }
            }
            if (flag)
            {
                NavMeshEditorWindow.RepaintSceneAndGameViews();
            }
        }
示例#30
0
 public void OnDisable()
 {
     NavMeshEditorWindow.s_NavMeshEditorWindow = null;
     EditorApplication.searchChanged           = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.searchChanged, new EditorApplication.CallbackFunction(base.Repaint));
     SceneView.onSceneGUIDelegate = (SceneView.OnSceneFunc)Delegate.Remove(SceneView.onSceneGUIDelegate, new SceneView.OnSceneFunc(this.OnSceneViewGUI));
 }
示例#31
0
        private static void DisplayAgentControls(UnityEngine.Object target, SceneView sceneView)
        {
            EditorGUIUtility.labelWidth = 150f;
            bool flag = false;

            if (Event.current.type == EventType.Layout)
            {
                NavMeshEditorWindow.s_NavMeshEditorWindow.m_HasPendingAgentDebugInfo = NavMeshVisualizationSettings.hasPendingAgentDebugInfo;
            }
            bool showAgentPath = NavMeshVisualizationSettings.showAgentPath;

            if (showAgentPath != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("Show Path Polygons|Shows the polygons leading to goal."), showAgentPath, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showAgentPath = !showAgentPath;
                flag = true;
            }
            bool showAgentPathInfo = NavMeshVisualizationSettings.showAgentPathInfo;

            if (showAgentPathInfo != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("Show Path Query Nodes|Shows the nodes expanded during last path query."), showAgentPathInfo, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showAgentPathInfo = !showAgentPathInfo;
                flag = true;
            }
            bool showAgentNeighbours = NavMeshVisualizationSettings.showAgentNeighbours;

            if (showAgentNeighbours != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("Show Neighbours|Show the agent neighbours cosidered during simulation."), showAgentNeighbours, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showAgentNeighbours = !showAgentNeighbours;
                flag = true;
            }
            bool showAgentWalls = NavMeshVisualizationSettings.showAgentWalls;

            if (showAgentWalls != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("Show Walls|Shows the wall segments handled during simulation."), showAgentWalls, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showAgentWalls = !showAgentWalls;
                flag = true;
            }
            bool showAgentAvoidance = NavMeshVisualizationSettings.showAgentAvoidance;

            if (showAgentAvoidance != EditorGUILayout.Toggle(EditorGUIUtility.TextContent("Show Avoidance|Shows the processed avoidance geometry from simulation."), showAgentAvoidance, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showAgentAvoidance = !showAgentAvoidance;
                flag = true;
            }
            if (showAgentAvoidance)
            {
                if (NavMeshEditorWindow.s_NavMeshEditorWindow.m_HasPendingAgentDebugInfo)
                {
                    EditorGUILayout.BeginVertical(new GUILayoutOption[]
                    {
                        GUILayout.MaxWidth(165f)
                    });
                    EditorGUILayout.HelpBox("Avoidance display is not valid until after next game update.", MessageType.Warning);
                    EditorGUILayout.EndVertical();
                }
                if (NavMeshEditorWindow.s_NavMeshEditorWindow.m_SelectedNavMeshAgentCount > 10)
                {
                    EditorGUILayout.BeginVertical(new GUILayoutOption[]
                    {
                        GUILayout.MaxWidth(165f)
                    });
                    EditorGUILayout.HelpBox(string.Concat(new object[]
                    {
                        "Avoidance visualization can be drawn for ",
                        10,
                        " agents (",
                        NavMeshEditorWindow.s_NavMeshEditorWindow.m_SelectedNavMeshAgentCount,
                        " selected)."
                    }), MessageType.Warning);
                    EditorGUILayout.EndVertical();
                }
            }
            if (flag)
            {
                NavMeshEditorWindow.RepaintSceneAndGameViews();
            }
        }
		public void OnDisable()
		{
			NavMeshEditorWindow.s_NavMeshEditorWindow = null;
			EditorApplication.searchChanged = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.searchChanged, new EditorApplication.CallbackFunction(base.Repaint));
			SceneView.onSceneGUIDelegate = (SceneView.OnSceneFunc)Delegate.Remove(SceneView.onSceneGUIDelegate, new SceneView.OnSceneFunc(this.OnSceneViewGUI));
		}
示例#33
0
        private void BakeSettings()
        {
            EditorGUILayout.LabelField(NavMeshEditorWindow.s_Styles.m_AgentSizeHeader, EditorStyles.boldLabel, new GUILayoutOption[0]);
            this.DrawAgentDiagram(EditorGUILayout.GetControlRect(false, 120f, new GUILayoutOption[0]), this.m_AgentRadius.floatValue, this.m_AgentHeight.floatValue, this.m_AgentClimb.floatValue, this.m_AgentSlope.floatValue);
            float num1 = EditorGUILayout.FloatField(NavMeshEditorWindow.s_Styles.m_AgentRadiusContent, this.m_AgentRadius.floatValue, new GUILayoutOption[0]);

            if ((double)num1 >= 1.0 / 1000.0 && !Mathf.Approximately(num1 - this.m_AgentRadius.floatValue, 0.0f))
            {
                this.m_AgentRadius.floatValue = num1;
                if (!this.m_ManualCellSize.boolValue)
                {
                    this.m_CellSize.floatValue = (float)(2.0 * (double)this.m_AgentRadius.floatValue / 6.0);
                }
            }
            if ((double)this.m_AgentRadius.floatValue < 0.0500000007450581 && !this.m_ManualCellSize.boolValue)
            {
                EditorGUILayout.HelpBox("The agent radius you've set is really small, this can slow down the build.\nIf you intended to allow the agent to move close to the borders and walls, please adjust voxel size in advaced settings to ensure correct bake.", MessageType.Warning);
            }
            float num2 = EditorGUILayout.FloatField(NavMeshEditorWindow.s_Styles.m_AgentHeightContent, this.m_AgentHeight.floatValue, new GUILayoutOption[0]);

            if ((double)num2 >= 1.0 / 1000.0 && !Mathf.Approximately(num2 - this.m_AgentHeight.floatValue, 0.0f))
            {
                this.m_AgentHeight.floatValue = num2;
            }
            EditorGUILayout.Slider(this.m_AgentSlope, 0.0f, 60f, NavMeshEditorWindow.s_Styles.m_AgentSlopeContent, new GUILayoutOption[0]);
            if ((double)this.m_AgentSlope.floatValue > 60.0)
            {
                EditorGUILayout.HelpBox("The maximum slope should be set to less than " + (object)60f + " degrees to prevent NavMesh build artifacts on slopes. ", MessageType.Warning);
            }
            float num3 = EditorGUILayout.FloatField(NavMeshEditorWindow.s_Styles.m_AgentClimbContent, this.m_AgentClimb.floatValue, new GUILayoutOption[0]);

            if ((double)num3 >= 0.0 && !Mathf.Approximately(this.m_AgentClimb.floatValue - num3, 0.0f))
            {
                this.m_AgentClimb.floatValue = num3;
            }
            if ((double)this.m_AgentClimb.floatValue > (double)this.m_AgentHeight.floatValue)
            {
                EditorGUILayout.HelpBox("Step height should be less than agent height.\nClamping step height to " + (object)this.m_AgentHeight.floatValue + " internally when baking.", MessageType.Warning);
            }
            float floatValue = this.m_CellSize.floatValue;
            float num4       = floatValue * 0.5f;
            int   num5       = (int)Mathf.Ceil(this.m_AgentClimb.floatValue / num4);
            int   num6       = (int)Mathf.Ceil(Mathf.Tan((float)((double)this.m_AgentSlope.floatValue / 180.0 * 3.14159274101257)) * floatValue * 2f / num4);

            if (num6 > num5)
            {
                EditorGUILayout.HelpBox("Step Height conflicts with Max Slope. This makes some slopes unwalkable.\nConsider decreasing Max Slope to < " + ((float)((double)Mathf.Atan((float)((double)num5 * (double)num4 / ((double)floatValue * 2.0))) / 3.14159274101257 * 180.0)).ToString("0.0") + " degrees.\nOr, increase Step Height to > " + ((float)(num6 - 1) * num4).ToString("0.00") + ".", MessageType.Warning);
            }
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(NavMeshEditorWindow.s_Styles.m_OffmeshHeader, EditorStyles.boldLabel, new GUILayoutOption[0]);
            float num7 = EditorGUILayout.FloatField(NavMeshEditorWindow.s_Styles.m_AgentDropContent, this.m_LedgeDropHeight.floatValue, new GUILayoutOption[0]);

            if ((double)num7 >= 0.0 && !Mathf.Approximately(num7 - this.m_LedgeDropHeight.floatValue, 0.0f))
            {
                this.m_LedgeDropHeight.floatValue = num7;
            }
            float num8 = EditorGUILayout.FloatField(NavMeshEditorWindow.s_Styles.m_AgentJumpContent, this.m_MaxJumpAcrossDistance.floatValue, new GUILayoutOption[0]);

            if ((double)num8 >= 0.0 && !Mathf.Approximately(num8 - this.m_MaxJumpAcrossDistance.floatValue, 0.0f))
            {
                this.m_MaxJumpAcrossDistance.floatValue = num8;
            }
            EditorGUILayout.Space();
            this.m_Advanced = GUILayout.Toggle(this.m_Advanced, NavMeshEditorWindow.s_Styles.m_AdvancedHeader, EditorStyles.foldout, new GUILayoutOption[0]);
            if (this.m_Advanced)
            {
                ++EditorGUI.indentLevel;
                bool flag1 = EditorGUILayout.Toggle(NavMeshEditorWindow.s_Styles.m_ManualCellSizeContent, this.m_ManualCellSize.boolValue, new GUILayoutOption[0]);
                if (flag1 != this.m_ManualCellSize.boolValue)
                {
                    this.m_ManualCellSize.boolValue = flag1;
                    if (!flag1)
                    {
                        this.m_CellSize.floatValue = (float)(2.0 * (double)this.m_AgentRadius.floatValue / 6.0);
                    }
                }
                EditorGUI.BeginDisabledGroup(!this.m_ManualCellSize.boolValue);
                ++EditorGUI.indentLevel;
                float val2 = EditorGUILayout.FloatField(NavMeshEditorWindow.s_Styles.m_CellSizeContent, this.m_CellSize.floatValue, new GUILayoutOption[0]);
                if ((double)val2 > 0.0 && !Mathf.Approximately(val2 - this.m_CellSize.floatValue, 0.0f))
                {
                    this.m_CellSize.floatValue = Math.Max(0.01f, val2);
                }
                if ((double)val2 < 0.00999999977648258)
                {
                    EditorGUILayout.HelpBox("The voxel size should be larger than 0.01.", MessageType.Warning);
                }
                float num9 = (double)this.m_CellSize.floatValue <= 0.0 ? 0.0f : this.m_AgentRadius.floatValue / this.m_CellSize.floatValue;
                EditorGUILayout.LabelField(" ", num9.ToString("0.00") + " voxels per agent radius", EditorStyles.miniLabel, new GUILayoutOption[0]);
                if (this.m_ManualCellSize.boolValue)
                {
                    if ((int)Mathf.Floor(this.m_AgentHeight.floatValue / (this.m_CellSize.floatValue * 0.5f)) > 250)
                    {
                        EditorGUILayout.HelpBox("The number of voxels per agent height is too high. This will reduce the accuracy of the navmesh. Consider using voxel size of at least " + ((float)((double)this.m_AgentHeight.floatValue / 250.0 / 0.5)).ToString("0.000") + ".", MessageType.Warning);
                    }
                    if ((double)num9 < 1.0)
                    {
                        EditorGUILayout.HelpBox("The number of voxels per agent radius is too small. The agent may not avoid walls and ledges properly. Consider using voxel size of at least " + (this.m_AgentRadius.floatValue / 2f).ToString("0.000") + " (2 voxels per agent radius).", MessageType.Warning);
                    }
                    else if ((double)num9 > 8.0)
                    {
                        EditorGUILayout.HelpBox("The number of voxels per agent radius is too high. It can cause excessive build times. Consider using voxel size closer to " + (this.m_AgentRadius.floatValue / 8f).ToString("0.000") + " (8 voxels per radius).", MessageType.Warning);
                    }
                }
                if (this.m_ManualCellSize.boolValue)
                {
                    EditorGUILayout.HelpBox("Voxel size controls how accurately the navigation mesh is generated from the level geometry. A good voxel size is 2-4 voxels per agent radius. Making voxel size smaller will increase build time.", MessageType.None);
                }
                --EditorGUI.indentLevel;
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.Space();
                float num10 = EditorGUILayout.FloatField(NavMeshEditorWindow.s_Styles.m_MinRegionAreaContent, this.m_MinRegionArea.floatValue, new GUILayoutOption[0]);
                if ((double)num10 >= 0.0 && (double)num10 != (double)this.m_MinRegionArea.floatValue)
                {
                    this.m_MinRegionArea.floatValue = num10;
                }
                EditorGUILayout.Space();
                bool flag2 = EditorGUILayout.Toggle(NavMeshEditorWindow.s_Styles.m_AgentPlacementContent, this.m_AccuratePlacement.boolValue, new GUILayoutOption[0]);
                if (flag2 != this.m_AccuratePlacement.boolValue)
                {
                    this.m_AccuratePlacement.boolValue = flag2;
                }
                --EditorGUI.indentLevel;
            }
            if (!Unsupported.IsDeveloperBuild())
            {
                return;
            }
            EditorGUILayout.Space();
            GUILayout.Label("Internal Bake Debug Options", EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorGUILayout.HelpBox("Note: The debug visualization is build during bake, so you'll need to bake for these settings to take effect.", MessageType.None);
            bool meshLinkSampling = NavMeshVisualizationSettings.showAutoOffMeshLinkSampling;

            if (meshLinkSampling != EditorGUILayout.Toggle(new GUIContent("Show Auto-Off-MeshLink Sampling"), meshLinkSampling, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showAutoOffMeshLinkSampling = !meshLinkSampling;
            }
            bool showVoxels = NavMeshVisualizationSettings.showVoxels;

            if (showVoxels != EditorGUILayout.Toggle(new GUIContent("Show Voxels"), showVoxels, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showVoxels = !showVoxels;
            }
            bool showWalkable = NavMeshVisualizationSettings.showWalkable;

            if (showWalkable != EditorGUILayout.Toggle(new GUIContent("Show Walkable"), showWalkable, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showWalkable = !showWalkable;
            }
            bool showRawContours = NavMeshVisualizationSettings.showRawContours;

            if (showRawContours != EditorGUILayout.Toggle(new GUIContent("Show Raw Contours"), showRawContours, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showRawContours = !showRawContours;
            }
            bool showContours = NavMeshVisualizationSettings.showContours;

            if (showContours != EditorGUILayout.Toggle(new GUIContent("Show Contours"), showContours, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showContours = !showContours;
            }
            bool showInputs = NavMeshVisualizationSettings.showInputs;

            if (showInputs != EditorGUILayout.Toggle(new GUIContent("Show Inputs"), showInputs, new GUILayoutOption[0]))
            {
                NavMeshVisualizationSettings.showInputs = !showInputs;
            }
            if (GUILayout.Button("Clear Visualiation Data"))
            {
                NavMeshVisualizationSettings.ClearVisualizationData();
                NavMeshEditorWindow.RepaintSceneAndGameViews();
            }
            EditorGUILayout.Space();
        }
 public void OnDisable()
 {
   NavMeshEditorWindow.s_NavMeshEditorWindow = (NavMeshEditorWindow) null;
   EditorApplication.searchChanged -= new EditorApplication.CallbackFunction(((EditorWindow) this).Repaint);
   SceneView.onSceneGUIDelegate -= new SceneView.OnSceneFunc(this.OnSceneViewGUI);
 }