unity custom editor save changes

C#
EditorUtility.SetDirty(castedTarget);
Source

Also in C#: