//search through files. if dynamics.name contains exported folder, upload static bool UploadDynamicObjects(List <string> dynamicMeshNames, bool ShowPopupWindow = false) { string fileList = "Upload Files:\n"; var settings = CognitiveVR_Preferences.FindCurrentScene(); if (settings == null) { string s = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name; if (string.IsNullOrEmpty(s)) { s = "Unknown Scene"; } EditorUtility.DisplayDialog("Dynamic Object Upload Failed", "Could not find the Scene Settings for \"" + s + "\". Are you sure you've saved, exported and uploaded this scene to SceneExplorer?", "Ok"); return(false); } string sceneid = settings.SceneId; if (string.IsNullOrEmpty(sceneid)) { EditorUtility.DisplayDialog("Dynamic Object Upload Failed", "Could not find the SceneId for \"" + settings.SceneName + "\". Are you sure you've exported and uploaded this scene to SceneExplorer?", "Ok"); return(false); } string path = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "CognitiveVR_SceneExplorerExport" + Path.DirectorySeparatorChar + "Dynamic"; var subdirectories = Directory.GetDirectories(path); // List <string> exportDirectories = new List <string>(); foreach (var v in subdirectories) { var split = v.Split(Path.DirectorySeparatorChar); if (dynamicMeshNames.Contains(split[split.Length - 1])) { exportDirectories.Add(v); } } if (ShowPopupWindow) { int option = EditorUtility.DisplayDialogComplex("Upload Dynamic Objects", "Do you want to upload " + exportDirectories.Count + " Objects to \"" + settings.SceneName + "\" (" + settings.SceneId + " Version:" + settings.VersionNumber + ")?", "Ok", "Cancel", "Open Directory"); if (option == 0) { } //ok else if (option == 1) { return(false); } //cancel else { #if UNITY_EDITOR_WIN //open directory System.Diagnostics.Process.Start("explorer.exe", path); return(false); #elif UNITY_EDITOR_OSX System.Diagnostics.Process.Start("open", path); return(false); #endif } } string objectNames = ""; foreach (var subdir in exportDirectories) { var filePaths = Directory.GetFiles(subdir); WWWForm wwwForm = new WWWForm(); foreach (var f in filePaths) { if (f.ToLower().EndsWith(".ds_store")) { Debug.Log("skip file " + f); continue; } fileList += f + "\n"; var data = File.ReadAllBytes(f); wwwForm.AddBinaryData("file", data, Path.GetFileName(f)); } var dirname = new DirectoryInfo(subdir).Name; objectNames += dirname + "\n"; string uploadUrl = Constants.POSTDYNAMICOBJECTDATA(settings.SceneId, settings.VersionNumber, dirname); 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; } } dynamicObjectForms.Add(new DynamicObjectForm(uploadUrl, wwwForm, dirname, headers)); //AUTH } if (dynamicObjectForms.Count > 0) { DynamicUploadTotal = dynamicObjectForms.Count; DynamicUploadSuccess = 0; EditorApplication.update += UpdateUploadDynamics; } return(true); }