Пример #1
0
        private static void BakeButtons()
        {
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            bool enabled = GUI.enabled;

            GUI.enabled &= !Application.isPlaying;
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(95f) };
            if (GUILayout.Button("Clear", options))
            {
                NavMeshBuilder.ClearAllNavMeshes();
            }
            GUI.enabled = enabled;
            if (NavMeshBuilder.isRunning)
            {
                GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(95f) };
                if (GUILayout.Button("Cancel", optionArray2))
                {
                    NavMeshBuilder.Cancel();
                }
            }
            else
            {
                enabled      = GUI.enabled;
                GUI.enabled &= !Application.isPlaying;
                GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width(95f) };
                if (GUILayout.Button("Bake", optionArray3))
                {
                    NavMeshBuilder.BuildNavMeshAsync();
                }
                GUI.enabled = enabled;
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
Пример #2
0
 /// <summary>
 ///   <para>Builds the combined navmesh for the contents of multiple scenes.</para>
 /// </summary>
 /// <param name="paths">Array of paths to scenes that are used for building the navmesh.</param>
 public static void BuildNavMeshForMultipleScenes(string[] paths)
 {
     if (paths.Length == 0)
     {
         return;
     }
     for (int index1 = 0; index1 < paths.Length; ++index1)
     {
         for (int index2 = index1 + 1; index2 < paths.Length; ++index2)
         {
             if (paths[index1] == paths[index2])
             {
                 throw new Exception("No duplicate scene names are allowed");
             }
         }
     }
     if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
     {
         return;
     }
     if (!EditorSceneManager.OpenScene(paths[0]).IsValid())
     {
         throw new Exception("Could not open scene: " + paths[0]);
     }
     for (int index = 1; index < paths.Length; ++index)
     {
         EditorSceneManager.OpenScene(paths[index], OpenSceneMode.Additive);
     }
     NavMeshBuilder.BuildNavMesh();
     UnityEngine.Object sceneNavMeshData = NavMeshBuilder.sceneNavMeshData;
     for (int index = 0; index < paths.Length; ++index)
     {
         if (EditorSceneManager.OpenScene(paths[index]).IsValid())
         {
             NavMeshBuilder.sceneNavMeshData = sceneNavMeshData;
             EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
         }
     }
 }
Пример #3
0
 public static void BuildNavMeshForMultipleScenes(string[] paths)
 {
     if (paths.Length == 0)
     {
         return;
     }
     for (int i = 0; i < paths.Length; i++)
     {
         for (int j = i + 1; j < paths.Length; j++)
         {
             if (paths[i] == paths[j])
             {
                 throw new Exception("No duplicate scene names are allowed");
             }
         }
     }
     if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
     {
         return;
     }
     if (!EditorSceneManager.OpenScene(paths[0]).IsValid())
     {
         throw new Exception("Could not open scene: " + paths[0]);
     }
     for (int k = 1; k < paths.Length; k++)
     {
         EditorSceneManager.OpenScene(paths[k], OpenSceneMode.Additive);
     }
     NavMeshBuilder.BuildNavMesh();
     UnityEngine.Object sceneNavMeshData = NavMeshBuilder.sceneNavMeshData;
     for (int l = 0; l < paths.Length; l++)
     {
         if (EditorSceneManager.OpenScene(paths[l]).IsValid())
         {
             NavMeshBuilder.sceneNavMeshData = sceneNavMeshData;
             EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
         }
     }
 }
Пример #4
0
        private static void BakeButtons()
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            bool enabled1 = GUI.enabled;

            GUI.enabled &= !Application.isPlaying;
            if (GUILayout.Button("Clear", new GUILayoutOption[1] {
                GUILayout.Width(95f)
            }))
            {
                NavMeshBuilder.ClearAllNavMeshes();
            }
            GUI.enabled = enabled1;
            if (NavMeshBuilder.isRunning)
            {
                if (GUILayout.Button("Cancel", new GUILayoutOption[1] {
                    GUILayout.Width(95f)
                }))
                {
                    NavMeshBuilder.Cancel();
                }
            }
            else
            {
                bool enabled2 = GUI.enabled;
                GUI.enabled &= !Application.isPlaying;
                if (GUILayout.Button("Bake", new GUILayoutOption[1] {
                    GUILayout.Width(95f)
                }))
                {
                    NavMeshBuilder.BuildNavMeshAsync();
                }
                GUI.enabled = enabled2;
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }