This repository has been archived on 2025-04-28. You can view files and clone it, but cannot push or open issues or pull requests.
ARPlusSystem/ARPlusSystem-250418/Assets/ARLocation/Scripts/Components/RenderPathLine.cs

53 lines
1.6 KiB
C#
Raw Permalink Normal View History

using System;
using UnityEngine;
namespace ARLocation
{
/// <summary>
/// This component renders a LocationPath using a given LineRenderer.
/// </summary>
[AddComponentMenu("AR+GPS/Render Path Line")]
[HelpURL("https://http://docs.unity-ar-gps-location.com/guide/#renderpathline")]
public class RenderPathLine : MonoBehaviour
{
public MoveAlongPath.PathSettingsData PathSettings;
public MoveAlongPath.PlacementSettingsData PlacementSettings;
[HideInInspector]
public Transform arLocationRoot;
[HideInInspector]
public MoveAlongPath moveAlongPath;
public void Start()
{
if (PathSettings.LineRenderer == null)
{
var lineRenderer = gameObject.GetComponent<LineRenderer>();
if (!lineRenderer)
{
throw new NullReferenceException("[AR+GPS][RenderPathLine#Start]: No Line Renderer!");
}
PathSettings.LineRenderer = lineRenderer;
}
arLocationRoot = ARLocationManager.Instance.gameObject.transform;
var pathGameObject = new GameObject($"{gameObject.name} - RenderPathLine");
moveAlongPath = pathGameObject.AddComponent<MoveAlongPath>();
moveAlongPath.PathSettings = PathSettings;
moveAlongPath.PlacementSettings = PlacementSettings;
}
public void SetLocationPath(LocationPath path)
{
if (moveAlongPath != null)
{
moveAlongPath.SetLocationPath(path);
}
}
}
}