I have a custom inspector for a UI component that I wrote which builds a polygon mesh. My problem is that when I change one of the values in the custom inspector during edit time, the target component doesnt reflect those changes. However when I change one of the public variables on the target script itself the changes are shown immediately. Heres my code:
[CustomEditor(typeof(RegularPolygonGraphic))]
public class RegularPolygonEditor : Editor
{
RegularPolygonGraphic Target;
public override void OnInspectorGUI()
{
if(target != null)
{
Target = target as RegularPolygonGraphic;
}
DrawDefaultInspector();
if(Target.Puncture)
{
EditorGUILayout.BeginHorizontal();
GUILayout.Label("Thickness");
Target.Thickness = EditorGUILayout.Slider(Target.Thickness, 0f, 1f);
Undo.RecordObject(Target, "Set Thickness");
EditorGUILayout.EndHorizontal();
}
}
}
Now when I move the slider in the inspector around, the RegularPolygonGraphic target doesnt reflect those changes. However if I modify any other public in the RegularPolygonGraphic script that isnt set by the custom inspector, it updates correctly. I have the same problem in a lot of other scripts which need a custom inspector so simply making the Thickness variable public on the target component isnt an option. Thanks for your help!
EDIT: If it helps, the target script is doing most of the work inside OnPopulateMesh(VertexHelper vh) which is overriding that method from the Graphic class.