public void MoveRenderTexture(UMAData umaData, RenderTextureSource rts) { // Thread p = new Thread(new ParameterizedThreadStart(CopyRenderTexture(rts)) int arrayLen = 0; int width = rts.renderTexture.width; int height = rts.renderTexture.height; /* * for (int i=0; i< rts.renderTexture.mipmapCount; i++) * { * arrayLen += width * height * 4; * width >>= 1; * height >>= 1; * }*/ DestinationTextureHolder dtex = new DestinationTextureHolder(); dtex.CompleteArray = new NativeArray <uint>(arrayLen, Allocator.Persistent); /* dtex.mipCount = rts.renderTexture.mipmapCount; */ dtex.MipConverted = new bool[dtex.mipCount + 1]; dtex.isDisposed = false; for (int i = 0; i < rts.renderTexture.mipmapCount; i++) { AsyncGPUReadbackRequest agr = AsyncGPUReadback.Request(rts.renderTexture, i, TextureFormat.ARGB32, OnCompleteReadback); ReadBackTracker rbt = new ReadBackTracker(); rbt.request = agr; rbt.texSource = rts; rbt.umaData = umaData; rbt.texAccumulator = dtex; trackedItems.Add(agr, rbt); } }
void Cleanup(ReadBackTracker rbt) { if (!rbt.texAccumulator.isDisposed) { if (rbt.texAccumulator.CompleteArray.IsCreated) { rbt.texAccumulator.CompleteArray.Dispose(); rbt.texAccumulator.isDisposed = true; } } trackedItems.Remove(rbt.request); }