You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code example below. I'll write an easy instruction on how to reproduce the bug.
Create a class containing all the code below
Add SerializableDictionaryBugExample to any Monobehaviour in a scene
Toggle the bool to "true"
Use the "+" to add a new empty dictionary entry (Dont set the value for the custom class)
Toggle the bool to "false"
You will not be able to click the Toggle again
Actually clicking the toggle button works, but somehow it never really gets applied. I guess theres an exception somewhere in the OnInspectorGui loop.
I couldn't finde out how to solve this problem.
I would really appreciate if anyone can help me!
using System;
using UnityEditor;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor.Experimental.SceneManagement;
using UnityEditor.SceneManagement;
#endif
[Serializable]
public class SerializableDictionaryExample : SerializableDictionary<SomeOtherClass, int> {}
public class SomeOtherClass : MonoBehaviour
{
}
public class SerializableDictionaryBugExample : MonoBehaviour
{
public bool boolean;
public SerializableDictionaryExample DictionaryExample;
#if UNITY_EDITOR
[CustomEditor(typeof(SerializableDictionaryBugExample))]
[CanEditMultipleObjects]
public class SerializableDictionaryBugExampleEditor : Editor
{
private SerializedProperty DictionaryExampleProperty;
private SerializableDictionaryBugExample exampleClass;
public void OnEnable()
{
DictionaryExampleProperty = serializedObject.FindProperty("DictionaryExample");
exampleClass = (SerializableDictionaryBugExample) target;
}
public override void OnInspectorGUI()
{
EditorGUI.BeginChangeCheck();
serializedObject.Update();
EditorGUILayout.LabelField("General", EditorStyles.boldLabel);
exampleClass.boolean = EditorGUILayout.Toggle("ToggleButton", exampleClass.boolean);
if (exampleClass.boolean)
{
EditorGUILayout.PropertyField(DictionaryExampleProperty,
new GUIContent("Dictionary", "Some Tooltip")
);
}
serializedObject.ApplyModifiedProperties();
var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
if (EditorGUI.EndChangeCheck())
{
EditorSceneManager.MarkSceneDirty(prefabStage.scene);
}
}
}
#endif
}
The text was updated successfully, but these errors were encountered:
Code example below. I'll write an easy instruction on how to reproduce the bug.
Actually clicking the toggle button works, but somehow it never really gets applied. I guess theres an exception somewhere in the OnInspectorGui loop.
I couldn't finde out how to solve this problem.
I would really appreciate if anyone can help me!
The text was updated successfully, but these errors were encountered: