线缆的物理表现

This commit is contained in:
2024-08-28 17:04:13 +08:00
parent a82b020c48
commit 5831a7cf84
17 changed files with 864 additions and 108 deletions
@@ -36,12 +36,27 @@ public class InteractiveLineSegment : VisualLineSegment
{
_isCuttable = value;
// Change the color of the line segment based on its cuttability
GetComponent<LineRenderer>().material.color = value ? Color.white : Color.black;
//GetComponent<LineRenderer>().material.color = value ? Color.white : Color.black;
}
}
private bool _isCuttable=false;
public void OnHover()
{
if (IsCuttable)
{
TurnGreen();
}
else
{
TurnRed();
}
}
public void OnHoverExit()
{
TurnGrey();
}
protected override void Awake()
{
base.Awake();
@@ -52,11 +67,26 @@ public class InteractiveLineSegment : VisualLineSegment
Initialize();
}
public void TurnGreen()
{
lineRenderer.material.color = Color.green; // 改变 LineRenderer 的颜色
}
public void TurnGrey()
{
lineRenderer.material.color = Color.grey; // 改变 LineRenderer 的颜色
}
public void TurnRed()
{
lineRenderer.material.color = Color.red; // 改变 LineRenderer 的颜色
}
public void Initialize()
{
TurnGrey();
if (StartTransform == null || EndTransform == null)
{
Debug.LogError("StartTransform or EndTransform is not set.");
@@ -84,5 +114,7 @@ public class InteractiveLineSegment : VisualLineSegment
// Set the position of the BoxCollider2D to the start point
boxCollider.transform.position = StartPoint;
}
}