示例#1
0
        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);
                }
            });
        }
示例#2
0
 public void Release()
 {
     if (BlobAssetBatchPtr != null)
     {
         BlobAssetBatch.Release(BlobAssetBatchPtr);
     }
 }
示例#3
0
 public void Retain()
 {
     if (BlobAssetBatchPtr != null)
     {
         BlobAssetBatch.Retain(BlobAssetBatchPtr);
     }
 }
示例#4
0
 public BlobAssetOwner(void *buffer, int expectedTotalDataSize)
 {
     BlobAssetBatchPtr = BlobAssetBatch.CreateFromMemory(buffer, expectedTotalDataSize);
 }