SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.2 KiB

4 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine.SceneManagement;
  4. using UnityEngine;
  5. using UnityEditor.Callbacks;
  6. using UnityEngine.XR.ARFoundation;
  7. namespace UnityEditor.XR.ARFoundation
  8. {
  9. internal class ARSceneValidator
  10. {
  11. [PostProcessBuild]
  12. static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
  13. {
  14. if (s_ScenesWithARTypes.Count > 0 && s_SessionCount == 0)
  15. {
  16. var scenes = "";
  17. foreach(var sceneName in s_ScenesWithARTypes)
  18. {
  19. scenes += string.Format("\n\t{0}", sceneName);
  20. }
  21. Debug.LogWarningFormat(
  22. "The following scenes contain AR components but no ARSession. The ARSession component controls the AR lifecycle, so these components will not do anything at runtime. Was this intended?{0}",
  23. scenes);
  24. }
  25. s_ScenesWithARTypes.Clear();
  26. s_SessionCount = 0;
  27. }
  28. [PostProcessScene]
  29. static void OnPostProcessScene()
  30. {
  31. if (sceneContainsARTypes)
  32. s_ScenesWithARTypes.Add(SceneManager.GetActiveScene().name);
  33. s_SessionCount += UnityEngine.Object.FindObjectsOfType<ARSession>().Length;
  34. }
  35. static bool sceneContainsARTypes
  36. {
  37. get
  38. {
  39. foreach (var type in k_ARTypes)
  40. {
  41. foreach (var component in UnityEngine.Object.FindObjectsOfType(type))
  42. {
  43. var monobehaviour = component as MonoBehaviour;
  44. if (monobehaviour != null && monobehaviour.enabled)
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. }
  51. static List<string> s_ScenesWithARTypes = new List<string>();
  52. static int s_SessionCount;
  53. static readonly Type[] k_ARTypes = new Type[]
  54. {
  55. typeof(ARCameraBackground),
  56. typeof(ARPlaneManager),
  57. typeof(ARPointCloudManager),
  58. typeof(ARAnchorManager)
  59. };
  60. }
  61. }