Unity Issue Tracker - Changes made in Awake function with ExecuteAlways attribute are overwritten when duplicating Prefab with a parent
Fixed
UUM-56488
Changes made in Awake function with ExecuteAlways attribute are overwritten when duplicating Prefab with a parent
Unity: Scene Management
Open
6.0.X
Fixed
2023.3.X
2022.3.X
Won't Fix
6.1.X
2023.2.X
2023.1.X
Cancelling this 2023.2 tech release issue since the support for this release has come to end of life. Cancelling this 2023.2 port case does not affect any LTS or Unity 6 Beta/Preview that remain open.
How to reproduce:
1. Open the attached “initialization_issue.zip” project
2. Open the SampleScene
3. Select the “testobject” under the “parent” GameObject in the Hierarchy
4. In the Inspector, set the “mat” field of the “Test Script” component to the “red” material
5. Duplicate (CTRL-D) or copy-paste (CTRL-C, CTRL-V) the “testobject”
6. Observe that the material of the duplicated GameObject does not change
Expected result: The material is applied to the GameObject when the Prefab is duplicated.
Actual result: The material is not applied when the Prefab has a parent
Reproducible on: Windows 11
Not reproducible on: No other environments tested
Notes:
When the Prefab has a parent, five functions are called when it is duplicated in the Hierarchy. However, when the Prefab has no parent, only three functions are called (see attached images).
Workaround (After performing the reproduction steps):
1. Drag and drop the original “testobject” out of the “parent” GameObject in the Hierarchy (make sure “testobject” does not have a parent)
2. Repeat reproduction step 5
3. Observe how the duplicated GameObject now applies the correct material
Prioritise and Follow this issue
Have a workaround or additional info about this issue?