protected override unsafe void OnUpdate() { Entities.WithNone <RetainBlobAssetBatchPtr>().ForEach((Entity e, BlobAssetOwner blobOwner, ref RetainBlobAssets retain) => { BlobAssetBatch.Retain(blobOwner.BlobAssetBatchPtr); EntityManager.AddComponentData(e, new RetainBlobAssetBatchPtr { BlobAssetBatchPtr = blobOwner.BlobAssetBatchPtr }); }); Entities.WithNone <BlobAssetOwner>().ForEach((Entity e, ref RetainBlobAssets retain, ref RetainBlobAssetBatchPtr retainPtr) => { if (retain.FramesToRetainBlobAssets-- == 0) { BlobAssetBatch.Release(retainPtr.BlobAssetBatchPtr); EntityManager.RemoveComponent <RetainBlobAssets>(e); EntityManager.RemoveComponent <RetainBlobAssetBatchPtr>(e); } }); Entities.WithNone <BlobAssetOwner>().ForEach((Entity e, ref RetainBlobAssets retain, ref RetainBlobAssetPtr retainPtr) => { if (retain.FramesToRetainBlobAssets-- == 0) { retainPtr.BlobAsset->Invalidate(); UnsafeUtility.Free(retainPtr.BlobAsset, Allocator.Persistent); EntityManager.RemoveComponent <RetainBlobAssets>(e); EntityManager.RemoveComponent <RetainBlobAssetPtr>(e); } }); }
public void Release() { if (BlobAssetBatchPtr != null) { BlobAssetBatch.Release(BlobAssetBatchPtr); } }
public void Retain() { if (BlobAssetBatchPtr != null) { BlobAssetBatch.Retain(BlobAssetBatchPtr); } }
public BlobAssetOwner(void *buffer, int expectedTotalDataSize) { BlobAssetBatchPtr = BlobAssetBatch.CreateFromMemory(buffer, expectedTotalDataSize); }