Skip to content

Register Scratch event threads in Visual Scripting#333

Merged
oco777 merged 1 commit intomainfrom
codex/add-scratch-thread-registration-in-eventunits
Nov 17, 2025
Merged

Register Scratch event threads in Visual Scripting#333
oco777 merged 1 commit intomainfrom
codex/add-scratch-thread-registration-in-eventunits

Conversation

@oco777
Copy link
Copy Markdown
Owner

@oco777 oco777 commented Nov 17, 2025

Summary

  • register Scratch event units with FUnityScriptThreadManager via StartScratchCoroutine to ensure stop blocks can target running scripts
  • add debug logging for Scratch coroutine startup and ensure listener data tracks EventBus registrations
  • update Visual Scripting mapping doc to reflect thread registration flow for Scratch events

Testing

  • not run (not requested)

Codex Task

@oco777 oco777 merged commit 6f95006 into main Nov 17, 2025
3 checks passed
@oco777 oco777 deleted the codex/add-scratch-thread-registration-in-eventunits branch November 17, 2025 12:30
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 +152 to +156
using (var flow = Flow.New(reference))
{
var routine = RunEventCoroutine(flow, args);
ScratchUnitUtil.StartScratchCoroutine(flow, routine);
}
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 Avoid registering scratch threads on every Update tick

In OnKeyPressedUnit.TriggerWithThreadRegistration the coroutine is always passed to ScratchUnitUtil.StartScratchCoroutine before RunEventCoroutine has a chance to evaluate ShouldTrigger. Because StartScratchCoroutine registers the coroutine with FUnityScriptThreadManager, an entry is added to m_ScratchThreads on every Update event even when no key is pressed (i.e., ShouldTrigger returns false). This creates an unbounded collection of idle thread registrations and stop-block targeting becomes inaccurate during normal gameplay, since most frames will register a new “thread” that immediately exits.

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