Environment
- Unity version:
6000.0.73f1
Description
SerializedDictionary does not serialize or refresh correctly when modified from script.
If the dictionary is modified via scripting such as in OnEnable, the runtime value changes but the Inspector does not update. Changes will be lost upon script recompilation.
Reproduction
Example:
using UnityEngine;
using AYellowpaper.SerializedCollections;
public class TestBehaviour : MonoBehaviour
{
[SerializeField]
private SerializedDictionary<int, int> _dictionary;
private void OnEnable()
{
_dictionary.Clear();
_dictionary.Add(Random.Range(0, 100), Random.Range(0, 100));
Debug.Log(_dictionary.Count);
}
}
Steps to reproduce
- Add the component to a GameObject.
- Observe the dictionary in the Inspector.
- Enter Play Mode.
Expected result
The Inspector should reflect the modified dictionary contents.
Actual result
Debug.Log shows the dictionary was modified successfully.
- The Inspector does not update to reflect the changes.
- The serialized value is unchanged.
Notes
This issue has a 100% reproduction rate on Unity 6000.0.73f1.
Environment
6000.0.73f1Description
SerializedDictionarydoes not serialize or refresh correctly when modified from script.If the dictionary is modified via scripting such as in
OnEnable, the runtime value changes but the Inspector does not update. Changes will be lost upon script recompilation.Reproduction
Example:
Steps to reproduce
Expected result
The Inspector should reflect the modified dictionary contents.
Actual result
Debug.Logshows the dictionary was modified successfully.Notes
This issue has a 100% reproduction rate on Unity
6000.0.73f1.