private static void OnRemove(IntPtr gcHandlePtr) { GCHandle gcHandle = GCHandle.FromIntPtr(gcHandlePtr); UObjectRef objRef = (UObjectRef)gcHandle.Target; FMessage.Log("GC " + (objRef.Managed == null ? "null" : objRef.Managed.GetType().ToString()) + " (" + gcHandlePtr.ToString("X16") + ")"); Coroutine.RemoveObjectByGC(objRef.Managed); Invoker.RemoveObjectByGC(objRef.Managed); objRef.Managed.ReleaseInjectedInterfaces(); objRef.Managed.objRef = null; // This will make UObject.IsDestroyed true objRef.Managed.Address = IntPtr.Zero; // Reset the address References.Remove(objRef.Native); gcHandle.Free(); // Return the objRef to the pool (this will also reset the objRef state back to empty) objRefPool.ReturnObject(objRef); }
private static void OnRemove(IntPtr gcHandlePtr) { GCHandle gcHandle = GCHandle.FromIntPtr(gcHandlePtr); UObjectRef objRef = (UObjectRef)gcHandle.Target; //FMessage.Log("GC " + (objRef.Managed == null ? "null" : objRef.Managed.GetType().ToString()) + " (GCHandle: " + gcHandlePtr.ToString("X16") + " ptr: " + objRef.Native.ToString("X16") + ")"); objRef.Managed.OnDestroyedInternal(); Coroutine.RemoveObjectByGC(objRef.Managed); Invoker.RemoveObjectByGC(objRef.Managed); objRef.Managed.objRef = null; // This will make UObject.IsDestroyed true objRef.Managed.Address = IntPtr.Zero; // Reset the address #if ARRAY_GC References[objRef.InternalIndex] = null; #else References.Remove(objRef.Native); #endif gcHandle.Free(); // Return the objRef to the pool (this will also reset the objRef state back to empty) objRefPool.ReturnObject(objRef); }