Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.     public void Record()
  2.     {
  3.         if (previewGifRoutine != null) StopCoroutine(previewGifRoutine);
  4.         if (captureGifRoutine != null) StopCoroutine(captureGifRoutine);
  5.         screenshots.Clear();
  6.  
  7.         captureGifRoutine = StartCoroutine(IERecord());
  8.     }
  9.     private IEnumerator IERecord()
  10.     {
  11.         IsRecording = true;
  12.         //Take a screenshot for every needed frame
  13.         for (int i = 0; i < gifDuration * framesPerSecond; i++)
  14.         {
  15.             TakeScreenShot();
  16.             //CurrentFrame = screenshots[i];
  17.             //FrameIndex = i;
  18.             yield return new WaitForSecondsRealtime(1 / framesPerSecond);
  19.             yield return null;
  20.         }
  21.  
  22.         IsRecording = false;
  23.         PreviewGif();
  24.         yield return null;
  25.     }
  26.  
  27.     private void PreviewGif()
  28.     {
  29.         previewGifRoutine = StartCoroutine(IEPreviewGif());
  30.     }
  31.     private IEnumerator IEPreviewGif()
  32.     {
  33.         for (int i = 0; i < screenshots.Count; i++)
  34.         {
  35.             CurrentFrame = screenshots[i];
  36.             FrameIndex = i;
  37.             replayMaterial.mainTexture = CurrentFrame;
  38.             //yield return new WaitForSecondsRealtime((1 / framesPerSecond) / PlaybackSpeed);
  39.             yield return new WaitForSeconds(1 / framesPerSecond);
  40.             yield return null;
  41.         }
  42.  
  43.         previewGifRoutine = StartCoroutine(IEPreviewGif());
  44.         yield return null;
  45.     }