AR + GPS Location  3.0.0
All Classes Namespaces Functions Variables Properties Events Pages
GameObjectMenuItems.cs
1 using UnityEngine;
2 using UnityEditor;
3 
4 #if !ARGPS_USE_VUFORIA
5 using UnityEngine.XR.ARFoundation;
6 #endif
7 
8 namespace ARLocation
9 {
10  public static class GameObjectMenuItems{
11 
12  [MenuItem("GameObject/AR+GPS/ARLocationRoot", false, 20)]
13  public static void CreateARLocationRoot()
14  {
15  var go = new GameObject("ARLocationRoot");
16 
17  go.AddComponent<ARLocationManager>();
18  go.AddComponent<ARLocationProvider>();
19 
20  var arSessionOrigin = GameObject.Find("AR Session Origin");
21 
22  if (arSessionOrigin != null)
23  {
24  go.transform.SetParent(arSessionOrigin.transform);
25  }
26  }
27 
28  [MenuItem("GameObject/AR+GPS/GPS Stage Object", false, 20)]
29  public static GameObject CreateGpsStageObject()
30  {
31  var go = new GameObject("GPS Stage Object");
32 
33  go.AddComponent<PlaceAtLocation>();
34 
35  return go;
36  }
37 
38  [MenuItem("GameObject/AR+GPS/GPS Hotspot Object", false, 20)]
39  public static GameObject CreateGpsHotspotObject()
40  {
41  var go = new GameObject("GPS Hotspot Object");
42 
43  go.AddComponent<Hotspot>();
44 
45  return go;
46  }
47 
48  [MenuItem("GameObject/AR+GPS/Create Basic Scene Structure", false, 20)]
49  public static void CreateBasicScene()
50  {
51 #if ARGPS_USE_VUFORIA
52  EditorApplication.ExecuteMenuItem("GameObject/Vuforia Engine/AR Camera");
53  Selection.activeObject = null;
54  EditorApplication.ExecuteMenuItem("GameObject/Vuforia Engine/Ground Plane/Plane Finder");
55 
56  CreateARLocationRoot();
57  var stage = CreateGpsStageObject();
58 
59  var capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);
60  capsule.transform.SetParent(stage.transform);
61 #else
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");
67 
68  var prevMain = GameObject.FindWithTag("MainCamera");
69  if (prevMain)
70  {
71  Object.DestroyImmediate(prevMain);
72  }
73 
74  var cam = GameObject.Find("AR Camera");
75 
76  if (cam)
77  {
78  cam.tag = "MainCamera";
79  var camera = cam.GetComponent<Camera>();
80  camera.farClipPlane = 1000.0f;
81  }
82 
83  var arSessionOrigin = Object.FindObjectOfType<ARSessionOrigin>().gameObject;
84  arSessionOrigin.AddComponent<ARPlaneManager>();
85 
86  var stage = CreateGpsStageObject();
87  var capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);
88  capsule.transform.SetParent(stage.transform);
89 #endif
90  }
91  }
92 }
ARLocation
Definition: ARLocationConfigInspector.cs:7