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
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.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Text is unreadable when DLSS is applied to the Canvas with Render Mode set to World Space
- NullReferenceException errors appear in the Console when changing the values of Visual Effect Control Clip Events' Attributes
- Crash on TextCore::OTL_TableReader::GetOpenTypeLayoutTables when using Japanese Font as TMP Fallback
- TreeView.AddItem performance regression when opening EditorWindow
- Shadows are not visible in Player when using DX12 with Forward+ or Deferred+ rendering in URP
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 ).