Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Does it make sense to check inspector GUI changes before modified properties applying?

Discussion in 'Editor & General Support' started by FIFTYTWO, Mar 23, 2020.

  1. FIFTYTWO

    FIFTYTWO

    Joined:
    Oct 21, 2014
    Posts:
    49
    When I develop a custom inspector I usually write it so:

    Code (CSharp):
    1. public override void OnInspectorGUI ()
    2. {
    3.     var so = serializedObject;
    4.     so.Update();
    5.     bool arePropertiesChangedNonGUI = false;
    6.     EditorGUI.BeginChangeCheck();
    7.  
    8.     // Property drawing & validation
    9.  
    10.     if( EditorGUI.EndChangeCheck() || arePropertiesChangedNonGUI )
    11.         so.ApplyModifiedProperties();
    12. }
    But I also see a default inspector drawing implementation from Unity and it doesn't check for any changes and just calls ApplyModifiedProperties(). So, does it make any sense to check property changes for performance reason? Or maybe is it more performant to not check them at all? I know that it is not bottleneck of slow Editor but I'm just curious about the most optimal solution even if I could win a couple of processor ticks :)