private IMegacoolPreviewFrame loadNextFrame(IMegacoolPreviewData preview)
 {
     for (int i = 0; i < preview.GetNumberOfFrames(); i++)
     {
         IMegacoolPreviewFrame frame = preview.GetNextFrame();
         if (frame == null)
         {
             Debug.Log("Skipping preview frame that failed to load");
             continue;
         }
         return(frame);
     }
     return(null);
 }
    /// <summary>
    /// Starts previewing the given recording.
    /// </summary>
    /// <param name="recordingIdentifier">Recording identifier.</param>
    public void StartPreview(string recordingIdentifier = default(string))
    {
        if (guiSystem == null)
        {
            guiSystem = new GUISystem(gameObject);
        }

        StopPreview();

        this.previewData = Megacool.Instance._GetPreviewDataForRecording(recordingIdentifier);
        if (previewData == null)
        {
            return;
        }

        _playGifIEnumerator = StartCoroutine(
            PreviewMegacoolGif()
            );
    }
    /// <summary>
    /// Stops the preview.
    /// </summary>
    public void StopPreview()
    {
        if (_playGifIEnumerator != null)
        {
            StopCoroutine(_playGifIEnumerator);

            guiSystem.HidePreview();

            // Only destroy the preview texture if it has been created, might not be the case if there were no frames
            // in the preview or it was stopped before any frames were loaded.
            if (previewTexture)
            {
                Destroy(previewTexture);
            }

            _playGifIEnumerator = null;
        }

        if (this.previewData != null)
        {
            this.previewData.Release();
            this.previewData = null;
        }
    }