async void NeverEndingStoryLoop() { start_time = Time.realtimeSinceStartup; if (currentType == ImageType.KTX) { while (!cancellationTokenSource.IsCancellationRequested) { var bt = new KtxTexture(); var result = await bt.LoadFromBytes(data, this); if (cancellationTokenSource.IsCancellationRequested) { break; } ApplyTexture(result); batch_time = Time.realtimeSinceStartup - start_time; await Task.Yield(); } } else { while (!cancellationTokenSource.IsCancellationRequested) { var texture = new Texture2D(2, 2); texture.LoadImage(data.ToArray(), true); if (cancellationTokenSource.IsCancellationRequested) { break; } ApplyTexture(new TextureResult(texture, TextureOrientation.UNITY_DEFAULT)); batch_time = Time.realtimeSinceStartup - start_time; await Task.Yield(); } } }
IEnumerator NeverEndingStory() { start_time = Time.realtimeSinceStartup; if (currentType == ImageType.KTX) { while (true) { var bt = new KtxTexture(); bt.onTextureLoaded += ApplyTexture; bt.LoadFromBytes(data, this); batch_time = Time.realtimeSinceStartup - start_time; yield return(null); } } else { while (true) { var texture = new Texture2D(2, 2); texture.LoadImage(data.ToArray(), true); ApplyTexture(texture); batch_time = Time.realtimeSinceStartup - start_time; yield return(null); } } }
void LoadBatch(int count) { Profiler.BeginSample("LoadBatch"); start_time = Time.realtimeSinceStartup; batch_count = count; batch_time = -1; for (int i = 0; i < count; i++) { if (currentType == ImageType.KTX) { var bt = new KtxTexture(); bt.onTextureLoaded += ApplyTexture; bt.LoadFromBytes(data, this); } else { var texture = new Texture2D(2, 2); texture.LoadImage(data.ToArray(), true); ApplyTexture(texture); } } Profiler.EndSample(); }
async void LoadBatch(int count) { Profiler.BeginSample("LoadBatch"); start_time = Time.realtimeSinceStartup; batch_count = count; batch_time = -1; for (int i = 0; i < count; i++) { if (currentType == ImageType.KTX) { var bt = new KtxTexture(); var result = await bt.LoadFromBytes(data, this); ApplyTexture(result); } else { var texture = new Texture2D(2, 2); texture.LoadImage(data.ToArray(), true); ApplyTexture(new TextureResult(texture, TextureOrientation.UNITY_DEFAULT)); } } Profiler.EndSample(); }