38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using UnityEngine;
|
|
using DG.Tweening;
|
|
|
|
public class VisualLineSegment : MonoBehaviour
|
|
{
|
|
public Vector3 StartPoint { get; private set; }
|
|
public Vector3 EndPoint { get; private set; }
|
|
[HideInInspector]
|
|
public LineRenderer lineRenderer;
|
|
|
|
protected virtual void Awake()
|
|
{
|
|
lineRenderer = GetComponent<LineRenderer>();
|
|
}
|
|
|
|
public void Initialize(Vector3 startPoint, Vector3 endPoint)
|
|
{
|
|
StartPoint = startPoint;
|
|
EndPoint = endPoint;
|
|
|
|
lineRenderer.positionCount = 2;
|
|
lineRenderer.SetPosition(0, StartPoint);
|
|
lineRenderer.SetPosition(1, EndPoint);
|
|
}
|
|
|
|
|
|
// public void ShrinkAndDisappear()
|
|
// {
|
|
// // Shrink the line segment from the end to the start
|
|
// DOTween.To(() => EndPoint, x => EndPoint = x, StartPoint, 1f)
|
|
// .OnUpdate(() => {
|
|
// lineRenderer.SetPosition(0, StartPoint);
|
|
// lineRenderer.SetPosition(1, EndPoint);
|
|
// })
|
|
// .OnComplete(() => Destroy(gameObject));
|
|
// }
|
|
}
|