Example #1
0
        public void Update()
        {
            if (!shouldPlayPreview)
            {
                return;
            }

            if (Recorder.Singleton.FrameList == null || Recorder.Singleton.FrameList.Count == 0)
            {
                return;
            }

            previewTime += Time.unscaledDeltaTime;

            if (previewTime >= gifCreatorWindow.Parameters.getTimePerFrame())
            {
                if (frameIndex >= frameEnd)
                {
                    frameIndex = (int)frameStart;
                }
                else
                {
                    frameIndex++;
                }

                gifCreatorWindow.Repaint();

                previewTime -= gifCreatorWindow.Parameters.getTimePerFrame();
            }
        }
Example #2
0
        private IEnumerator uploadImage()
        {
            if (getLastSaveFileSize() > 10000000)             // 10MB
            {
                EditorUtility.DisplayDialog("Can't upload to imgur.com", "The gif you want to upload is larger than 10MB, it's " + getLastSaveFileSizeDescription() + "! This is the max size allowed by imgur.com. (You can try to reduce the output width to reduce the file size)", "Cancel Upload");
                yield break;
            }

            Dictionary <string, string> headers = new Dictionary <string, string> ();

            headers.Add("Authorization", "Client-ID " + "01c02b71cfa8334");

            WWWForm form = new WWWForm();

            form.AddField("type", "base64");
            form.AddField("image", Convert.ToBase64String(File.ReadAllBytes(lastSavedFilePath)));

            gifCreatorWindow.ProgressRenderer.UpdateProgress("Uploading (" + getLastSaveFileSizeDescription() + ") - this can take a few minutes...", 0.0f);

            WWW www = new WWW("https://api.imgur.com/3/image/", form.data, headers);

            while (!www.isDone)
            {
                yield return(null);
            }

            if (!string.IsNullOrEmpty(www.error))
            {
                gifCreatorWindow.ProgressRenderer.UpdateProgress("Error uploading to imgur.com", 0.0f);
                Debug.LogError("An unknown error occured while uploading to imgur.com: " + www.error + "\n" + www.text);
            }
            else
            {
                JSONObject jsonObject = new JSONObject(www.text);
                bool       success    = jsonObject.GetField("success").b;

                if (!success)
                {
                    string error = jsonObject.GetField("data").GetField("error").str;

                    gifCreatorWindow.ProgressRenderer.UpdateProgress("Error uploading to imgur.com", 0.0f);
                    Debug.LogError("An error occured while uploading to imgur.com: " + error + "\n" + www.text);
                }
                else
                {
                    string url = jsonObject.GetField("data").GetField("link").str;
                    url = url.Replace("\\", string.Empty);

                    EditorGUIUtility.systemCopyBuffer = url;

                    gifCreatorWindow.ProgressRenderer.UpdateProgress("Upload done (URL is in your clipboard)! See console for info", 1.0f);
                    gifCreatorWindow.Repaint();

                    Debug.Log("Your gif have successfully been uploaded to imgur.com (and copied to your clipboard): " + url);
                }
            }
        }
Example #3
0
        public void OnPlayModeChange(bool isEditorPlaying)
        {
            gifCreatorWindow.Repaint();

            if (isEditorPlaying)
            {
                assignCallbacks();
            }
            else
            {
                gifCreatorWindow.Reset();
            }
        }
Example #4
0
 public void OnRecordingProgress(float percent)
 {
     gifCreatorWindow.ProgressRenderer.UpdateProgress("Recording", percent);
     gifCreatorWindow.Repaint();
 }