Files
aibis-dream/Assets/Scripts/FixSystem/Line/VisualLineSegment.cs
T
bottlefish 5ffa9f6b5f 模块和线的拆除以及重装
view的visual管理,重构了line的初始化方式,支持用yarn初始化
2024-09-01 18:40:46 +08:00

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));
// }
}