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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
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 ).