这是“ LocationArrayEditorLocationProvider.cs” C#代码:
namespace Mapbox.Unity.Location
{
using System;
using Mapbox.Unity.Utilities;
using Mapbox.Utils;
using UnityEngine;
/// <summary>
/// The EditorLocationProvider is responsible for providing mock location and heading data
/// for testing purposes in the Unity editor.
/// </summary>
public class LocationArrayEditorLocationProvider : AbstractEditorLocationProvider
{
/// <summary>
/// The mock "latitude, longitude" location, respresented with a string.
/// You can search for a place using the embedded "Search" button in the inspector.
/// This value can be changed at runtime in the inspector.
/// </summary>
[SerializeField]
//[Geocode]
string[] _latitudeLongitude;
/// <summary>
/// The mock heading value.
/// </summary>
[SerializeField]
[Range(0, 359)]
float _heading;
private int idx = -1;
Vector2d LatitudeLongitude
{
get
{
idx++;
// reset index to keep looping through the location array
if (idx >= _latitudeLongitude.Length) { idx = 0; }
return Conversions.StringToLatLon(_latitudeLongitude[idx]);
}
}
protected override void SetLocation()
{
_currentLocation.UserHeading = _heading;
_currentLocation.LatitudeLongitude = LatitudeLongitude;
_currentLocation.Accuracy = _accuracy;
_currentLocation.Timestamp = UnixTimestampUtils.To(DateTime.UtcNow);
_currentLocation.IsLocationUpdated = true;
_currentLocation.IsUserHeadingUpdated = true;
}
}
}
通过将它们添加到Unity检查器中,可以使我的对象遵循多个航路点(纬度,经度位置): LocationArray
我的问题是:我喜欢500个这样的路标,并且不想在检查器中添加每一个,而是将它们集成到代码中。有谁知道如何或在何处更改代码以添加字符串数组之类的想法?如果有人可以帮助,那就太好了。如果您不了解我的问题,请提出要求。预先谢谢你!