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
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
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.