Search Issue Tracker
By Design
Votes
0
Found in
2018.4
2019.4
2020.1
2020.1.17f1
2020.2
2021.1
2021.2
Issue ID
1315670
Regression
No
Changes made to Prefab's variable values in a custom EditorWindow get reverted when entering the Play mode
How to reproduce:
1. Open the user's attached project
2. Open 'SampleScene'
3. In the top bar menu select Example > Example Window
4. In the Example Window toggle the 'Use Start Time' checkbox
5. Enter the Play mode
6. Observe the Example Window
7. If the issue doesn't reproduce repeat steps 4-6 (usually reproduces on the second try)
Expected result: The 'Use Start Time' checkbox state doesn't change
Actual result: The 'Use Start Time' checkbox state gets reverted
Reproducible with: 2018.4.32f1, 2019.4.21f1, 2020.1.17f1, 2020.2.6f1, 2021.1.0b8, 2021.2.0a6
Notes:
- The issue is not reproducible after unpacking the ExampleScript Prefab
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
- Highlighter.Highlight does not find window when using class name as window title
- Highlighter.Highlight highlights a different component when multiple components have the same property path
- Highlighter.Highlight does not find elements in an array or list when the array or list is collapsed
- [URP][NRP] RenderPass, BeginSubPass, and EndRenderPass errors are thrown when Native RenderPass is enabled
- D3D11 swapchain error pop-up appears and the Editor shuts down when Generating Lighting with Probe Volumes present
Resolution Note:
When setting properties directly in the ExampleWindow (without using SerializedProperty) extra care have to be taken for overrides on Prefab instances to be recorded. There are two options here:
1) Ensure to call PrefabUtility.RecordPrefabInstancePropertyModifications(yourChangedObject) after changing properties.
2) Or call EditorUtility.SetDirty(yourChangedObject). This will indirectly call RecordPrefabInstancePropertyModifications at the end of frame for all dirty objects.
When going into Play mode the current open scene saved, so it can be reloaded after play mode, and then loaded again. When loading all Prefab instances will be merged and their overrides setup, but if overrides was not recorded properly then the state will appear wrong..
Note that when changing the toggle in the Inspector the state is correct in Play mode, but when using the ExampleWindow UI where RecordPrefabInstancePropertyModifications is missing the state is incorrect.