public UnsafeData Set <T>(T data) where T : struct { this.typeId = AllComponentTypes <T> .typeId; if (this.data != System.IntPtr.Zero) { NativeArrayUtils.Dispose(ref this.data); } this.sizeOf = UnsafeUtility.SizeOf <T>(); this.alignOf = UnsafeUtility.AlignOf <T>(); this.data = (System.IntPtr)UnsafeUtility.Malloc(this.sizeOf, this.alignOf, Unity.Collections.Allocator.Persistent); Unity.Collections.LowLevel.Unsafe.UnsafeUtility.WriteArrayElement((void *)this.data, 0, data); return(this); }