mirror of
https://github.com/BotChain-Robots/ui.git
synced 2026-07-08 15:07:22 +02:00
BTS-150: Programmed Movements UI - timeline, config panel, Run button fixes
- Timeline blocks aligned with second markers (Blocks rect full width) - Config panel: Angle/Direction sections, Save/Back/Delete - DC module support: Fwd/Bwd, degrees input - Run button: re-wire on completion, periodic re-wire when idle - Fix AngleInput path (ConfigRow2/AngleSection/AngleInput) for correct angle save - Default module None for new blocks, Run text 'Running' Made-with: Cursor
This commit is contained in:
23
Assets/ProgrammedMovements/TrackClickHandler.cs
Normal file
23
Assets/ProgrammedMovements/TrackClickHandler.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
/// <summary>
|
||||
/// Attach to a track's Blocks rect. On click, invokes callback with the clicked time (0-10).
|
||||
/// </summary>
|
||||
public class TrackClickHandler : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public System.Action<int, float> OnTrackClicked;
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (OnTrackClicked == null) return;
|
||||
var rect = GetComponent<RectTransform>();
|
||||
if (rect == null) return;
|
||||
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, eventData.position, eventData.pressEventCamera, out var localPoint);
|
||||
float normalizedX = Mathf.InverseLerp(rect.rect.xMin, rect.rect.xMax, localPoint.x);
|
||||
float second = Mathf.Clamp(normalizedX * ProgrammedMovementsController.TimelineDurationSeconds, 0f, ProgrammedMovementsController.TimelineDurationSeconds - 0.1f);
|
||||
int trackIndex = transform.parent.GetSiblingIndex();
|
||||
OnTrackClicked.Invoke(trackIndex, second);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user