How to trigger udpate in editor mode only when I modify component parameters

Hello!

I made a script to generate gameobjects with random positions an random tints.
I added “[ExecuteInEditMode]” at the beginning of the script.
And I clear generated objects before re generated them on every update.

void Update()
        {
            if (Application.IsPlaying(gameObject))
            {
                // Play logic
            }
            else
            {
                // Editor logic
                ClearGrid();
                CreateGrid(); 
            }
    
        }

My problem is that the script constantly update and I just want it update only when I modify my component parameters ( in inspector windows ).
Is it clear ans is there a way to do that?

Thanks!

It’s not exactly meant to be used like this, but OnValidate is triggered whenever you change a value in the inspector. The more elegant, although probably also more complex solution would be a custom inspector.