Port Unity stroke personalization source layers#103
Draft
sw1029 wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.6source-only stacked PR on top of Extract two-track personalization engine for survey evals #102: add the Unity-side Input capture, Stroke recognition, Personalization, and Presentation source layers..meta,Packages,ProjectSettings, screenshots, and capture artifacts.StrokeInputSession -> IStrokeRecognitionService -> SpellCastingService, with accepted casts recorded back into the tutorial personalization store.Related Issues
Why Needed
.5PR isolates the final two-track personalization policy from the survey prototype. This.6PR ports the Unity source-code side of that boundary without mixing generated Unity metadata or editor/package setup changes into the diff.WorldDrawingControllerpreviously combined pointer polling, stroke buffering, line rendering, recognition handoff, and legacyStrokeSampleoutput. The new structure gives each layer a narrow responsibility and gives recognition/personalization a stable session contract.Changed Boundaries
unity/MagicExamHall/Assets/MagicExamHall/Scripts/Input/unity/MagicExamHall/Assets/MagicExamHall/Scripts/Recognition/StrokeRecognitionService.csunity/MagicExamHall/Assets/MagicExamHall/Scripts/Personalization/TutorialPersonalizationProfile.csunity/MagicExamHall/Assets/MagicExamHall/Scripts/Presentation/WorldStrokeVisuals.csWorldDrawingController,ExamGameController,SpellCastingService,SpellRuntime,SpellRecognitionPixelArtFactory,PixelSpriteViewStrokeInputRecognitionHandoffTests.csCode Change Details
Input Capture Layer
StrokeInputTypes.csaddsInputCoordinateSpace,StrokeInputPoint,StrokeInputStroke, andStrokeInputSessionas the canonical Unity stroke session data model.StrokeInputSessionExtensionsbridges old and new models withFromStrokeSamples,ToStrokeSamples,GetWorldCenter, andEstimateWorldScale, so existing recognizers can be reused while new code depends on session objects.WorldPointerInputSourceowns pointer polling only: mouse button selection, UI hit filtering, screen-to-world conversion, min-distance point filtering, and start/update/complete/cancel events.StrokeSessionBuffergroups completed strokes into one session afterbufferSeconds, supports direct synthetic session submission, and resets cleanly on cancel.Stroke Recognition / Personalization Layer
StrokeRecognitionService.csintroducesIStrokeRecognitionService,RecognitionContext,StrokeRecognitionResult, andHeuristicStrokeRecognitionService.SpellCastingService.FindAttachableSeal, checks detached overlay candidates, then falls back to base spell recognition.RecordAcceptedResultstores only accepted base or overlay results as tutorial captures, avoiding failed or invalid casts from training the profile.TutorialPersonalizationProfile.csadds the Unity personalization store: threshold state calculation, capture retention, per-target evaluation, base/overlay personalization application, and feature extraction.Runtime Handoff
WorldDrawingControllernow composesWorldPointerInputSource,StrokeSessionBuffer, andWorldStrokeVisualsinstead of implementing all three concerns inline.StrokeSessionCompletedfor the new recognition path and keeps the legacySpellBufferedevent for tests/tools that still consumeStrokeSamplegroups.ExamGameControllerowns the recognition service, processes completed sessions, exposes personalization counters for tests, records successful outcomes, and keeps legacy synthetic spell submission working via session conversion.SpellCastingService.ProcessRecognitionResultconverts aStrokeRecognitionResultinto existingSpellCastOutcomevariants and attaches the recognition result to the outcome for downstream inspection.SpellRuntimeandSpellRecognitionnow carryTutorialPersonalizationSummaryalongside recognition results; base candidate ordering prefers true success before recognized-but-not-success states.Presentation / Runtime Cleanup
WorldStrokeVisualsowns LineRenderer creation, active stroke updates, completed stroke fading, and synthetic session visualization.PixelArtFactorycreates generated sprites withSpriteMeshType.FullRect, matching tiled sprite usage expectations.PixelSpriteViewdefers play-modeOnValidateapplication toLateUpdate, avoiding Unity editor lifecycle warnings from applying sprite changes during validation.Test Coverage
StrokeInputRecognitionHandoffTestsverifies session round-tripping, buffered stroke grouping, recognition-to-personalization capture recording, personalization summary availability after captures, and the guard that prevents invalid input from being promoted to success.GestureRecognizerTestsalso cover the updated service handoff methods and overlay routing behavior in the same EditMode run.Handoff
mainor rebase it ontomain..metafiles are excluded by request, this PR relies on Unity regenerating metadata for new scripts on import. The new runtime components are added dynamically byWorldDrawingController, so no serialized scene references are required in this source-only split..metaand scene files there rather than expanding this source-only PR.Verification
npm run validate:docsnpm testnpm run buildUnity.exe -batchmode -projectPath C:\Users\USER\magic\unity\MagicExamHall -runTests -testPlatform EditMode -testResults %TEMP%\magic-editmode-source-pr.xml -logFile %TEMP%\magic-unity-editmode-source-pr.log(51 passed).5survey/engine PR.Notes
.meta, package manifests, project settings, screenshots, capture artifacts, and MCP package files..metaGUIDs will differ unless committed in a later metadata PR.Review Checklist
Screenshots / Playtest Notes
No screenshot attached for this source-only split. Local verification was Unity EditMode test execution; generated screenshots and capture artifacts are intentionally excluded.