Do I need to remove subscription from completed event once the event has been completed?

Here is my code:

        public static void InstantiatePrefab(string id, Transform parent, GameObjectLoadCallback callback)
        {
            void OnCompleted(AsyncOperationHandle<GameObject> obj)
            {
            }

            AsyncOperationHandle<GameObject> handle = Addressables.InstantiateAsync(id, parent);
            if (callback != null)
            {
                handle.Completed += OnCompleted;
            }
        }

Do I need to remove OnCompleted method from Completed event subscriptions after the async operation has been completed?

2 Likes

No need. The system will cache the handle via a result-to-handle dictionary internally. As long as you invoked Addressables.Release (or when the scene get destroyed), the handle will be released with the instantiated object (the result).

4 Likes