mirror of
https://github.com/BotChain-Robots/ui.git
synced 2026-07-08 23:17:22 +02:00
- 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
24 lines
1017 B
C#
24 lines
1017 B
C#
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);
|
|
}
|
|
}
|