# Private parameter and OnInspectorGUI

**URL:** <https://discussions.unity.com/t/private-parameter-and-oninspectorgui/640797>\
**Category:** Editor Extensions\
**Created:** [September 23, 2016, 4:46pm UTC](https://discussions.unity.com/t/private-parameter-and-oninspectorgui/640797 "2016-09-23T16:46:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![caso2rognac](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/caso2rognac/32/347563_2.png) [@caso2rognac](https://discussions.unity.com/u/caso2rognac)\
**Post date:** [September 23, 2016, 4:46pm UTC](https://discussions.unity.com/t/private-parameter-and-oninspectorgui/640797/1 "2016-09-23T16:46:45Z")

</div>

Hello,

I’m developping an Editor script which modifies values of a private parameter in OnSceneGUI…  
When I want to read the value in OnInspectorGUI, the value is not set to the value I set in OnSceneGUI…

What am I missing?

Thanks

---

<div class="post-metadata">

**Author:** ![NickAtUnity](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/nickatunity/32/610004_2.png) [@NickAtUnity](https://discussions.unity.com/u/NickAtUnity)\
**Post date:** [September 23, 2016, 5:13pm UTC](https://discussions.unity.com/t/private-parameter-and-oninspectorgui/640797/2 "2016-09-23T17:13:51Z")

</div>

If you’re using the serializedObject value to modify the object, make sure you call [Update](https://docs.unity3d.com/ScriptReference/SerializedObject.Update.html) before reading any values and [ApplyModifiedProperties](https://docs.unity3d.com/ScriptReference/SerializedObject.ApplyModifiedProperties.html) after changing any values. Those ensure your objects are properly in sync and changes are saved.

---

<div class="post-metadata">

**Author:** ![caso2rognac](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/caso2rognac/32/347563_2.png) [@caso2rognac](https://discussions.unity.com/u/caso2rognac)\
**Post date:** [September 23, 2016, 6:00pm UTC](https://discussions.unity.com/t/private-parameter-and-oninspectorgui/640797/3 "2016-09-23T18:00:15Z")

</div>

This is not a serializedObject, this is a private parameter that is declared in the body of the Editor class and which is modified in OnSceneGUI. When I get into OnInspectorGUI this parameter is still having its default value.

---

<div class="post-metadata">

**Author:** ![caso2rognac](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/caso2rognac/32/347563_2.png) [@caso2rognac](https://discussions.unity.com/u/caso2rognac)\
**Post date:** [September 23, 2016, 8:08pm UTC](https://discussions.unity.com/t/private-parameter-and-oninspectorgui/640797/4 "2016-09-23T20:08:19Z")

</div>

After having called Repaint() in OnSceneGUI my private integer could be updated and I could get the appropriate value in OnInspectorGUI… A bit strange, but good to know!
