ND_SimulationAutomaticControl/Assets/Scripts/Line/WireData.cs

30 lines
813 B
C#

using UnityEngine;
/// <summary>
/// 连线数据组件,附加到连线对象上存储连线信息
/// </summary>
public class WireData : MonoBehaviour
{
public Vector3 startPoint; // 连线起点位置
public Vector3 endPoint; // 连线终点位置
public System.DateTime creationTime; // 连线创建时间
[Header("吸附信息")]
public GameObject snapStartObject; // 起点吸附的物体
public GameObject snapEndObject; // 终点吸附的物体
[Header("电气属性")]
public float resistance = 0.1f;
public bool isConnected = false;
// 连线编辑功能
public void UpdateEndPoint(Vector3 newEndPoint)
{
endPoint = newEndPoint;
LineRenderer lr = GetComponent<LineRenderer>();
if (lr != null)
{
lr.SetPosition(1, newEndPoint);
}
}
}