Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

NavigationSampleInitializer.cs 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. #if UNITY_EDITOR
  3. using Unity.AI.Navigation.Samples.Editor;
  4. using UnityEditor.SceneManagement;
  5. #endif
  6. using UnityEngine;
  7. namespace Unity.AI.Navigation.Samples
  8. {
  9. /// <summary>
  10. /// The Navigation samples use a couple of custom agent types.
  11. /// This class calls the NavigationSampleProjectSettingsGenerator to ensure that these agent types do exist within your Unity project.
  12. /// It is in no way necessary for using the Navigation package and is only used for the correct functioning of the samples.
  13. /// </summary>
  14. [ExecuteAlways]
  15. public class NavigationSampleInitializer : MonoBehaviour
  16. {
  17. #if UNITY_EDITOR
  18. [SerializeField]
  19. NavigationSampleSettingsState settingsState;
  20. void Start()
  21. {
  22. if (!Application.isPlaying)
  23. {
  24. NavigationSampleProjectSettingsGenerator.GenerateAllProjectSettings(settingsState);
  25. DestroyGameObjectAndSave(gameObject);
  26. }
  27. }
  28. static void DestroyGameObjectAndSave(GameObject gameObject)
  29. {
  30. var scene = gameObject.scene;
  31. DestroyImmediate(gameObject);
  32. EditorSceneManager.SaveScene(scene);
  33. }
  34. #endif
  35. }
  36. }