5 using UnityEngine.XR.ARFoundation;
10 public static class GameObjectMenuItems{
12 [MenuItem(
"GameObject/AR+GPS/ARLocationRoot",
false, 20)]
13 public static void CreateARLocationRoot()
15 var go =
new GameObject(
"ARLocationRoot");
17 go.AddComponent<ARLocationManager>();
18 go.AddComponent<ARLocationProvider>();
20 var arSessionOrigin = GameObject.Find(
"AR Session Origin");
22 if (arSessionOrigin !=
null)
24 go.transform.SetParent(arSessionOrigin.transform);
28 [MenuItem(
"GameObject/AR+GPS/GPS Stage Object",
false, 20)]
29 public static GameObject CreateGpsStageObject()
31 var go =
new GameObject(
"GPS Stage Object");
33 go.AddComponent<PlaceAtLocation>();
38 [MenuItem(
"GameObject/AR+GPS/GPS Hotspot Object",
false, 20)]
39 public static GameObject CreateGpsHotspotObject()
41 var go =
new GameObject(
"GPS Hotspot Object");
43 go.AddComponent<Hotspot>();
48 [MenuItem(
"GameObject/AR+GPS/Create Basic Scene Structure",
false, 20)]
49 public static void CreateBasicScene()
52 EditorApplication.ExecuteMenuItem(
"GameObject/Vuforia Engine/AR Camera");
53 Selection.activeObject =
null;
54 EditorApplication.ExecuteMenuItem(
"GameObject/Vuforia Engine/Ground Plane/Plane Finder");
56 CreateARLocationRoot();
57 var stage = CreateGpsStageObject();
59 var capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);
60 capsule.transform.SetParent(stage.transform);
62 EditorApplication.ExecuteMenuItem(
"GameObject/XR/AR Session");
63 Selection.activeObject =
null;
64 EditorApplication.ExecuteMenuItem(
"GameObject/XR/AR Session Origin");
65 Selection.activeObject =
null;
66 EditorApplication.ExecuteMenuItem(
"GameObject/AR+GPS/ARLocationRoot");
68 var prevMain = GameObject.FindWithTag(
"MainCamera");
71 Object.DestroyImmediate(prevMain);
74 var cam = GameObject.Find(
"AR Camera");
78 cam.tag =
"MainCamera";
79 var camera = cam.GetComponent<Camera>();
80 camera.farClipPlane = 1000.0f;
83 var arSessionOrigin = Object.FindObjectOfType<ARSessionOrigin>().gameObject;
84 arSessionOrigin.AddComponent<ARPlaneManager>();
86 var stage = CreateGpsStageObject();
87 var capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);
88 capsule.transform.SetParent(stage.transform);