From 6e96580930835a49325a9dbe69f3760d76c9adfa Mon Sep 17 00:00:00 2001 From: hatayama Date: Sun, 26 Jul 2026 03:20:22 +0900 Subject: [PATCH 1/3] Remove unreferenced FirstPartyTools and Runtime PublicCandidates Drop outbound-only members that production scan reports as unused so PR-5 can shrink the FirstPartyTools/Runtime bucket without removing Skill/CLI-backed fields or Unity reflection keepers. Co-authored-by: Cursor --- .../MouseUiMainThreadCleanupSchedulerTests.cs | 1 - .../ClearConsole/ClearConsoleResponse.cs | 22 ---- .../Common/InputRecording/InputRecorder.cs | 5 - .../InputRecording/InputReplayUiController.cs | 49 ++------ .../Common/MouseUi/UiRaycastHelper.cs | 8 -- ...yDefinitionDuplicationValidationService.cs | 83 -------------- .../GameObjectFinder/GameObjectDetails.cs | 1 - .../GetLogs/GetLogsResponse.cs | 17 --- .../RunTests/RunTestsResponse.cs | 12 -- .../Application/KeyboardKeyState.cs | 11 -- .../Application/MouseInputState.cs | 4 - .../MouseUiIncrementalDragExecutor.cs | 108 +++++------------- .../MouseUiOneShotDragExecutor.cs | 40 ++----- .../MouseUiPressActionExecutor.cs | 69 +++-------- .../Watch/WatchExpressionStepMonitor.cs | 11 -- .../SimulateMouseInputOverlayState.cs | 10 -- .../SimulateMouseUiOverlayState.cs | 8 +- 17 files changed, 64 insertions(+), 395 deletions(-) diff --git a/Assets/Tests/Editor/MouseUiMainThreadCleanupSchedulerTests.cs b/Assets/Tests/Editor/MouseUiMainThreadCleanupSchedulerTests.cs index c368686845..da92345938 100644 --- a/Assets/Tests/Editor/MouseUiMainThreadCleanupSchedulerTests.cs +++ b/Assets/Tests/Editor/MouseUiMainThreadCleanupSchedulerTests.cs @@ -43,7 +43,6 @@ public void QueueOverlayClear_WithActiveOverlayState_ClearsState() MouseAction.Click, new Vector2(10f, 20f), null, - "Target", new Vector2(100f, 200f)); MouseUiMainThreadCleanupScheduler scheduler = new(); scheduler.CaptureMainThreadContext(); diff --git a/Packages/src/Editor/FirstPartyTools/ClearConsole/ClearConsoleResponse.cs b/Packages/src/Editor/FirstPartyTools/ClearConsole/ClearConsoleResponse.cs index aad42ab50f..d402b3bb7a 100644 --- a/Packages/src/Editor/FirstPartyTools/ClearConsole/ClearConsoleResponse.cs +++ b/Packages/src/Editor/FirstPartyTools/ClearConsole/ClearConsoleResponse.cs @@ -41,28 +41,6 @@ public ClearConsoleResponse(bool success, int clearedLogCount, ClearedLogCounts Message = message ?? string.Empty; ErrorMessage = string.Empty; } - - /// - /// Create a new ClearConsoleResponse for failed operation - /// - public ClearConsoleResponse(string errorMessage) - { - Success = false; - ClearedLogCount = 0; - ClearedCounts = new ClearedLogCounts(); - Message = string.Empty; - ErrorMessage = errorMessage ?? string.Empty; - } - - /// - /// Parameterless constructor for JSON deserialization - /// - public ClearConsoleResponse() - { - ClearedCounts = new ClearedLogCounts(); - Message = string.Empty; - ErrorMessage = string.Empty; - } } /// diff --git a/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputRecorder.cs b/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputRecorder.cs index c54965dd95..965e2bca20 100644 --- a/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputRecorder.cs +++ b/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputRecorder.cs @@ -234,11 +234,6 @@ public static void NotifyRecordingStopped() ServiceValue.NotifyRecordingStopped(); } - public static void ForceStop() - { - ServiceValue.ForceStop(); - } - internal static string FormatVector2(Vector2 v) { return InputRecordingVectorFormat.FormatVector2(v); diff --git a/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputReplayUiController.cs b/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputReplayUiController.cs index 6f53820fcd..d0ed876e87 100644 --- a/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputReplayUiController.cs +++ b/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputReplayUiController.cs @@ -80,11 +80,7 @@ private void ApplyUiPointerActivity(UiReplayFrame replayFrame) _pressTime = Time.realtimeSinceStartup; OnUiPointerDown(replayFrame.ScreenPosition, replayFrame.EventSystem); SimulateMouseUiOverlayState.Update( - MouseAction.Click, - replayFrame.InputPosition, - null, - _currentPressTarget?.name, - replayFrame.GameViewSize); + MouseAction.Click, replayFrame.InputPosition, null, replayFrame.GameViewSize); SimulateMouseUiOverlayState.RequestExpandAnimation(); return; } @@ -101,11 +97,7 @@ private void ApplyUiPointerActivity(UiReplayFrame replayFrame) // from being cancelled by the next idle frame at the same position. _suppressIdleUiOverlay = false; SimulateMouseUiOverlayState.Update( - MouseAction.Click, - replayFrame.InputPosition, - null, - null, - replayFrame.GameViewSize); + MouseAction.Click, replayFrame.InputPosition, null, replayFrame.GameViewSize); } } @@ -116,14 +108,9 @@ private void ApplyUiPointerHold(UiReplayFrame replayFrame) if (_isDragging) { Vector2 pressInputPos = new( - _pressScreenPosition.x, - replayFrame.GameViewSize.y - _pressScreenPosition.y); + _pressScreenPosition.x, replayFrame.GameViewSize.y - _pressScreenPosition.y); SimulateMouseUiOverlayState.Update( - MouseAction.Drag, - replayFrame.InputPosition, - pressInputPos, - null, - replayFrame.GameViewSize); + MouseAction.Drag, replayFrame.InputPosition, pressInputPos, replayFrame.GameViewSize); return; } @@ -134,11 +121,7 @@ private void ApplyUiPointerHold(UiReplayFrame replayFrame) } SimulateMouseUiOverlayState.Update( - MouseAction.LongPress, - replayFrame.InputPosition, - null, - _currentPressTarget?.name, - replayFrame.GameViewSize); + MouseAction.LongPress, replayFrame.InputPosition, null, replayFrame.GameViewSize); SimulateMouseUiOverlayState.UpdateLongPressElapsed(elapsed); } @@ -183,14 +166,7 @@ private void ApplyUiPointerRelease(UiReplayFrame replayFrame) Vector2 inputPos = new(screenPos.x, gameViewSize.y - screenPos.y); return new UiReplayFrame( - eventSystem, - screenPos, - inputPos, - gameViewSize, - leftHeld, - justPressed, - justReleased, - mouseMoved); + eventSystem, screenPos, inputPos, gameViewSize, leftHeld, justPressed, justReleased, mouseMoved); } private void OnUiPointerDown(Vector2 screenPos, EventSystem eventSystem) @@ -199,9 +175,7 @@ private void OnUiPointerDown(Vector2 screenPos, EventSystem eventSystem) _pointerData = new PointerEventData(eventSystem) { - position = screenPos, - pressPosition = screenPos, - button = PointerEventData.InputButton.Left + position = screenPos, pressPosition = screenPos, button = PointerEventData.InputButton.Left }; _pressScreenPosition = screenPos; _isDragging = false; @@ -348,14 +322,7 @@ private void SetUiInputModulesSuppressed(bool suppressed) private readonly struct UiReplayFrame { public UiReplayFrame( - EventSystem eventSystem, - Vector2 screenPosition, - Vector2 inputPosition, - Vector2 gameViewSize, - bool leftHeld, - bool justPressed, - bool justReleased, - bool mouseMoved) + EventSystem eventSystem, Vector2 screenPosition, Vector2 inputPosition, Vector2 gameViewSize, bool leftHeld, bool justPressed, bool justReleased, bool mouseMoved) { EventSystem = eventSystem; ScreenPosition = screenPosition; diff --git a/Packages/src/Editor/FirstPartyTools/Common/MouseUi/UiRaycastHelper.cs b/Packages/src/Editor/FirstPartyTools/Common/MouseUi/UiRaycastHelper.cs index ea15937d08..356af9dc14 100644 --- a/Packages/src/Editor/FirstPartyTools/Common/MouseUi/UiRaycastHelper.cs +++ b/Packages/src/Editor/FirstPartyTools/Common/MouseUi/UiRaycastHelper.cs @@ -18,14 +18,6 @@ internal static class UiRaycastHelper return context.Raycast(screenPosition); } - // Bypass EventSystem's Screen-bounds clipping by directly testing Graphic rects in Canvas space. - // Only supports ScreenSpaceOverlay canvases where world positions equal Canvas-space positions. - public static RaycastResult? RaycastCanvasSpace(Vector2 canvasPosition) - { - List canvasRaycastSources = CollectCanvasRaycastSources(); - return RaycastCanvasSpaceFromSources(canvasPosition, canvasRaycastSources); - } - private static List CollectCanvasRaycastSources() { #if UNITY_6000_4_OR_NEWER diff --git a/Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionDuplicationValidationService.cs b/Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionDuplicationValidationService.cs index 264a639e38..28a8ac3091 100644 --- a/Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionDuplicationValidationService.cs +++ b/Packages/src/Editor/FirstPartyTools/Compile/AssemblyDefinitionDuplicationValidationService.cs @@ -4,7 +4,6 @@ using System.Text.RegularExpressions; using UnityEditor; using UnityEditorInternal; -using UnityEngine; using io.github.hatayama.UnityCliLoop.ToolContracts; @@ -18,88 +17,6 @@ public class AssemblyDefinitionDuplicationValidationService private static readonly Regex AsmdefNameRegex = new("\"name\"\\s*:\\s*\"(?[^\"]+)\"", RegexOptions.Compiled); - private static readonly Regex DuplicateAsmdefConsoleRegex = new( - "^Assembly with name '(?[^']+)' already exists \\((?[^)]+)\\)$", - RegexOptions.Compiled - ); - - public ValidationResult ValidateNoDuplicateAsmdefNamesFromConsoleErrors() - { - LogRetrievalService retrievalService = new(); - LogDisplayDto logData = retrievalService.GetLogsWithSearch( - UnityCliLoopLogType.Error, - "Assembly with name '", - useRegex: false, - searchInStackTrace: false - ); - - Dictionary> pathsByAsmName = new(StringComparer.Ordinal); - - foreach (LogEntryDto entry in logData.LogEntries) - { - if (string.IsNullOrEmpty(entry.Message)) - { - continue; - } - - Match match = DuplicateAsmdefConsoleRegex.Match(entry.Message.Trim()); - if (!match.Success) - { - continue; - } - - string asmName = match.Groups["name"].Value; - string assetPath = match.Groups["path"].Value; - if (string.IsNullOrEmpty(asmName) || string.IsNullOrEmpty(assetPath)) - { - continue; - } - - // Prevent false positives from stale console logs by verifying the asset still exists. - UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assetPath); - if (obj == null) - { - continue; - } - - if (!pathsByAsmName.TryGetValue(asmName, out List paths)) - { - paths = new List(); - pathsByAsmName.Add(asmName, paths); - } - - if (!paths.Contains(assetPath)) - { - paths.Add(assetPath); - } - } - - if (pathsByAsmName.Count == 0) - { - return ValidationResult.Success(); - } - - string details = string.Join( - "\n", - pathsByAsmName - .OrderBy(kvp => kvp.Key, StringComparer.Ordinal) - .Take(5) - .Select(d => - { - string paths = string.Join("\n ", d.Value.Take(8)); - return $"- {d.Key}\n {paths}"; - }) - ); - - string message = - $"{UnityCliLoopConstants.ERROR_MESSAGE_DUPLICATE_ASMDEF}\n" + - "Detected from Console errors:\n" + - $"{details}\n" + - "Fix: ensure each .asmdef has a unique \"name\"."; - - return ValidationResult.Failure(message); - } - public ValidationResult ValidateNoDuplicateAsmdefNames() { string[] asmdefGuids = AssetDatabase.FindAssets("t:AssemblyDefinitionAsset"); diff --git a/Packages/src/Editor/FirstPartyTools/FindGameObjects/GameObjectFinder/GameObjectDetails.cs b/Packages/src/Editor/FirstPartyTools/FindGameObjects/GameObjectFinder/GameObjectDetails.cs index 4c47188e8b..5999d46370 100644 --- a/Packages/src/Editor/FirstPartyTools/FindGameObjects/GameObjectFinder/GameObjectDetails.cs +++ b/Packages/src/Editor/FirstPartyTools/FindGameObjects/GameObjectFinder/GameObjectDetails.cs @@ -8,7 +8,6 @@ namespace io.github.hatayama.UnityCliLoop.FirstPartyTools public class GameObjectDetails { public bool Found { get; set; } - public string ErrorMessage { get; set; } public GameObject GameObject { get; set; } public string Name { get; set; } public string Path { get; set; } diff --git a/Packages/src/Editor/FirstPartyTools/GetLogs/GetLogsResponse.cs b/Packages/src/Editor/FirstPartyTools/GetLogs/GetLogsResponse.cs index 9b9f232816..a5dc1d8d19 100644 --- a/Packages/src/Editor/FirstPartyTools/GetLogs/GetLogsResponse.cs +++ b/Packages/src/Editor/FirstPartyTools/GetLogs/GetLogsResponse.cs @@ -19,13 +19,6 @@ public LogEntry(string type, string message, string stackTrace) Message = message; StackTrace = stackTrace; } - - /// - /// Parameterless constructor for JSON deserialization - /// - public LogEntry() - { - } } /// @@ -83,15 +76,5 @@ public GetLogsResponse(int totalCount, int displayedCount, string logType, int m IncludeStackTrace = includeStackTrace; Logs = logs ?? Array.Empty(); } - - /// - /// Parameterless constructor for JSON deserialization - /// - public GetLogsResponse() - { - LogType = string.Empty; - SearchText = string.Empty; - Logs = Array.Empty(); - } } } \ No newline at end of file diff --git a/Packages/src/Editor/FirstPartyTools/RunTests/RunTestsResponse.cs b/Packages/src/Editor/FirstPartyTools/RunTests/RunTestsResponse.cs index 01f02f0607..b4ec06031a 100644 --- a/Packages/src/Editor/FirstPartyTools/RunTests/RunTestsResponse.cs +++ b/Packages/src/Editor/FirstPartyTools/RunTests/RunTestsResponse.cs @@ -115,18 +115,6 @@ public RunTestsResponse( NoTestsFoundExplanation = noTestsFoundExplanation; } - /// - /// Parameterless constructor for JSON deserialization - /// - public RunTestsResponse() - { - Message = string.Empty; - Status = string.Empty; - NoTestsFoundExplanation = string.Empty; - CompletedAt = string.Empty; - XmlPath = string.Empty; - } - public static RunTestsResponse CreateTestFrameworkUnavailable() { return new RunTestsResponse( diff --git a/Packages/src/Editor/FirstPartyTools/SimulateKeyboard/Application/KeyboardKeyState.cs b/Packages/src/Editor/FirstPartyTools/SimulateKeyboard/Application/KeyboardKeyState.cs index 976e77b40b..db185d6715 100644 --- a/Packages/src/Editor/FirstPartyTools/SimulateKeyboard/Application/KeyboardKeyState.cs +++ b/Packages/src/Editor/FirstPartyTools/SimulateKeyboard/Application/KeyboardKeyState.cs @@ -74,12 +74,6 @@ public void UnregisterTransientKey(Key key) _transientKeys.Remove(key); } - public void Clear() - { - _heldKeys.Clear(); - _transientKeys.Clear(); - } - // Keyboard keys are stored as a bitfield, so StateEvent.From captures // the entire keyboard state. To support simultaneous key holds, we write // ALL currently held keys into every event — not just the target key. @@ -180,11 +174,6 @@ public static void UnregisterTransientKey(Key key) ServiceValue.UnregisterTransientKey(key); } - public static void Clear() - { - ServiceValue.Clear(); - } - public static IReadOnlyList ClearTrackedKeys() { return ServiceValue.ClearTrackedKeys(); diff --git a/Packages/src/Editor/FirstPartyTools/SimulateMouseInput/Application/MouseInputState.cs b/Packages/src/Editor/FirstPartyTools/SimulateMouseInput/Application/MouseInputState.cs index 994255ea9b..2787ef51d9 100644 --- a/Packages/src/Editor/FirstPartyTools/SimulateMouseInput/Application/MouseInputState.cs +++ b/Packages/src/Editor/FirstPartyTools/SimulateMouseInput/Application/MouseInputState.cs @@ -25,8 +25,6 @@ internal sealed class MouseInputStateService private Action? _pendingDeltaReset; private Action? _pendingScrollReset; - public bool IsButtonHeld(RuntimeMouseButton button) => _heldButtons.Contains(button); - public void RegisterPlayModeCallbacks() { EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; @@ -237,8 +235,6 @@ internal static void InitializeForEditorStartup() ServiceValue.RegisterPlayModeCallbacks(); } - public static bool IsButtonHeld(RuntimeMouseButton button) => ServiceValue.IsButtonHeld(button); - public static void SetButtonDown(RuntimeMouseButton button) { ServiceValue.SetButtonDown(button); diff --git a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiIncrementalDragExecutor.cs b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiIncrementalDragExecutor.cs index c30eedcf7f..374e3e46e9 100644 --- a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiIncrementalDragExecutor.cs +++ b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiIncrementalDragExecutor.cs @@ -16,20 +16,13 @@ namespace io.github.hatayama.UnityCliLoop.FirstPartyTools internal static class MouseUiIncrementalDragExecutor { internal static async Task ExecuteDragStart( - MouseUiSimulationCommand parameters, - EventSystem eventSystem, - MouseUiMainThreadCleanupScheduler cleanupScheduler, - CancellationToken ct) + MouseUiSimulationCommand parameters, EventSystem eventSystem, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) { if (MouseDragState.IsDragging) { return new SimulateMouseUiResponse { - Success = false, - Message = "A drag is already in progress. Call DragEnd first.", - Action = MouseAction.DragStart.ToString(), - PositionX = parameters.X, - PositionY = parameters.Y + Success = false, Message = "A drag is already in progress. Call DragEnd first.", Action = MouseAction.DragStart.ToString(), PositionX = parameters.X, PositionY = parameters.Y }; } @@ -37,11 +30,7 @@ internal static async Task ExecuteDragStart( Vector2 screenPos = MouseUiCoordinateConverter.InputToScreen(inputPos); (RaycastResult startRaycast, GameObject? target, SimulateMouseUiResponse? targetFailureResponse) = MouseUiDragTargetResolver.Resolve( - parameters, - eventSystem, - MouseAction.DragStart, - inputPos, - screenPos); + parameters, eventSystem, MouseAction.DragStart, inputPos, screenPos); if (targetFailureResponse != null) { return targetFailureResponse; @@ -50,7 +39,7 @@ internal static async Task ExecuteDragStart( if (target == null) { SimulateMouseUiOverlayState.Update( - MouseAction.DragStart, inputPos, null, null, Handles.GetMainGameViewSize()); + MouseAction.DragStart, inputPos, null, Handles.GetMainGameViewSize()); MouseUiFrameWaitOutcome noTargetExpandOutcome = await MouseUiOverlayAnimator.PlayExpandAnimation(ct).ConfigureAwait(false); if (noTargetExpandOutcome == MouseUiFrameWaitOutcome.TimedOut) { @@ -61,8 +50,7 @@ internal static async Task ExecuteDragStart( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.DragStart, inputPos, null, - "DragStart stopped because Unity paused during Pause Point inspection. No draggable target was found at the position, so no drag was initiated."); + MouseAction.DragStart, inputPos, null, "DragStart stopped because Unity paused during Pause Point inspection. No draggable target was found at the position, so no drag was initiated."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -76,20 +64,15 @@ internal static async Task ExecuteDragStart( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.DragStart, inputPos, null, - "DragStart stopped because Unity paused during Pause Point inspection. No draggable target was found at the position, so no drag was initiated."); + MouseAction.DragStart, inputPos, null, "DragStart stopped because Unity paused during Pause Point inspection. No draggable target was found at the position, so no drag was initiated."); } await MainThreadSwitcher.SwitchToMainThread(ct); return new SimulateMouseUiResponse { - Success = false, - Message = parameters.BypassRaycast + Success = false, Message = parameters.BypassRaycast ? $"TargetPath '{parameters.TargetPath}' has no drag handler." - : $"No draggable UI element at ({inputPos.x:F1}, {inputPos.y:F1}). Use find-game-objects or screenshot to verify positions.", - Action = MouseAction.DragStart.ToString(), - PositionX = inputPos.x, - PositionY = inputPos.y + : $"No draggable UI element at ({inputPos.x:F1}, {inputPos.y:F1}). Use find-game-objects or screenshot to verify positions.", Action = MouseAction.DragStart.ToString(), PositionX = inputPos.x, PositionY = inputPos.y }; } @@ -102,7 +85,7 @@ internal static async Task ExecuteDragStart( string targetName = target.name; SimulateMouseUiOverlayState.Update( - MouseAction.DragStart, inputPos, inputPos, targetName, Handles.GetMainGameViewSize()); + MouseAction.DragStart, inputPos, inputPos, Handles.GetMainGameViewSize()); bool animationCompleted = false; try @@ -117,8 +100,7 @@ internal static async Task ExecuteDragStart( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.DragStart, inputPos, targetName, - "DragStart was finalized early (pointerUp/drop/endDrag dispatched via cleanup) because Unity paused during Pause Point inspection before the start animation finished. No drag session is active; call DragStart again to retry."); + MouseAction.DragStart, inputPos, targetName, "DragStart was finalized early (pointerUp/drop/endDrag dispatched via cleanup) because Unity paused during Pause Point inspection before the start animation finished. No drag session is active; call DragStart again to retry."); } await MainThreadSwitcher.SwitchToMainThread(ct); animationCompleted = true; @@ -138,29 +120,18 @@ internal static async Task ExecuteDragStart( return new SimulateMouseUiResponse { - Success = true, - Message = $"Drag started on '{targetName}' at ({inputPos.x:F1}, {inputPos.y:F1})", - Action = MouseAction.DragStart.ToString(), - HitGameObjectName = targetName, - PositionX = inputPos.x, - PositionY = inputPos.y + Success = true, Message = $"Drag started on '{targetName}' at ({inputPos.x:F1}, {inputPos.y:F1})", Action = MouseAction.DragStart.ToString(), HitGameObjectName = targetName, PositionX = inputPos.x, PositionY = inputPos.y }; } internal static async Task ExecuteDragMove( - MouseUiSimulationCommand parameters, - MouseUiMainThreadCleanupScheduler cleanupScheduler, - CancellationToken ct) + MouseUiSimulationCommand parameters, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) { if (!MouseDragState.IsDragging) { return new SimulateMouseUiResponse { - Success = false, - Message = "No drag in progress. Call DragStart first.", - Action = MouseAction.DragMove.ToString(), - PositionX = parameters.X, - PositionY = parameters.Y + Success = false, Message = "No drag in progress. Call DragStart first.", Action = MouseAction.DragMove.ToString(), PositionX = parameters.X, PositionY = parameters.Y }; } @@ -180,15 +151,11 @@ internal static async Task ExecuteDragMove( string targetName = target.name; SimulateMouseUiOverlayState.Update( - MouseAction.DragMove, - MouseUiCoordinateConverter.ScreenToInput(pointerData.position), - SimulateMouseUiOverlayState.DragStartPosition, - targetName, Handles.GetMainGameViewSize()); + MouseAction.DragMove, MouseUiCoordinateConverter.ScreenToInput(pointerData.position), SimulateMouseUiOverlayState.DragStartPosition, Handles.GetMainGameViewSize()); // Cancellation leaves drag state intact so the user can continue with DragMove/DragEnd MouseUiFrameWaitOutcome dragOutcome = await MouseUiDragEventExecutor.InterpolateDragPosition( - pointerData, target, screenEnd, - parameters.DragSpeed, ct).ConfigureAwait(false); + pointerData, target, screenEnd, parameters.DragSpeed, ct).ConfigureAwait(false); if (dragOutcome == MouseUiFrameWaitOutcome.TimedOut) { cleanupScheduler.QueueOverlayClear(); @@ -198,8 +165,7 @@ internal static async Task ExecuteDragMove( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.DragMove, inputEnd, targetName, - "DragMove was interrupted because Unity paused during Pause Point inspection while interpolating. The drag session is still active (not finalized); the pointer may not have reached the requested position. Call DragMove or DragEnd to continue."); + MouseAction.DragMove, inputEnd, targetName, "DragMove was interrupted because Unity paused during Pause Point inspection while interpolating. The drag session is still active (not finalized); the pointer may not have reached the requested position. Call DragMove or DragEnd to continue."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -207,29 +173,18 @@ internal static async Task ExecuteDragMove( return new SimulateMouseUiResponse { - Success = true, - Message = $"Drag moved on '{targetName}' to ({inputEnd.x:F1}, {inputEnd.y:F1}) at {parameters.DragSpeed:F0} px/s", - Action = MouseAction.DragMove.ToString(), - HitGameObjectName = targetName, - PositionX = inputEnd.x, - PositionY = inputEnd.y + Success = true, Message = $"Drag moved on '{targetName}' to ({inputEnd.x:F1}, {inputEnd.y:F1}) at {parameters.DragSpeed:F0} px/s", Action = MouseAction.DragMove.ToString(), HitGameObjectName = targetName, PositionX = inputEnd.x, PositionY = inputEnd.y }; } internal static async Task ExecuteDragEnd( - MouseUiSimulationCommand parameters, - MouseUiMainThreadCleanupScheduler cleanupScheduler, - CancellationToken ct) + MouseUiSimulationCommand parameters, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) { if (!MouseDragState.IsDragging) { return new SimulateMouseUiResponse { - Success = false, - Message = "No drag in progress. Call DragStart first.", - Action = MouseAction.DragEnd.ToString(), - PositionX = parameters.X, - PositionY = parameters.Y + Success = false, Message = "No drag in progress. Call DragStart first.", Action = MouseAction.DragEnd.ToString(), PositionX = parameters.X, PositionY = parameters.Y }; } @@ -249,19 +204,14 @@ internal static async Task ExecuteDragEnd( string targetName = target.name; (GameObject? explicitDropTarget, SimulateMouseUiResponse? dropFailureResponse) = MouseUiPointerTargetResolver.ResolveDropTargetPath( - parameters, - MouseAction.DragEnd, - inputEnd); + parameters, MouseAction.DragEnd, inputEnd); if (dropFailureResponse != null) { return dropFailureResponse; } SimulateMouseUiOverlayState.Update( - MouseAction.DragEnd, - MouseUiCoordinateConverter.ScreenToInput(pointerData.position), - SimulateMouseUiOverlayState.DragStartPosition, - targetName, Handles.GetMainGameViewSize()); + MouseAction.DragEnd, MouseUiCoordinateConverter.ScreenToInput(pointerData.position), SimulateMouseUiOverlayState.DragStartPosition, Handles.GetMainGameViewSize()); // Any Paused exit inside this try still runs FinalizeDrag + MouseDragState.Clear() // in the finally below, so every in-try branch reports the drag as finalized early. @@ -271,8 +221,7 @@ internal static async Task ExecuteDragEnd( try { MouseUiFrameWaitOutcome dragOutcome = await MouseUiDragEventExecutor.InterpolateDragPosition( - pointerData, target, screenEnd, - parameters.DragSpeed, ct).ConfigureAwait(false); + pointerData, target, screenEnd, parameters.DragSpeed, ct).ConfigureAwait(false); if (dragOutcome == MouseUiFrameWaitOutcome.TimedOut) { cleanupScheduler.QueueOverlayClear(); @@ -310,7 +259,7 @@ internal static async Task ExecuteDragEnd( } SimulateMouseUiOverlayState.Update( - MouseAction.DragEnd, inputEnd, null, targetName, Handles.GetMainGameViewSize()); + MouseAction.DragEnd, inputEnd, null, Handles.GetMainGameViewSize()); MouseUiFrameWaitOutcome dissipateOutcome = await MouseUiOverlayAnimator.PlayDissipateAnimation(ct).ConfigureAwait(false); if (dissipateOutcome == MouseUiFrameWaitOutcome.TimedOut) @@ -322,8 +271,7 @@ internal static async Task ExecuteDragEnd( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.DragEnd, inputEnd, targetName, - "DragEnd was already completed (target position reached, pointerUp/drop/endDrag dispatched, drag state cleared). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); + MouseAction.DragEnd, inputEnd, targetName, "DragEnd was already completed (target position reached, pointerUp/drop/endDrag dispatched, drag state cleared). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -340,9 +288,7 @@ internal static async Task ExecuteDragEnd( SimulateMouseUiOverlayState.Clear(); return new SimulateMouseUiResponse { - Success = false, - Message = "Drag target was destroyed or deactivated during drag.", - Action = action.ToString() + Success = false, Message = "Drag target was destroyed or deactivated during drag.", Action = action.ToString() }; } @@ -353,9 +299,7 @@ internal static async Task ExecuteDragEnd( SimulateMouseUiOverlayState.Clear(); return new SimulateMouseUiResponse { - Success = false, - Message = "Drag was interrupted by user input or system event.", - Action = action.ToString() + Success = false, Message = "Drag was interrupted by user input or system event.", Action = action.ToString() }; } diff --git a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiOneShotDragExecutor.cs b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiOneShotDragExecutor.cs index 35e0891c1c..cf00f1c93f 100644 --- a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiOneShotDragExecutor.cs +++ b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiOneShotDragExecutor.cs @@ -16,10 +16,7 @@ namespace io.github.hatayama.UnityCliLoop.FirstPartyTools internal static class MouseUiOneShotDragExecutor { internal static async Task ExecuteDragOneShot( - MouseUiSimulationCommand parameters, - EventSystem eventSystem, - MouseUiMainThreadCleanupScheduler cleanupScheduler, - CancellationToken ct) + MouseUiSimulationCommand parameters, EventSystem eventSystem, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) { Vector2 inputStart = new(parameters.FromX, parameters.FromY); Vector2 inputEnd = new(parameters.X, parameters.Y); @@ -27,11 +24,7 @@ internal static async Task ExecuteDragOneShot( Vector2 screenEnd = MouseUiCoordinateConverter.InputToScreen(inputEnd); (RaycastResult startRaycast, GameObject? target, SimulateMouseUiResponse? targetFailureResponse) = MouseUiDragTargetResolver.Resolve( - parameters, - eventSystem, - MouseAction.Drag, - inputStart, - screenStart); + parameters, eventSystem, MouseAction.Drag, inputStart, screenStart); if (targetFailureResponse != null) { return targetFailureResponse; @@ -39,9 +32,7 @@ internal static async Task ExecuteDragOneShot( (GameObject? explicitDropTarget, SimulateMouseUiResponse? dropFailureResponse) = MouseUiPointerTargetResolver.ResolveDropTargetPath( - parameters, - MouseAction.Drag, - inputEnd); + parameters, MouseAction.Drag, inputEnd); if (dropFailureResponse != null) { return dropFailureResponse; @@ -50,7 +41,7 @@ internal static async Task ExecuteDragOneShot( if (target == null) { SimulateMouseUiOverlayState.Update( - MouseAction.Drag, inputStart, null, null, Handles.GetMainGameViewSize()); + MouseAction.Drag, inputStart, null, Handles.GetMainGameViewSize()); MouseUiFrameWaitOutcome noTargetExpandOutcome = await MouseUiOverlayAnimator.PlayExpandAnimation(ct).ConfigureAwait(false); if (noTargetExpandOutcome == MouseUiFrameWaitOutcome.TimedOut) { @@ -61,8 +52,7 @@ internal static async Task ExecuteDragOneShot( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.Drag, inputStart, null, - "Drag stopped because Unity paused during Pause Point inspection. No draggable target was found at the start position, so no drag was initiated."); + MouseAction.Drag, inputStart, null, "Drag stopped because Unity paused during Pause Point inspection. No draggable target was found at the start position, so no drag was initiated."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -76,22 +66,15 @@ internal static async Task ExecuteDragOneShot( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.Drag, inputStart, null, - "Drag stopped because Unity paused during Pause Point inspection. No draggable target was found at the start position, so no drag was initiated."); + MouseAction.Drag, inputStart, null, "Drag stopped because Unity paused during Pause Point inspection. No draggable target was found at the start position, so no drag was initiated."); } await MainThreadSwitcher.SwitchToMainThread(ct); return new SimulateMouseUiResponse { - Success = false, - Message = parameters.BypassRaycast + Success = false, Message = parameters.BypassRaycast ? $"TargetPath '{parameters.TargetPath}' has no drag handler." - : $"No draggable UI element at ({inputStart.x:F1}, {inputStart.y:F1}). Use find-game-objects or screenshot to verify positions.", - Action = MouseAction.Drag.ToString(), - PositionX = inputStart.x, - PositionY = inputStart.y, - EndPositionX = inputEnd.x, - EndPositionY = inputEnd.y + : $"No draggable UI element at ({inputStart.x:F1}, {inputStart.y:F1}). Use find-game-objects or screenshot to verify positions.", Action = MouseAction.Drag.ToString(), PositionX = inputStart.x, PositionY = inputStart.y, EndPositionX = inputEnd.x, EndPositionY = inputEnd.y }; } @@ -102,7 +85,7 @@ internal static async Task ExecuteDragOneShot( string targetName = target.name; SimulateMouseUiOverlayState.Update( - MouseAction.Drag, inputStart, inputStart, targetName, Handles.GetMainGameViewSize()); + MouseAction.Drag, inputStart, inputStart, Handles.GetMainGameViewSize()); // Any Paused exit inside this try still runs FinalizeDrag in the finally below // (pointerUp/drop/endDrag), so every branch reports the drag as finalized early @@ -161,7 +144,7 @@ internal static async Task ExecuteDragOneShot( } SimulateMouseUiOverlayState.Update( - MouseAction.Drag, inputEnd, inputStart, targetName, Handles.GetMainGameViewSize()); + MouseAction.Drag, inputEnd, inputStart, Handles.GetMainGameViewSize()); MouseUiFrameWaitOutcome dissipateOutcome = await MouseUiOverlayAnimator.PlayDissipateAnimation(ct).ConfigureAwait(false); if (dissipateOutcome == MouseUiFrameWaitOutcome.TimedOut) @@ -173,8 +156,7 @@ internal static async Task ExecuteDragOneShot( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.Drag, inputStart, targetName, - "Drag was already completed (target position reached, pointerUp/drop/endDrag dispatched). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); + MouseAction.Drag, inputStart, targetName, "Drag was already completed (target position reached, pointerUp/drop/endDrag dispatched). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); } await MainThreadSwitcher.SwitchToMainThread(ct); diff --git a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiPressActionExecutor.cs b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiPressActionExecutor.cs index 1eabaffeee..f6fc13c903 100644 --- a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiPressActionExecutor.cs +++ b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiPressActionExecutor.cs @@ -16,10 +16,7 @@ namespace io.github.hatayama.UnityCliLoop.FirstPartyTools internal static class MouseUiPressActionExecutor { internal static async Task ExecuteClick( - MouseUiSimulationCommand parameters, - EventSystem eventSystem, - MouseUiMainThreadCleanupScheduler cleanupScheduler, - CancellationToken ct) + MouseUiSimulationCommand parameters, EventSystem eventSystem, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) { Vector2 inputPos = new(parameters.X, parameters.Y); Vector2 screenPos = MouseUiCoordinateConverter.InputToScreen(inputPos); @@ -36,19 +33,14 @@ internal static async Task ExecuteClick( { return new SimulateMouseUiResponse { - Success = false, - Message = $"TargetPath '{parameters.TargetPath}' has no pointer click or pointer down handler.", - Action = MouseAction.Click.ToString(), - PositionX = inputPos.x, - PositionY = inputPos.y + Success = false, Message = $"TargetPath '{parameters.TargetPath}' has no pointer click or pointer down handler.", Action = MouseAction.Click.ToString(), PositionX = inputPos.x, PositionY = inputPos.y }; } string? targetName = resolvedTargets.Target?.name; bool hitTarget = resolvedTargets.Target != null; SimulateMouseUiOverlayState.Update( - MouseAction.Click, inputPos, null, - targetName, Handles.GetMainGameViewSize()); + MouseAction.Click, inputPos, null, Handles.GetMainGameViewSize()); MouseUiFrameWaitOutcome expandOutcome = await MouseUiOverlayAnimator.PlayExpandAnimation(ct).ConfigureAwait(false); if (expandOutcome == MouseUiFrameWaitOutcome.TimedOut) @@ -60,8 +52,7 @@ internal static async Task ExecuteClick( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.Click, inputPos, targetName, - "Click stopped because Unity paused during Pause Point inspection before the click was dispatched. No pointer event was fired."); + MouseAction.Click, inputPos, targetName, "Click stopped because Unity paused during Pause Point inspection before the click was dispatched. No pointer event was fired."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -78,8 +69,7 @@ internal static async Task ExecuteClick( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.Click, inputPos, targetName, - "Click was already dispatched. Unity paused during Pause Point inspection while the click overlay animation was still playing; only the animation was interrupted."); + MouseAction.Click, inputPos, targetName, "Click was already dispatched. Unity paused during Pause Point inspection while the click overlay animation was still playing; only the animation was interrupted."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -87,18 +77,13 @@ internal static async Task ExecuteClick( } internal static async Task ExecuteLongPress( - MouseUiSimulationCommand parameters, - EventSystem eventSystem, - MouseUiMainThreadCleanupScheduler cleanupScheduler, - CancellationToken ct) + MouseUiSimulationCommand parameters, EventSystem eventSystem, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) { if (parameters.Duration <= 0f || float.IsNaN(parameters.Duration) || float.IsInfinity(parameters.Duration)) { return new SimulateMouseUiResponse { - Success = false, - Message = $"Duration must be positive, got: {parameters.Duration}", - Action = MouseAction.LongPress.ToString() + Success = false, Message = $"Duration must be positive, got: {parameters.Duration}", Action = MouseAction.LongPress.ToString() }; } @@ -117,11 +102,7 @@ internal static async Task ExecuteLongPress( { return new SimulateMouseUiResponse { - Success = false, - Message = $"TargetPath '{parameters.TargetPath}' has no pointer down or pointer click handler.", - Action = MouseAction.LongPress.ToString(), - PositionX = inputPos.x, - PositionY = inputPos.y + Success = false, Message = $"TargetPath '{parameters.TargetPath}' has no pointer down or pointer click handler.", Action = MouseAction.LongPress.ToString(), PositionX = inputPos.x, PositionY = inputPos.y }; } @@ -129,8 +110,7 @@ internal static async Task ExecuteLongPress( bool hitTarget = resolvedTargets.Target != null; bool shouldReleasePointer = resolvedTargets.RawTarget != null && resolvedTargets.Target != null; SimulateMouseUiOverlayState.Update( - MouseAction.LongPress, inputPos, null, - targetName, Handles.GetMainGameViewSize()); + MouseAction.LongPress, inputPos, null, Handles.GetMainGameViewSize()); MouseUiFrameWaitOutcome expandOutcome = await MouseUiOverlayAnimator.PlayExpandAnimation(ct).ConfigureAwait(false); if (expandOutcome == MouseUiFrameWaitOutcome.TimedOut) @@ -142,8 +122,7 @@ internal static async Task ExecuteLongPress( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.LongPress, inputPos, targetName, - "Long-press stopped because Unity paused during Pause Point inspection before pointerDown was dispatched. No pointer event was fired."); + MouseAction.LongPress, inputPos, targetName, "Long-press stopped because Unity paused during Pause Point inspection before pointerDown was dispatched. No pointer event was fired."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -168,8 +147,7 @@ internal static async Task ExecuteLongPress( // Returning here still runs the finally below, which releases pointerUp early. cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.LongPress, inputPos, targetName, - "Long-press pointerDown was already dispatched. Unity paused during Pause Point inspection while holding; pointerUp was released early and the press duration was cut short."); + MouseAction.LongPress, inputPos, targetName, "Long-press pointerDown was already dispatched. Unity paused during Pause Point inspection while holding; pointerUp was released early and the press duration was cut short."); } await MainThreadSwitcher.SwitchToMainThread(ct); elapsed = Time.realtimeSinceStartup - startTime; @@ -196,8 +174,7 @@ internal static async Task ExecuteLongPress( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.LongPress, inputPos, targetName, - "Long-press was already completed (pointerDown and pointerUp both dispatched). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); + MouseAction.LongPress, inputPos, targetName, "Long-press was already completed (pointerDown and pointerUp both dispatched). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -205,8 +182,7 @@ internal static async Task ExecuteLongPress( } private static void ExecutePointerClickEvents( - ResolvedPointerTargets resolvedTargets, - PointerEventData pointerData) + ResolvedPointerTargets resolvedTargets, PointerEventData pointerData) { if (resolvedTargets.RawTarget == null) { @@ -216,31 +192,24 @@ private static void ExecutePointerClickEvents( if (resolvedTargets.PressTarget != null) { ExecuteEvents.ExecuteHierarchy( - resolvedTargets.RawTarget, - pointerData, - ExecuteEvents.pointerDownHandler); + resolvedTargets.RawTarget, pointerData, ExecuteEvents.pointerDownHandler); } if (resolvedTargets.Target != null) { ExecuteEvents.Execute( - resolvedTargets.Target, - pointerData, - ExecuteEvents.pointerUpHandler); + resolvedTargets.Target, pointerData, ExecuteEvents.pointerUpHandler); } if (resolvedTargets.ClickTarget != null) { ExecuteEvents.Execute( - resolvedTargets.ClickTarget, - pointerData, - ExecuteEvents.pointerClickHandler); + resolvedTargets.ClickTarget, pointerData, ExecuteEvents.pointerClickHandler); } } private static void ExecuteLongPressPointerDown( - ResolvedPointerTargets resolvedTargets, - PointerEventData pointerData) + ResolvedPointerTargets resolvedTargets, PointerEventData pointerData) { if (resolvedTargets.RawTarget == null || resolvedTargets.Target == null) { @@ -248,9 +217,7 @@ private static void ExecuteLongPressPointerDown( } ExecuteEvents.ExecuteHierarchy( - resolvedTargets.RawTarget, - pointerData, - ExecuteEvents.pointerDownHandler); + resolvedTargets.RawTarget, pointerData, ExecuteEvents.pointerDownHandler); } } } diff --git a/Packages/src/Editor/FirstPartyTools/Watch/WatchExpressionStepMonitor.cs b/Packages/src/Editor/FirstPartyTools/Watch/WatchExpressionStepMonitor.cs index 8789a85eed..18c3eb4eb1 100644 --- a/Packages/src/Editor/FirstPartyTools/Watch/WatchExpressionStepMonitor.cs +++ b/Packages/src/Editor/FirstPartyTools/Watch/WatchExpressionStepMonitor.cs @@ -26,17 +26,6 @@ public void Start() _isStarted = true; } - public void Stop() - { - if (!_isStarted) - { - return; - } - - EditorApplication.update -= OnEditorUpdate; - _isStarted = false; - } - private void OnEditorUpdate() { _registry.EvaluateIfFrameChanged(); diff --git a/Packages/src/Runtime/SimulateMouseInput/SimulateMouseInputOverlayState.cs b/Packages/src/Runtime/SimulateMouseInput/SimulateMouseInputOverlayState.cs index 8c8a434293..77f27824cf 100644 --- a/Packages/src/Runtime/SimulateMouseInput/SimulateMouseInputOverlayState.cs +++ b/Packages/src/Runtime/SimulateMouseInput/SimulateMouseInputOverlayState.cs @@ -87,11 +87,6 @@ public void SetScrollDirection(int direction) LastActivityTime = Time.realtimeSinceStartup; } - public void ClearScroll() - { - _scrollActiveUntil = 0f; - } - public void SetMoveDelta(Vector2 delta) { _moveAccumulator += delta; @@ -159,11 +154,6 @@ public static void SetScrollDirection(int direction) ServiceValue.SetScrollDirection(direction); } - public static void ClearScroll() - { - ServiceValue.ClearScroll(); - } - public static void SetMoveDelta(Vector2 delta) { ServiceValue.SetMoveDelta(delta); diff --git a/Packages/src/Runtime/SimulateMouseUi/SimulateMouseUiOverlayState.cs b/Packages/src/Runtime/SimulateMouseUi/SimulateMouseUiOverlayState.cs index 8eb74136ca..d2d44513a2 100644 --- a/Packages/src/Runtime/SimulateMouseUi/SimulateMouseUiOverlayState.cs +++ b/Packages/src/Runtime/SimulateMouseUi/SimulateMouseUiOverlayState.cs @@ -14,7 +14,6 @@ public sealed class SimulateMouseUiOverlayStateService public MouseAction Action { get; private set; } public Vector2 CurrentPosition { get; private set; } public Vector2? DragStartPosition { get; private set; } - public string? HitGameObjectName { get; private set; } // Screen.width/height at the time positions were recorded (Editor context may differ from Game context) public Vector2 SourceScreenSize { get; private set; } @@ -36,7 +35,6 @@ public void Update( MouseAction action, Vector2 currentPosition, Vector2? dragStartPosition, - string? hitGameObjectName, Vector2 sourceScreenSize) { // PlayDissipateAnimation calls Clear() on normal completion, but a cancelled or stuck drag @@ -50,7 +48,6 @@ public void Update( Action = action; CurrentPosition = currentPosition; DragStartPosition = dragStartPosition; - HitGameObjectName = hitGameObjectName; SourceScreenSize = sourceScreenSize; } @@ -113,7 +110,6 @@ public void Clear() Action = default; CurrentPosition = Vector2.zero; DragStartPosition = null; - HitGameObjectName = null; SourceScreenSize = Vector2.zero; LongPressElapsed = 0f; _dragWaypoints.Clear(); @@ -132,7 +128,6 @@ public static class SimulateMouseUiOverlayState public static MouseAction Action => ServiceValue.Action; public static Vector2 CurrentPosition => ServiceValue.CurrentPosition; public static Vector2? DragStartPosition => ServiceValue.DragStartPosition; - public static string? HitGameObjectName => ServiceValue.HitGameObjectName; public static Vector2 SourceScreenSize => ServiceValue.SourceScreenSize; public static float LongPressElapsed => ServiceValue.LongPressElapsed; public static IReadOnlyList DragWaypoints => ServiceValue.DragWaypoints; @@ -141,10 +136,9 @@ public static void Update( MouseAction action, Vector2 currentPosition, Vector2? dragStartPosition, - string? hitGameObjectName, Vector2 sourceScreenSize) { - ServiceValue.Update(action, currentPosition, dragStartPosition, hitGameObjectName, sourceScreenSize); + ServiceValue.Update(action, currentPosition, dragStartPosition, sourceScreenSize); } public static void UpdateLongPressElapsed(float elapsed) From e148e15c5c0ef859b64c71d2ac3328bd1bcc5dd2 Mon Sep 17 00:00:00 2001 From: hatayama Date: Sun, 26 Jul 2026 03:25:54 +0900 Subject: [PATCH 2/3] Restore MouseUi formatting and keep Update-arg diffs surgical Collapse-only rewrites made the hitGameObjectName removal unreviewable. Restore base wrapping, drop only that argument, and document that agents must not reformat unrelated C# when making surgical triage edits. Co-authored-by: Cursor --- AGENTS.md | 4 + .../InputRecording/InputReplayUiController.cs | 45 ++++++-- .../MouseUiIncrementalDragExecutor.cs | 102 ++++++++++++++---- .../MouseUiOneShotDragExecutor.cs | 34 ++++-- .../MouseUiPressActionExecutor.cs | 69 ++++++++---- 5 files changed, 197 insertions(+), 57 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 45301ec4a2..5fca7be000 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,6 +35,10 @@ Comments in the code, commit messages, PR titles, and PR descriptions must all b Every test method must have a short comment that states what behavior the test verifies. +Do not reformat unrelated code. Surgical edits must keep existing wrapping and layout; only +change lines required by the task. Do not run C# formatters, IDE format-on-save, or rewrite +scripts that collapse multi-line argument lists or object initializers into one-liners. + ## CLI / Unity Package Compatibility Runtime compatibility between the Unity package and the native CLI is gated on an integer diff --git a/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputReplayUiController.cs b/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputReplayUiController.cs index d0ed876e87..06757fec26 100644 --- a/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputReplayUiController.cs +++ b/Packages/src/Editor/FirstPartyTools/Common/InputRecording/InputReplayUiController.cs @@ -80,7 +80,10 @@ private void ApplyUiPointerActivity(UiReplayFrame replayFrame) _pressTime = Time.realtimeSinceStartup; OnUiPointerDown(replayFrame.ScreenPosition, replayFrame.EventSystem); SimulateMouseUiOverlayState.Update( - MouseAction.Click, replayFrame.InputPosition, null, replayFrame.GameViewSize); + MouseAction.Click, + replayFrame.InputPosition, + null, + replayFrame.GameViewSize); SimulateMouseUiOverlayState.RequestExpandAnimation(); return; } @@ -97,7 +100,10 @@ private void ApplyUiPointerActivity(UiReplayFrame replayFrame) // from being cancelled by the next idle frame at the same position. _suppressIdleUiOverlay = false; SimulateMouseUiOverlayState.Update( - MouseAction.Click, replayFrame.InputPosition, null, replayFrame.GameViewSize); + MouseAction.Click, + replayFrame.InputPosition, + null, + replayFrame.GameViewSize); } } @@ -108,9 +114,13 @@ private void ApplyUiPointerHold(UiReplayFrame replayFrame) if (_isDragging) { Vector2 pressInputPos = new( - _pressScreenPosition.x, replayFrame.GameViewSize.y - _pressScreenPosition.y); + _pressScreenPosition.x, + replayFrame.GameViewSize.y - _pressScreenPosition.y); SimulateMouseUiOverlayState.Update( - MouseAction.Drag, replayFrame.InputPosition, pressInputPos, replayFrame.GameViewSize); + MouseAction.Drag, + replayFrame.InputPosition, + pressInputPos, + replayFrame.GameViewSize); return; } @@ -121,7 +131,10 @@ private void ApplyUiPointerHold(UiReplayFrame replayFrame) } SimulateMouseUiOverlayState.Update( - MouseAction.LongPress, replayFrame.InputPosition, null, replayFrame.GameViewSize); + MouseAction.LongPress, + replayFrame.InputPosition, + null, + replayFrame.GameViewSize); SimulateMouseUiOverlayState.UpdateLongPressElapsed(elapsed); } @@ -166,7 +179,14 @@ private void ApplyUiPointerRelease(UiReplayFrame replayFrame) Vector2 inputPos = new(screenPos.x, gameViewSize.y - screenPos.y); return new UiReplayFrame( - eventSystem, screenPos, inputPos, gameViewSize, leftHeld, justPressed, justReleased, mouseMoved); + eventSystem, + screenPos, + inputPos, + gameViewSize, + leftHeld, + justPressed, + justReleased, + mouseMoved); } private void OnUiPointerDown(Vector2 screenPos, EventSystem eventSystem) @@ -175,7 +195,9 @@ private void OnUiPointerDown(Vector2 screenPos, EventSystem eventSystem) _pointerData = new PointerEventData(eventSystem) { - position = screenPos, pressPosition = screenPos, button = PointerEventData.InputButton.Left + position = screenPos, + pressPosition = screenPos, + button = PointerEventData.InputButton.Left }; _pressScreenPosition = screenPos; _isDragging = false; @@ -322,7 +344,14 @@ private void SetUiInputModulesSuppressed(bool suppressed) private readonly struct UiReplayFrame { public UiReplayFrame( - EventSystem eventSystem, Vector2 screenPosition, Vector2 inputPosition, Vector2 gameViewSize, bool leftHeld, bool justPressed, bool justReleased, bool mouseMoved) + EventSystem eventSystem, + Vector2 screenPosition, + Vector2 inputPosition, + Vector2 gameViewSize, + bool leftHeld, + bool justPressed, + bool justReleased, + bool mouseMoved) { EventSystem = eventSystem; ScreenPosition = screenPosition; diff --git a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiIncrementalDragExecutor.cs b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiIncrementalDragExecutor.cs index 374e3e46e9..02832f459a 100644 --- a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiIncrementalDragExecutor.cs +++ b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiIncrementalDragExecutor.cs @@ -16,13 +16,20 @@ namespace io.github.hatayama.UnityCliLoop.FirstPartyTools internal static class MouseUiIncrementalDragExecutor { internal static async Task ExecuteDragStart( - MouseUiSimulationCommand parameters, EventSystem eventSystem, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) + MouseUiSimulationCommand parameters, + EventSystem eventSystem, + MouseUiMainThreadCleanupScheduler cleanupScheduler, + CancellationToken ct) { if (MouseDragState.IsDragging) { return new SimulateMouseUiResponse { - Success = false, Message = "A drag is already in progress. Call DragEnd first.", Action = MouseAction.DragStart.ToString(), PositionX = parameters.X, PositionY = parameters.Y + Success = false, + Message = "A drag is already in progress. Call DragEnd first.", + Action = MouseAction.DragStart.ToString(), + PositionX = parameters.X, + PositionY = parameters.Y }; } @@ -30,7 +37,11 @@ internal static async Task ExecuteDragStart( Vector2 screenPos = MouseUiCoordinateConverter.InputToScreen(inputPos); (RaycastResult startRaycast, GameObject? target, SimulateMouseUiResponse? targetFailureResponse) = MouseUiDragTargetResolver.Resolve( - parameters, eventSystem, MouseAction.DragStart, inputPos, screenPos); + parameters, + eventSystem, + MouseAction.DragStart, + inputPos, + screenPos); if (targetFailureResponse != null) { return targetFailureResponse; @@ -50,7 +61,8 @@ internal static async Task ExecuteDragStart( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.DragStart, inputPos, null, "DragStart stopped because Unity paused during Pause Point inspection. No draggable target was found at the position, so no drag was initiated."); + MouseAction.DragStart, inputPos, null, + "DragStart stopped because Unity paused during Pause Point inspection. No draggable target was found at the position, so no drag was initiated."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -64,15 +76,20 @@ internal static async Task ExecuteDragStart( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.DragStart, inputPos, null, "DragStart stopped because Unity paused during Pause Point inspection. No draggable target was found at the position, so no drag was initiated."); + MouseAction.DragStart, inputPos, null, + "DragStart stopped because Unity paused during Pause Point inspection. No draggable target was found at the position, so no drag was initiated."); } await MainThreadSwitcher.SwitchToMainThread(ct); return new SimulateMouseUiResponse { - Success = false, Message = parameters.BypassRaycast + Success = false, + Message = parameters.BypassRaycast ? $"TargetPath '{parameters.TargetPath}' has no drag handler." - : $"No draggable UI element at ({inputPos.x:F1}, {inputPos.y:F1}). Use find-game-objects or screenshot to verify positions.", Action = MouseAction.DragStart.ToString(), PositionX = inputPos.x, PositionY = inputPos.y + : $"No draggable UI element at ({inputPos.x:F1}, {inputPos.y:F1}). Use find-game-objects or screenshot to verify positions.", + Action = MouseAction.DragStart.ToString(), + PositionX = inputPos.x, + PositionY = inputPos.y }; } @@ -100,7 +117,8 @@ internal static async Task ExecuteDragStart( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.DragStart, inputPos, targetName, "DragStart was finalized early (pointerUp/drop/endDrag dispatched via cleanup) because Unity paused during Pause Point inspection before the start animation finished. No drag session is active; call DragStart again to retry."); + MouseAction.DragStart, inputPos, targetName, + "DragStart was finalized early (pointerUp/drop/endDrag dispatched via cleanup) because Unity paused during Pause Point inspection before the start animation finished. No drag session is active; call DragStart again to retry."); } await MainThreadSwitcher.SwitchToMainThread(ct); animationCompleted = true; @@ -120,18 +138,29 @@ internal static async Task ExecuteDragStart( return new SimulateMouseUiResponse { - Success = true, Message = $"Drag started on '{targetName}' at ({inputPos.x:F1}, {inputPos.y:F1})", Action = MouseAction.DragStart.ToString(), HitGameObjectName = targetName, PositionX = inputPos.x, PositionY = inputPos.y + Success = true, + Message = $"Drag started on '{targetName}' at ({inputPos.x:F1}, {inputPos.y:F1})", + Action = MouseAction.DragStart.ToString(), + HitGameObjectName = targetName, + PositionX = inputPos.x, + PositionY = inputPos.y }; } internal static async Task ExecuteDragMove( - MouseUiSimulationCommand parameters, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) + MouseUiSimulationCommand parameters, + MouseUiMainThreadCleanupScheduler cleanupScheduler, + CancellationToken ct) { if (!MouseDragState.IsDragging) { return new SimulateMouseUiResponse { - Success = false, Message = "No drag in progress. Call DragStart first.", Action = MouseAction.DragMove.ToString(), PositionX = parameters.X, PositionY = parameters.Y + Success = false, + Message = "No drag in progress. Call DragStart first.", + Action = MouseAction.DragMove.ToString(), + PositionX = parameters.X, + PositionY = parameters.Y }; } @@ -151,11 +180,15 @@ internal static async Task ExecuteDragMove( string targetName = target.name; SimulateMouseUiOverlayState.Update( - MouseAction.DragMove, MouseUiCoordinateConverter.ScreenToInput(pointerData.position), SimulateMouseUiOverlayState.DragStartPosition, Handles.GetMainGameViewSize()); + MouseAction.DragMove, + MouseUiCoordinateConverter.ScreenToInput(pointerData.position), + SimulateMouseUiOverlayState.DragStartPosition, + Handles.GetMainGameViewSize()); // Cancellation leaves drag state intact so the user can continue with DragMove/DragEnd MouseUiFrameWaitOutcome dragOutcome = await MouseUiDragEventExecutor.InterpolateDragPosition( - pointerData, target, screenEnd, parameters.DragSpeed, ct).ConfigureAwait(false); + pointerData, target, screenEnd, + parameters.DragSpeed, ct).ConfigureAwait(false); if (dragOutcome == MouseUiFrameWaitOutcome.TimedOut) { cleanupScheduler.QueueOverlayClear(); @@ -165,7 +198,8 @@ internal static async Task ExecuteDragMove( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.DragMove, inputEnd, targetName, "DragMove was interrupted because Unity paused during Pause Point inspection while interpolating. The drag session is still active (not finalized); the pointer may not have reached the requested position. Call DragMove or DragEnd to continue."); + MouseAction.DragMove, inputEnd, targetName, + "DragMove was interrupted because Unity paused during Pause Point inspection while interpolating. The drag session is still active (not finalized); the pointer may not have reached the requested position. Call DragMove or DragEnd to continue."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -173,18 +207,29 @@ internal static async Task ExecuteDragMove( return new SimulateMouseUiResponse { - Success = true, Message = $"Drag moved on '{targetName}' to ({inputEnd.x:F1}, {inputEnd.y:F1}) at {parameters.DragSpeed:F0} px/s", Action = MouseAction.DragMove.ToString(), HitGameObjectName = targetName, PositionX = inputEnd.x, PositionY = inputEnd.y + Success = true, + Message = $"Drag moved on '{targetName}' to ({inputEnd.x:F1}, {inputEnd.y:F1}) at {parameters.DragSpeed:F0} px/s", + Action = MouseAction.DragMove.ToString(), + HitGameObjectName = targetName, + PositionX = inputEnd.x, + PositionY = inputEnd.y }; } internal static async Task ExecuteDragEnd( - MouseUiSimulationCommand parameters, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) + MouseUiSimulationCommand parameters, + MouseUiMainThreadCleanupScheduler cleanupScheduler, + CancellationToken ct) { if (!MouseDragState.IsDragging) { return new SimulateMouseUiResponse { - Success = false, Message = "No drag in progress. Call DragStart first.", Action = MouseAction.DragEnd.ToString(), PositionX = parameters.X, PositionY = parameters.Y + Success = false, + Message = "No drag in progress. Call DragStart first.", + Action = MouseAction.DragEnd.ToString(), + PositionX = parameters.X, + PositionY = parameters.Y }; } @@ -204,14 +249,19 @@ internal static async Task ExecuteDragEnd( string targetName = target.name; (GameObject? explicitDropTarget, SimulateMouseUiResponse? dropFailureResponse) = MouseUiPointerTargetResolver.ResolveDropTargetPath( - parameters, MouseAction.DragEnd, inputEnd); + parameters, + MouseAction.DragEnd, + inputEnd); if (dropFailureResponse != null) { return dropFailureResponse; } SimulateMouseUiOverlayState.Update( - MouseAction.DragEnd, MouseUiCoordinateConverter.ScreenToInput(pointerData.position), SimulateMouseUiOverlayState.DragStartPosition, Handles.GetMainGameViewSize()); + MouseAction.DragEnd, + MouseUiCoordinateConverter.ScreenToInput(pointerData.position), + SimulateMouseUiOverlayState.DragStartPosition, + Handles.GetMainGameViewSize()); // Any Paused exit inside this try still runs FinalizeDrag + MouseDragState.Clear() // in the finally below, so every in-try branch reports the drag as finalized early. @@ -221,7 +271,8 @@ internal static async Task ExecuteDragEnd( try { MouseUiFrameWaitOutcome dragOutcome = await MouseUiDragEventExecutor.InterpolateDragPosition( - pointerData, target, screenEnd, parameters.DragSpeed, ct).ConfigureAwait(false); + pointerData, target, screenEnd, + parameters.DragSpeed, ct).ConfigureAwait(false); if (dragOutcome == MouseUiFrameWaitOutcome.TimedOut) { cleanupScheduler.QueueOverlayClear(); @@ -271,7 +322,8 @@ internal static async Task ExecuteDragEnd( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.DragEnd, inputEnd, targetName, "DragEnd was already completed (target position reached, pointerUp/drop/endDrag dispatched, drag state cleared). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); + MouseAction.DragEnd, inputEnd, targetName, + "DragEnd was already completed (target position reached, pointerUp/drop/endDrag dispatched, drag state cleared). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -288,7 +340,9 @@ internal static async Task ExecuteDragEnd( SimulateMouseUiOverlayState.Clear(); return new SimulateMouseUiResponse { - Success = false, Message = "Drag target was destroyed or deactivated during drag.", Action = action.ToString() + Success = false, + Message = "Drag target was destroyed or deactivated during drag.", + Action = action.ToString() }; } @@ -299,7 +353,9 @@ internal static async Task ExecuteDragEnd( SimulateMouseUiOverlayState.Clear(); return new SimulateMouseUiResponse { - Success = false, Message = "Drag was interrupted by user input or system event.", Action = action.ToString() + Success = false, + Message = "Drag was interrupted by user input or system event.", + Action = action.ToString() }; } diff --git a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiOneShotDragExecutor.cs b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiOneShotDragExecutor.cs index cf00f1c93f..73752a2929 100644 --- a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiOneShotDragExecutor.cs +++ b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiOneShotDragExecutor.cs @@ -16,7 +16,10 @@ namespace io.github.hatayama.UnityCliLoop.FirstPartyTools internal static class MouseUiOneShotDragExecutor { internal static async Task ExecuteDragOneShot( - MouseUiSimulationCommand parameters, EventSystem eventSystem, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) + MouseUiSimulationCommand parameters, + EventSystem eventSystem, + MouseUiMainThreadCleanupScheduler cleanupScheduler, + CancellationToken ct) { Vector2 inputStart = new(parameters.FromX, parameters.FromY); Vector2 inputEnd = new(parameters.X, parameters.Y); @@ -24,7 +27,11 @@ internal static async Task ExecuteDragOneShot( Vector2 screenEnd = MouseUiCoordinateConverter.InputToScreen(inputEnd); (RaycastResult startRaycast, GameObject? target, SimulateMouseUiResponse? targetFailureResponse) = MouseUiDragTargetResolver.Resolve( - parameters, eventSystem, MouseAction.Drag, inputStart, screenStart); + parameters, + eventSystem, + MouseAction.Drag, + inputStart, + screenStart); if (targetFailureResponse != null) { return targetFailureResponse; @@ -32,7 +39,9 @@ internal static async Task ExecuteDragOneShot( (GameObject? explicitDropTarget, SimulateMouseUiResponse? dropFailureResponse) = MouseUiPointerTargetResolver.ResolveDropTargetPath( - parameters, MouseAction.Drag, inputEnd); + parameters, + MouseAction.Drag, + inputEnd); if (dropFailureResponse != null) { return dropFailureResponse; @@ -52,7 +61,8 @@ internal static async Task ExecuteDragOneShot( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.Drag, inputStart, null, "Drag stopped because Unity paused during Pause Point inspection. No draggable target was found at the start position, so no drag was initiated."); + MouseAction.Drag, inputStart, null, + "Drag stopped because Unity paused during Pause Point inspection. No draggable target was found at the start position, so no drag was initiated."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -66,15 +76,22 @@ internal static async Task ExecuteDragOneShot( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.Drag, inputStart, null, "Drag stopped because Unity paused during Pause Point inspection. No draggable target was found at the start position, so no drag was initiated."); + MouseAction.Drag, inputStart, null, + "Drag stopped because Unity paused during Pause Point inspection. No draggable target was found at the start position, so no drag was initiated."); } await MainThreadSwitcher.SwitchToMainThread(ct); return new SimulateMouseUiResponse { - Success = false, Message = parameters.BypassRaycast + Success = false, + Message = parameters.BypassRaycast ? $"TargetPath '{parameters.TargetPath}' has no drag handler." - : $"No draggable UI element at ({inputStart.x:F1}, {inputStart.y:F1}). Use find-game-objects or screenshot to verify positions.", Action = MouseAction.Drag.ToString(), PositionX = inputStart.x, PositionY = inputStart.y, EndPositionX = inputEnd.x, EndPositionY = inputEnd.y + : $"No draggable UI element at ({inputStart.x:F1}, {inputStart.y:F1}). Use find-game-objects or screenshot to verify positions.", + Action = MouseAction.Drag.ToString(), + PositionX = inputStart.x, + PositionY = inputStart.y, + EndPositionX = inputEnd.x, + EndPositionY = inputEnd.y }; } @@ -156,7 +173,8 @@ internal static async Task ExecuteDragOneShot( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.Drag, inputStart, targetName, "Drag was already completed (target position reached, pointerUp/drop/endDrag dispatched). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); + MouseAction.Drag, inputStart, targetName, + "Drag was already completed (target position reached, pointerUp/drop/endDrag dispatched). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); } await MainThreadSwitcher.SwitchToMainThread(ct); diff --git a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiPressActionExecutor.cs b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiPressActionExecutor.cs index f6fc13c903..66795b2aa4 100644 --- a/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiPressActionExecutor.cs +++ b/Packages/src/Editor/FirstPartyTools/SimulateMouseUi/MouseUiPressActionExecutor.cs @@ -16,7 +16,10 @@ namespace io.github.hatayama.UnityCliLoop.FirstPartyTools internal static class MouseUiPressActionExecutor { internal static async Task ExecuteClick( - MouseUiSimulationCommand parameters, EventSystem eventSystem, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) + MouseUiSimulationCommand parameters, + EventSystem eventSystem, + MouseUiMainThreadCleanupScheduler cleanupScheduler, + CancellationToken ct) { Vector2 inputPos = new(parameters.X, parameters.Y); Vector2 screenPos = MouseUiCoordinateConverter.InputToScreen(inputPos); @@ -33,14 +36,19 @@ internal static async Task ExecuteClick( { return new SimulateMouseUiResponse { - Success = false, Message = $"TargetPath '{parameters.TargetPath}' has no pointer click or pointer down handler.", Action = MouseAction.Click.ToString(), PositionX = inputPos.x, PositionY = inputPos.y + Success = false, + Message = $"TargetPath '{parameters.TargetPath}' has no pointer click or pointer down handler.", + Action = MouseAction.Click.ToString(), + PositionX = inputPos.x, + PositionY = inputPos.y }; } string? targetName = resolvedTargets.Target?.name; bool hitTarget = resolvedTargets.Target != null; SimulateMouseUiOverlayState.Update( - MouseAction.Click, inputPos, null, Handles.GetMainGameViewSize()); + MouseAction.Click, inputPos, null, + Handles.GetMainGameViewSize()); MouseUiFrameWaitOutcome expandOutcome = await MouseUiOverlayAnimator.PlayExpandAnimation(ct).ConfigureAwait(false); if (expandOutcome == MouseUiFrameWaitOutcome.TimedOut) @@ -52,7 +60,8 @@ internal static async Task ExecuteClick( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.Click, inputPos, targetName, "Click stopped because Unity paused during Pause Point inspection before the click was dispatched. No pointer event was fired."); + MouseAction.Click, inputPos, targetName, + "Click stopped because Unity paused during Pause Point inspection before the click was dispatched. No pointer event was fired."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -69,7 +78,8 @@ internal static async Task ExecuteClick( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.Click, inputPos, targetName, "Click was already dispatched. Unity paused during Pause Point inspection while the click overlay animation was still playing; only the animation was interrupted."); + MouseAction.Click, inputPos, targetName, + "Click was already dispatched. Unity paused during Pause Point inspection while the click overlay animation was still playing; only the animation was interrupted."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -77,13 +87,18 @@ internal static async Task ExecuteClick( } internal static async Task ExecuteLongPress( - MouseUiSimulationCommand parameters, EventSystem eventSystem, MouseUiMainThreadCleanupScheduler cleanupScheduler, CancellationToken ct) + MouseUiSimulationCommand parameters, + EventSystem eventSystem, + MouseUiMainThreadCleanupScheduler cleanupScheduler, + CancellationToken ct) { if (parameters.Duration <= 0f || float.IsNaN(parameters.Duration) || float.IsInfinity(parameters.Duration)) { return new SimulateMouseUiResponse { - Success = false, Message = $"Duration must be positive, got: {parameters.Duration}", Action = MouseAction.LongPress.ToString() + Success = false, + Message = $"Duration must be positive, got: {parameters.Duration}", + Action = MouseAction.LongPress.ToString() }; } @@ -102,7 +117,11 @@ internal static async Task ExecuteLongPress( { return new SimulateMouseUiResponse { - Success = false, Message = $"TargetPath '{parameters.TargetPath}' has no pointer down or pointer click handler.", Action = MouseAction.LongPress.ToString(), PositionX = inputPos.x, PositionY = inputPos.y + Success = false, + Message = $"TargetPath '{parameters.TargetPath}' has no pointer down or pointer click handler.", + Action = MouseAction.LongPress.ToString(), + PositionX = inputPos.x, + PositionY = inputPos.y }; } @@ -110,7 +129,8 @@ internal static async Task ExecuteLongPress( bool hitTarget = resolvedTargets.Target != null; bool shouldReleasePointer = resolvedTargets.RawTarget != null && resolvedTargets.Target != null; SimulateMouseUiOverlayState.Update( - MouseAction.LongPress, inputPos, null, Handles.GetMainGameViewSize()); + MouseAction.LongPress, inputPos, null, + Handles.GetMainGameViewSize()); MouseUiFrameWaitOutcome expandOutcome = await MouseUiOverlayAnimator.PlayExpandAnimation(ct).ConfigureAwait(false); if (expandOutcome == MouseUiFrameWaitOutcome.TimedOut) @@ -122,7 +142,8 @@ internal static async Task ExecuteLongPress( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.LongPress, inputPos, targetName, "Long-press stopped because Unity paused during Pause Point inspection before pointerDown was dispatched. No pointer event was fired."); + MouseAction.LongPress, inputPos, targetName, + "Long-press stopped because Unity paused during Pause Point inspection before pointerDown was dispatched. No pointer event was fired."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -147,7 +168,8 @@ internal static async Task ExecuteLongPress( // Returning here still runs the finally below, which releases pointerUp early. cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.LongPress, inputPos, targetName, "Long-press pointerDown was already dispatched. Unity paused during Pause Point inspection while holding; pointerUp was released early and the press duration was cut short."); + MouseAction.LongPress, inputPos, targetName, + "Long-press pointerDown was already dispatched. Unity paused during Pause Point inspection while holding; pointerUp was released early and the press duration was cut short."); } await MainThreadSwitcher.SwitchToMainThread(ct); elapsed = Time.realtimeSinceStartup - startTime; @@ -174,7 +196,8 @@ internal static async Task ExecuteLongPress( { cleanupScheduler.QueueOverlayClear(); return MouseUiSimulationResponseFactory.CreateInterruptedResult( - MouseAction.LongPress, inputPos, targetName, "Long-press was already completed (pointerDown and pointerUp both dispatched). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); + MouseAction.LongPress, inputPos, targetName, + "Long-press was already completed (pointerDown and pointerUp both dispatched). Unity paused during Pause Point inspection while the overlay animation was still playing; only the animation was interrupted."); } await MainThreadSwitcher.SwitchToMainThread(ct); @@ -182,7 +205,8 @@ internal static async Task ExecuteLongPress( } private static void ExecutePointerClickEvents( - ResolvedPointerTargets resolvedTargets, PointerEventData pointerData) + ResolvedPointerTargets resolvedTargets, + PointerEventData pointerData) { if (resolvedTargets.RawTarget == null) { @@ -192,24 +216,31 @@ private static void ExecutePointerClickEvents( if (resolvedTargets.PressTarget != null) { ExecuteEvents.ExecuteHierarchy( - resolvedTargets.RawTarget, pointerData, ExecuteEvents.pointerDownHandler); + resolvedTargets.RawTarget, + pointerData, + ExecuteEvents.pointerDownHandler); } if (resolvedTargets.Target != null) { ExecuteEvents.Execute( - resolvedTargets.Target, pointerData, ExecuteEvents.pointerUpHandler); + resolvedTargets.Target, + pointerData, + ExecuteEvents.pointerUpHandler); } if (resolvedTargets.ClickTarget != null) { ExecuteEvents.Execute( - resolvedTargets.ClickTarget, pointerData, ExecuteEvents.pointerClickHandler); + resolvedTargets.ClickTarget, + pointerData, + ExecuteEvents.pointerClickHandler); } } private static void ExecuteLongPressPointerDown( - ResolvedPointerTargets resolvedTargets, PointerEventData pointerData) + ResolvedPointerTargets resolvedTargets, + PointerEventData pointerData) { if (resolvedTargets.RawTarget == null || resolvedTargets.Target == null) { @@ -217,7 +248,9 @@ private static void ExecuteLongPressPointerDown( } ExecuteEvents.ExecuteHierarchy( - resolvedTargets.RawTarget, pointerData, ExecuteEvents.pointerDownHandler); + resolvedTargets.RawTarget, + pointerData, + ExecuteEvents.pointerDownHandler); } } } From 07b461a29db38ef7c54908f8f791bf0dead4c1e4 Mon Sep 17 00:00:00 2001 From: hatayama Date: Sun, 26 Jul 2026 03:27:52 +0900 Subject: [PATCH 3/3] Remove agent formatting rule from PublicCandidate triage PR Keep PR-5 scoped to FirstPartyTools/Runtime deletions; the AGENTS.md rule belongs in a separate docs PR for clear history and review. Co-authored-by: Cursor --- AGENTS.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 5fca7be000..45301ec4a2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,10 +35,6 @@ Comments in the code, commit messages, PR titles, and PR descriptions must all b Every test method must have a short comment that states what behavior the test verifies. -Do not reformat unrelated code. Surgical edits must keep existing wrapping and layout; only -change lines required by the task. Do not run C# formatters, IDE format-on-save, or rewrite -scripts that collapse multi-line argument lists or object initializers into one-liners. - ## CLI / Unity Package Compatibility Runtime compatibility between the Unity package and the native CLI is gated on an integer