using System.Runtime.InteropServices; namespace Svelto.ECS.Hybrid { public struct ValueReference where T:class, IImplementor { public ValueReference(T obj) { _pointer = GCHandle.Alloc(obj, GCHandleType.Normal); } public static explicit operator T(ValueReference t) => (T) t._pointer.Target; GCHandle _pointer; } }