Fix: Keep DC panel in side panel instead of floating (remove FollowPositionForFrames)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leo Qu
2026-02-22 20:50:40 -05:00
committed by Leo Qu
parent 71d3ae77bd
commit 9b6bb5dc88

View File

@@ -11,7 +11,6 @@ public class DCMotorModule : ModuleBase
public float rotationSpeed = 90f;
private float targetPosition = 0f;
private Coroutine followCoroutine;
public void Start()
{
@@ -23,33 +22,13 @@ public class DCMotorModule : ModuleBase
public override void OnSelect()
{
if (followCoroutine != null)
StopCoroutine(followCoroutine);
followCoroutine = StartCoroutine(FollowPositionForFrames());
if (motorControlPanel != null)
motorControlPanel.Initialize(this);
}
private IEnumerator FollowPositionForFrames()
{
RectTransform panelRect = motorControlPanel.GetComponent<RectTransform>();
float duration = 0.5f;
float timer = 0f;
while (timer < duration)
{
Vector3 worldPos = transform.position;
Vector3 screenPos = Camera.main.WorldToScreenPoint(worldPos) + new Vector3(150f, 0f, 0f);
panelRect.position = screenPos;
timer += Time.deltaTime;
yield return null;
}
}
public override void DeSelect()
{
if (motorControlPanel != null)
motorControlPanel.HidePanel();
}