So the preferred way to keep UI updated with state seems to be binding. This is pretty straightforward if I have e.g. a Label
and a corresponding string
-value.
But what about this case: I have a Button
to add a Component
to a GameObject
. That button should be disabled if that component is already present. That can either happen by pressing the button, but also outside by just adding it through the inspector, or in multiple other ways.
So I want to keep the button enabled state always in sync with the state GetComponent<MyComponent>() != null
.
How would I go about this?
Is there some preferred way to go about this?
Something like a BindingScope maybe?
Thanks very much for your attention!
Edit: nicer code formatting