I have a MonoBehaviour which contains an array but I didn’t like the way the array elements are shown. So I created a custom inspector which does the job, but now the inspector does not update when I reset the MonoBehaviour(right-click->Reset). Everything works fine except for the Reset. When I reset, the values don’t get updated until I hit the play button. I tried to use SetDirty in OnInspectorGUI and also SetDirty in the MonoBehaviours Reset method but nothing seems to work.
Without the custom inspector, the reset works just fine.
To reset your values in the inspector, you need to add the reset function to your script.
function Reset()
{
// Set your data to a default value/s here.
}
You can read more in the reset documentation.
I solved the problem. After I modify my MonoBehaviour, I have to call serializedObject.ApplyModifiedProperties() and serializedObject.Update(). I did it once when trying to solve the problem but I didn’t notice a reset because the inspector updates when I leave the modified property. For example I set a value to 1000 and then do the reset, the value won’t be updated to the default until I click on another field.