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.

92 lines
2.9 KiB

4 years ago
  1. using UnityEngine;
  2. using UnityEditor;
  3. #if !ARGPS_USE_VUFORIA
  4. using UnityEngine.XR.ARFoundation;
  5. #endif
  6. namespace ARLocation
  7. {
  8. public static class GameObjectMenuItems{
  9. [MenuItem("GameObject/AR+GPS/ARLocationRoot", false, 20)]
  10. public static void CreateARLocationRoot()
  11. {
  12. var go = new GameObject("ARLocationRoot");
  13. go.AddComponent<ARLocationManager>();
  14. go.AddComponent<ARLocationProvider>();
  15. var arSessionOrigin = GameObject.Find("AR Session Origin");
  16. if (arSessionOrigin != null)
  17. {
  18. go.transform.SetParent(arSessionOrigin.transform);
  19. }
  20. }
  21. [MenuItem("GameObject/AR+GPS/GPS Stage Object", false, 20)]
  22. public static GameObject CreateGpsStageObject()
  23. {
  24. var go = new GameObject("GPS Stage Object");
  25. go.AddComponent<PlaceAtLocation>();
  26. return go;
  27. }
  28. [MenuItem("GameObject/AR+GPS/GPS Hotspot Object", false, 20)]
  29. public static GameObject CreateGpsHotspotObject()
  30. {
  31. var go = new GameObject("GPS Hotspot Object");
  32. go.AddComponent<Hotspot>();
  33. return go;
  34. }
  35. [MenuItem("GameObject/AR+GPS/Create Basic Scene Structure", false, 20)]
  36. public static void CreateBasicScene()
  37. {
  38. #if ARGPS_USE_VUFORIA
  39. EditorApplication.ExecuteMenuItem("GameObject/Vuforia Engine/AR Camera");
  40. Selection.activeObject = null;
  41. EditorApplication.ExecuteMenuItem("GameObject/Vuforia Engine/Ground Plane/Plane Finder");
  42. CreateARLocationRoot();
  43. var stage = CreateGpsStageObject();
  44. var capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);
  45. capsule.transform.SetParent(stage.transform);
  46. #else
  47. EditorApplication.ExecuteMenuItem("GameObject/XR/AR Session");
  48. Selection.activeObject = null;
  49. EditorApplication.ExecuteMenuItem("GameObject/XR/AR Session Origin");
  50. Selection.activeObject = null;
  51. EditorApplication.ExecuteMenuItem("GameObject/AR+GPS/ARLocationRoot");
  52. var prevMain = GameObject.FindWithTag("MainCamera");
  53. if (prevMain)
  54. {
  55. Object.DestroyImmediate(prevMain);
  56. }
  57. var cam = GameObject.Find("AR Camera");
  58. if (cam)
  59. {
  60. cam.tag = "MainCamera";
  61. var camera = cam.GetComponent<Camera>();
  62. camera.farClipPlane = 1000.0f;
  63. }
  64. var arSessionOrigin = Object.FindObjectOfType<ARSessionOrigin>().gameObject;
  65. arSessionOrigin.AddComponent<ARPlaneManager>();
  66. var stage = CreateGpsStageObject();
  67. var capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);
  68. capsule.transform.SetParent(stage.transform);
  69. #endif
  70. }
  71. }
  72. }