public static void UploadDecimatedScene(CognitiveVR_Preferences.SceneSettings settings, System.Action uploadComplete) { //if uploadNewScene POST //else PUT to sceneexplorer/sceneid if (settings == null) { UploadSceneSettings = null; return; } UploadSceneSettings = settings; bool hasExistingSceneId = settings != null && !string.IsNullOrEmpty(settings.SceneId); bool uploadConfirmed = false; string sceneName = settings.SceneName; string[] filePaths = new string[] { }; string sceneExportDirectory = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "CognitiveVR_SceneExplorerExport" + Path.DirectorySeparatorChar + settings.SceneName + Path.DirectorySeparatorChar; var SceneExportDirExists = Directory.Exists(sceneExportDirectory); if (SceneExportDirExists) { filePaths = Directory.GetFiles(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "CognitiveVR_SceneExplorerExport" + Path.DirectorySeparatorChar + sceneName + Path.DirectorySeparatorChar); } //custom confirm upload popup windows if ((!SceneExportDirExists || filePaths.Length <= 1)) { if (EditorUtility.DisplayDialog("Upload Scene", "Scene " + settings.SceneName + " has no exported geometry. Upload anyway?", "Yes", "No")) { uploadConfirmed = true; //create a json.settings file in the directory string objPath = CognitiveVR_SceneExplorerExporter.GetDirectory(sceneName); Directory.CreateDirectory(objPath); string jsonSettingsContents = "{ \"scale\":1, \"sceneName\":\"" + settings.SceneName + "\",\"sdkVersion\":\"" + Core.SDK_VERSION + "\"}"; File.WriteAllText(objPath + "settings.json", jsonSettingsContents); } } else { uploadConfirmed = true; /*if (EditorUtility.DisplayDialog("Upload Scene", "Do you want to upload \"" + settings.SceneName + "\" to your Dashboard?", "Yes", "No")) * { * * }*/ } if (!uploadConfirmed) { UploadSceneSettings = null; return; //just exit now } //after confirmation because uploading an empty scene creates a settings.json file if (Directory.Exists(sceneExportDirectory)) { filePaths = Directory.GetFiles(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "CognitiveVR_SceneExplorerExport" + Path.DirectorySeparatorChar + sceneName + Path.DirectorySeparatorChar); } string[] screenshotPath = new string[0]; if (Directory.Exists(sceneExportDirectory + "screenshot")) { screenshotPath = Directory.GetFiles(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "CognitiveVR_SceneExplorerExport" + Path.DirectorySeparatorChar + sceneName + Path.DirectorySeparatorChar + "screenshot"); } else { Debug.Log("SceneExportWindow Upload can't find directory to screenshot"); } string fileList = "Upload Files:\n"; string mtlFilepath = ""; string objFilepath = ""; WWWForm wwwForm = new WWWForm(); foreach (var f in filePaths) { if (f.ToLower().EndsWith(".ds_store")) { Debug.Log("skip file " + f); continue; } //set obj file. prefer decimated if (f.EndsWith(".obj")) { if (f.EndsWith("_decimated.obj")) { objFilepath = f; } else if (string.IsNullOrEmpty(objFilepath)) { objFilepath = f; } continue; } //set mtl file. prefer decimated if (f.EndsWith(".mtl")) { if (f.EndsWith("_decimated.mtl")) { mtlFilepath = f; } else if (string.IsNullOrEmpty(mtlFilepath)) { mtlFilepath = f; } continue; } fileList += f + "\n"; var data = File.ReadAllBytes(f); wwwForm.AddBinaryData("file", data, Path.GetFileName(f)); } if (!string.IsNullOrEmpty(objFilepath)) { //add obj and mtl files wwwForm.AddBinaryData("file", File.ReadAllBytes(objFilepath), Path.GetFileName(objFilepath)); fileList += objFilepath + "\n"; wwwForm.AddBinaryData("file", File.ReadAllBytes(mtlFilepath), Path.GetFileName(mtlFilepath)); fileList += mtlFilepath + "\n"; } Debug.Log(fileList); if (screenshotPath.Length == 0) { Debug.Log("SceneExportWindow Upload can't find files in screenshot directory"); } else { wwwForm.AddBinaryData("screenshot", File.ReadAllBytes(screenshotPath[0]), "screenshot.png"); } if (hasExistingSceneId) //upload new verison of existing scene { Dictionary <string, string> headers = new Dictionary <string, string>(); if (EditorCore.IsDeveloperKeyValid) { headers.Add("Authorization", "APIKEY:DEVELOPER " + EditorCore.DeveloperKey); //headers.Add("Content-Type", "multipart/form-data; boundary=\""+) foreach (var v in wwwForm.headers) { headers[v.Key] = v.Value; } } EditorNetwork.Post(Constants.POSTUPDATESCENE(settings.SceneId), wwwForm.data, PostSceneUploadResponse, headers, true, "Upload", "Uploading new version of scene");//AUTH } else //upload as new scene { //posting wwwform with headers //sceneUploadWWW = new WWW(Constants.POSTNEWSCENE(), wwwForm); Dictionary <string, string> headers = new Dictionary <string, string>(); if (EditorCore.IsDeveloperKeyValid) { headers.Add("Authorization", "APIKEY:DEVELOPER " + EditorCore.DeveloperKey); //headers.Add("Content-Type", "multipart/form-data; boundary=\""+) foreach (var v in wwwForm.headers) { headers[v.Key] = v.Value; } } EditorNetwork.Post(Constants.POSTNEWSCENE(), wwwForm.data, PostSceneUploadResponse, headers, true, "Upload", "Uploading new scene");//AUTH //Debug.Log("Upload new scene"); } UploadComplete = uploadComplete; //EditorApplication.update += UpdateUploadData; }