From ac4b5d8b72b7ffa6873ccf288f31a6427408ce05 Mon Sep 17 00:00:00 2001 From: Jamie Brynes Date: Wed, 19 Feb 2020 11:22:33 +0000 Subject: [PATCH] ensure that requireable fields are set to null when the subscription is no longer satisfied --- .../Subscriptions/RequiredSubscriptionsInjector.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs index 73e7d88814..9a782375c4 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/RequiredSubscriptionsInjector.cs @@ -77,6 +77,14 @@ private void HandleSubscriptionsSatisfied() private void HandleSubscriptionsNoLongerSatisfied() { onDisable?.Invoke(); + + foreach (var field in info.RequiredFields) + { + if (!field.FieldType.IsValueType) + { + field.SetValue(target, value: null); + } + } } private class Handler : ISubscriptionAvailabilityHandler