There was a previous fix
(40baf00)
that attempted to fix the following issue: (This is being described
in detail as the message on the other commit is unhelpful).
The Malimbe custom Unity InspectorEditor would only run the
BeforeChange and AfterChange methods when valid ChangeHandler
attributes were found in the component (e.g. OnBeforeChange() and
OnAfterChange(). However, when using a Zinnia ObservableList it would
not raise the component events when the Elements array was updated in
the inspector.
This is due to the Zinnia ObservableList using a custom inspector
(ObservableListEditor) which extends the Malimbe InspectorEditor and
overrides the BeforeChange() and AfterChange() methods to raise
events when the list elements have items added/removed from them.
This would mean that the ObservableListEditorBeforeChange() and
AfterChange() methods would therefore never be called so the events
would never be raised.
The original fix was to just always called BeforeChange() and
AfterChange() in the ifelse part of the logic so they would always
be called in any sub class, and the base methods would not run because
the internal logic would simply iterate over a collection of found
ChangeHandlers, which in the case of the ObservableList would be empty.
However, this fix introduced another problem where the BeforeChange()
and AfterChange() methods in the base InspectorEditor would still
run at edit time if the component did have ChangeHandlers and this
created cascading issues where components would attempt to set up
internal references at edit time, which is not correct behaviour.
This fix reworks how the OnInspectorGUI logic works so that the
BeforeChange() and AfterChange() methods are always called at
runtime even if there are no ChangeHandlers.
There was a previous fix (40baf00) that attempted to fix the following issue: (This is being described in detail as the message on the other commit is unhelpful).
The Malimbe custom Unity InspectorEditor would only run the
BeforeChange
andAfterChange
methods when valid ChangeHandler attributes were found in the component (e.g.OnBeforeChange()
andOnAfterChange()
. However, when using a Zinnia ObservableList it would not raise the component events when the Elements array was updated in the inspector.This is due to the Zinnia ObservableList using a custom inspector (
ObservableListEditor
) which extends the Malimbe InspectorEditor and overrides theBeforeChange()
andAfterChange()
methods to raise events when the list elements have items added/removed from them.The problem rose from the ObservableList component does not contain any ChangeHandler attributes and therefore the
ChangeHandlerMethodInfos
would be empty and so the check in theOnInspectorGUI()
method (https://github.com/ExtendRealityLtd/Malimbe/blob/master/Sources/FodyRunner.UnityIntegration/InspectorEditor.cs#L85-L88) would not be true and therefore theBeforeChange()
andAfterChange()
methods would never be executed by the base inspector editor.This would mean that the
ObservableListEditor
BeforeChange()
andAfterChange()
methods would therefore never be called so the events would never be raised.The original fix was to just always called
BeforeChange()
andAfterChange()
in theifelse
part of the logic so they would always be called in any sub class, and the base methods would not run because the internal logic would simply iterate over a collection of found ChangeHandlers, which in the case of the ObservableList would be empty.However, this fix introduced another problem where the
BeforeChange()
andAfterChange()
methods in the base InspectorEditor would still run at edit time if the component did have ChangeHandlers and this created cascading issues where components would attempt to set up internal references at edit time, which is not correct behaviour.This fix reworks how the
OnInspectorGUI
logic works so that theBeforeChange()
andAfterChange()
methods are always called at runtime even if there are no ChangeHandlers.