static void UploadScreenshot(CognitiveVR_Preferences.SceneSettings settings)
        {
            string sceneExportDirectory = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "CognitiveVR_SceneExplorerExport" + Path.DirectorySeparatorChar + settings.SceneName + Path.DirectorySeparatorChar;

            string[] screenshotPath = new string[0];
            if (Directory.Exists(sceneExportDirectory + "screenshot"))
            {
                screenshotPath = Directory.GetFiles(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "CognitiveVR_SceneExplorerExport" + Path.DirectorySeparatorChar + settings.SceneName + Path.DirectorySeparatorChar + "screenshot");
            }
            else
            {
                Debug.Log("SceneExportWindow Upload can't find directory to screenshot");
                return;
            }

            if (screenshotPath.Length == 0)
            {
                Debug.Log("SceneExportWindow can't load data from screenshot directory");
                return;
            }

            string url = Constants.POSTSCREENSHOT(settings.SceneId, settings.VersionNumber);

            Debug.Log("SceneExportWIndow upload screenshot to " + url);

            WWWForm wwwForm = new WWWForm();

            wwwForm.AddBinaryData("screenshot", File.ReadAllBytes(screenshotPath[0]), "screenshot.png");
            new WWW(url, wwwForm);
        }
예제 #2
0
        public static void UploadScreenshot()
        {
            //get scene id
            var currentScene = CognitiveVR_Preferences.FindCurrentScene();

            if (currentScene == null)
            {
                Debug.Log("Could not find current scene");
                return;
            }
            if (string.IsNullOrEmpty(currentScene.SceneId))
            {
                Debug.Log(currentScene.SceneName + " scene has not been uploaded!");
                return;
            }


            //file popup
            string path = EditorUtility.OpenFilePanel("Select Screenshot", "", "png");

            if (path.Length == 0)
            {
                return;
            }

            string filename = Path.GetFileName(path);

            if (EditorUtility.DisplayDialog("Upload Screenshot", "Upload " + filename + " to " + currentScene.SceneName + " version " + currentScene.VersionNumber + "?", "Upload", "Cancel"))
            {
                string url = Constants.POSTSCREENSHOT(currentScene.SceneId, currentScene.VersionNumber);

                var bytes = File.ReadAllBytes(path);

                WWWForm form = new WWWForm();
                form.AddBinaryData("screenshot", bytes, "screenshot.png");

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

                foreach (var v in form.headers)
                {
                    headers[v.Key] = v.Value;
                }

                if (EditorCore.IsDeveloperKeyValid)
                {
                    headers.Add("Authorization", "APIKEY:DEVELOPER " + EditorCore.DeveloperKey);
                }

                EditorNetwork.Post(url, form, UploadScreenhotResponse, headers, false);
            }
        }