Skip to content

Fast enter playmode support#1098

Open
sim-bz wants to merge 7 commits intomainfrom
uum-131015
Open

Fast enter playmode support#1098
sim-bz wants to merge 7 commits intomainfrom
uum-131015

Conversation

@sim-bz
Copy link
Contributor

@sim-bz sim-bz commented Feb 12, 2026

Purpose of this PR

https://jira.unity3d.com/browse/UUM-131015

Static variable management in Cinemachine to support fast enter playmode.

We'll need to add exceptions for

  • CinemachineFreeLook CreateRigOverride and DestroyRigOverride (because of static responders in CinemachineFreeLookEditor).
  • CinemachineVirtualCamera CreatePipelineOverride and DestroyPipelineOverride (because of static responders in CinemachineVirtualCameraEditor).
  • CinemachineCore CameraUpdatedEvent and CameraActivatedEvent (because of static responders in CinemachineVolumeSettings).

Testing status

[Explanation of what’s tested, how tested and existing or new automation tests. Can include manual testing by self and/or QA. Specify test plans. Rarely acceptable to have no testing.]

  • Added an automated test
  • Passed all automated tests
  • Manually tested

Documentation status

[Overview of how documentation is affected by this change. If there is no effect on documentation, explain why. Otherwise, state which sections are changed and why.]

  • Updated CHANGELOG
  • Updated README (if applicable)
  • Commented all public classes, properties, and methods
  • Updated user documentation

Technical risk

[Overall product level assessment of risk of change. Need technical risk & halo effect.]

Comments to reviewers

[Info per person for what to focus on, or historical info to understand who have previously reviewed and coverage. Help them get context.]

Package version

[Justification for updating either the patch, minor, or major version according to the semantic versioning rules]

  • Updated package version

@sim-bz sim-bz requested a review from richardk-u3d February 12, 2026 21:04
{
Array.Fill(s_ColliderBuffer, null);
Array.Fill(s_ColliderDistanceBuffer, 0f);
Array.Fill(s_ColliderOrderBuffer, 0);

Choose a reason for hiding this comment

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

FYI i am fixing the analyzer to consider calls to Array.Fill as successful initialization

private static void ResetStaticsOnLoad()
{
//CreateRigOverride = null;
//DestroyRigOverride = null;

Choose a reason for hiding this comment

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

intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I'll remove them or add an explanatory comment before I push, but I wanted to highlight the fact that I can't reset these delegates without breaking workflows elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, I don't know what would be the pragma to disable warnings about those

Copy link

@richardk-u3d richardk-u3d left a comment

Choose a reason for hiding this comment

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

some commented out bits im not sure about, but overall looks good

Copy link

@richardk-u3d richardk-u3d left a comment

Choose a reason for hiding this comment

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

need to figure out if having 2 RuntimeInitializeOnLoadMethod's is something we want to allow. the analyzer gets confised by it.

@sim-bz sim-bz marked this pull request as ready for review February 17, 2026 15:51
@sim-bz sim-bz requested a review from glabute as a code owner February 17, 2026 15:51
@u-pr
Copy link
Contributor

u-pr bot commented Feb 17, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

UUM-131015 - Fully compliant

Compliant requirements:

  • Implemented 'ResetStaticsOnLoad' with '[RuntimeInitializeOnLoadMethod]' across the codebase for identified classes (CinemachineCore, CinemachineDebug, CinemachineBlend, etc.).
  • Handled Editor-specific static resets (FreeLookEditor, VirtualCameraEditor).
  • Converted some statics to readonly or instance members where appropriate (CameraState, CinemachineOrbitalTransposer).
  • Handled exceptions for CinemachineCore events as noted in the PR description.
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪

The PR touches many files with a repetitive pattern to handle static resets, requiring verification of initialization logic and potential race conditions across Editor and Runtime assemblies.
🏅 Score: 92

The PR systematically addresses the Fast Enter Play Mode requirements with appropriate resets and architectural changes. A potential race condition in debug settings initialization prevents a perfect score.
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Race Condition

In CinemachineDebug.ResetStaticsOnLoad, GameViewGuidesEnabled is set to false. However, in CinemachineCorePrefs.ResetStaticsOnLoad (Editor), it is set to ShowInGameGuides.Value. Since both methods are decorated with [RuntimeInitializeOnLoadMethod], their execution order is undefined. If CinemachineDebug runs last, it will overwrite the user's preference with false. Consider removing the assignment in CinemachineDebug if the Editor script handles it, or consolidating the logic.

GameViewGuidesEnabled = false;
  • Update review

🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr

@u-pr
Copy link
Contributor

u-pr bot commented Feb 17, 2026

PR Code Suggestions ✨


🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr

@sim-bz sim-bz requested a review from richardk-u3d February 17, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants