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.
65 lines
1.8 KiB
65 lines
1.8 KiB
using UnityEngine;
|
|
|
|
namespace ARLocation
|
|
{
|
|
|
|
public class MockLocationProvider : AbstractLocationProvider
|
|
{
|
|
public override string Name => "MockLocationProvider";
|
|
|
|
public override bool IsCompassEnabled => true;
|
|
|
|
public Location mockLocation = new Location();
|
|
|
|
protected override HeadingReading? ReadHeading()
|
|
{
|
|
var mainCamera = ARLocationManager.Instance.MainCamera;
|
|
|
|
var transform = mainCamera.transform;
|
|
|
|
var localEulerAngles = transform.localEulerAngles;
|
|
return new HeadingReading
|
|
{
|
|
heading = localEulerAngles.y,
|
|
magneticHeading = localEulerAngles.y,
|
|
accuracy = 0,
|
|
isMagneticHeadingAvailable = true,
|
|
timestamp = (long)(Time.time * 1000)
|
|
};
|
|
}
|
|
|
|
protected override LocationReading? ReadLocation()
|
|
{
|
|
return new LocationReading
|
|
{
|
|
latitude = mockLocation.Latitude,
|
|
longitude = mockLocation.Longitude,
|
|
altitude = mockLocation.Altitude,
|
|
accuracy = 0.0,
|
|
floor = -1,
|
|
timestamp = (long)(Time.time * 1000)
|
|
};
|
|
}
|
|
|
|
private bool requested = true;
|
|
|
|
protected override void RequestLocationAndCompassUpdates()
|
|
{
|
|
requested = true;
|
|
}
|
|
|
|
protected override void UpdateLocationRequestStatus()
|
|
{
|
|
if (requested)
|
|
{
|
|
Status = LocationProviderStatus.Initializing;
|
|
requested = false;
|
|
}
|
|
|
|
if (Status == LocationProviderStatus.Initializing)
|
|
{
|
|
Status = LocationProviderStatus.Started;
|
|
}
|
|
}
|
|
}
|
|
}
|