Search Issue Tracker

By Design

Votes

1

Found in [Package]

1.9.4

Issue ID

UVSB-2572

Regression

No

Visual Scripting "OnEnterState" method is called before C# "Awake" when entering Play mode

Package: Visual Scripting

-

How to reproduce:
1. Open the attached “IN-86188“ project
2. Open the “Test Scene“
3. Enter Play mode
4. Observe the Console window

Expected result: “C# Awake” message gets printed before “VS Enter!”
Actual result: “VS Enter” is printed first

Reproducible in: 1.9.4 (2021.3.45f1, 2022.3.51f1, 6000.0.24f1, 6000.1.0a1)

Reproducible on: Windows 11
Not reproducible on: No other environment tested

Workaround: Duplicating an entity affected by the bug or rearranging its Components fixes the scripts execution order

Note: Could not test for regression. Unfixable exceptions are spit after downgrading the package.

  1. Resolution Note:

    This is by design, see https://docs.unity3d.com/Manual/execution-order.html. Quote:

    `Awake is only guaranteed to be called before OnEnable in the scope of each individual object. Across multiple objects the order is not deterministic and you can’t rely on one object’s Awake being called before another object’s OnEnable. Any work that depends on Awake having been called for all objects in the scene should be done in Start.`

    Thus, here we can't count on CharacterControllerAdapter_Player's Awake to be called before OnEnterState (which is sent from within OnEnable of the StateMachine -- a different object as far as the loading sequence is concerned ).

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.