private void Start() { arLocationOrientation = GetComponent <ARLocationOrientation>(); arLocationProvider = ARLocationProvider.Instance; if (WaitForARTrackingToStart) { arLocationProvider.Mute(); } #if !ARGPS_USE_VUFORIA var arSession = FindObjectOfType <ARSession>(); if (!arSession) { throw new NullReferenceException("[AR+GPS][ARLocationManager#Start]: No ARSession found in the scene!"); } SessionManager = new ARFoundationSessionManager(arSession); #else SessionManager = new VuforiaSessionManager(); #endif SessionManager.DebugMode = DebugMode; SessionManager.OnARTrackingStarted(ARTrackingStartedCallback); SessionManager.OnARTrackingRestored(ARTrackingRestoredCallback); SessionManager.OnARTrackingLost(ARTrackingLostCallback); groundHeightDummy = new GameObject("ARLocationGroundHeight"); groundHeightDummy.transform.SetParent(MainCamera.transform); groundHeightDummy.transform.localPosition = new Vector3(); groundHeight = groundHeightDummy.AddComponent <GroundHeight>(); }
private void Initialize() { state.PointCount = PathSettings.LocationPath.Locations.Length; state.Points = new Vector3[state.PointCount]; useLineRenderer = PathSettings.LineRenderer != null; transform.SetParent(arLocationRoot.transform); state.Playing = PlaybackSettings.AutoPlay; u += PlaybackSettings.Offset; groundHeight = GetComponent <GroundHeight>(); if (PlacementSettings.AltitudeMode == AltitudeMode.GroundRelative) { if (!groundHeight) { groundHeight = gameObject.AddComponent <GroundHeight>(); groundHeight.Settings.DisableUpdate = true; } } else { if (groundHeight) { Destroy(groundHeight); groundHeight = null; } } if (!hasInitialized) { locationProvider.OnProviderRestartEvent(ProviderRestarted); } if (locationProvider.IsEnabled) { LocationUpdated(locationProvider.CurrentLocation, locationProvider.LastLocation); } }