Skip to content

feat: add stop control units and thread manager#308

Merged
oco777 merged 1 commit intomainfrom
codex/add-stop-control-units-to-scratch
Nov 15, 2025
Merged

feat: add stop control units and thread manager#308
oco777 merged 1 commit intomainfrom
codex/add-stop-control-units-to-scratch

Conversation

@oco777
Copy link
Copy Markdown
Owner

@oco777 oco777 commented Nov 15, 2025

Summary

  • add a script thread manager singleton for tracking running Scratch visual scripting coroutines
  • extend ScratchUnitUtil with helpers to store thread context on Flow variables
  • introduce Stop All/Stop This Script/Stop Other Scripts units and document them in VS_Scratch_Mapping.md

Testing

  • not run (not requested)

Codex Task

@oco777 oco777 merged commit 56195f7 into main Nov 15, 2025
3 checks passed
@oco777 oco777 deleted the codex/add-stop-control-units-to-scratch branch November 15, 2025 14:28
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +65 to +69
private ControlOutput OnEnter(Flow flow)
{
if (ScratchUnitUtil.TryGetThreadContext(flow, out _, out var threadId))
{
FUnityScriptThreadManager.Instance.StopThread(threadId);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop control units never stop anything

Both StopThisScriptUnit and StopOtherScriptsInSpriteUnit rely on ScratchUnitUtil.TryGetThreadContext (and ultimately FUnityScriptThreadManager) to find the current thread, but the commit never stores that context anywhere. The accompanying helper ScratchUnitUtil.SetThreadContext and FUnityScriptThreadManager.RegisterThread that would supply FUnity_ActorId/FUnity_ThreadId are never called anywhere in the repo, so the flow variables they read are never defined and the thread manager’s dictionary always stays empty. As a result the new Stop blocks are no-ops: TryGetThreadContext always returns false, so StopThread/StopThreadsOfActorExcept are never reached, and StopAllUnit also has nothing to stop. Please hook the runner/coroutine startup to register each script with the manager and call SetThreadContext so these units can actually stop scripts.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant