Fix ChangedOnOnEnable not triggered

When using an Event Reference Listener with a variable, GetOrCreateEvent() is sometimes called after TriggerInitialEvents(). This commit solves this issue.
This commit is contained in:
Simon Bucher 2021-04-25 16:59:21 +02:00 committed by Miika Lönnqvist
parent c810df67f0
commit 3aa06a70a1

View File

@ -179,12 +179,18 @@ namespace UnityAtoms
/// </summary>
public void TriggerInitialEvents()
{
if (Changed != null && _triggerChangedOnOnEnable)
if (_triggerChangedOnOnEnable)
{
if (Changed == null)
GetOrCreateEvent<E1>();
Changed.Raise(Value);
}
if (ChangedWithHistory != null && _triggerChangedWithHistoryOnOnEnable)
if (_triggerChangedWithHistoryOnOnEnable)
{
if(ChangedWithHistory == null)
GetOrCreateEvent<E2>();
var pair = default(P);
pair.Item1 = _value;
pair.Item2 = _oldValue;