Ejemplo n.º 1
0
    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();
            }
        }
    }
Ejemplo n.º 2
0
 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);
         }
     }
 }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
    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();
    }