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); }
/// <summary> /// Set the SceneId for recorded data by reference /// </summary> /// <param name="scene"></param> public static void SetTrackingScene(CognitiveVR_Preferences.SceneSettings scene) { if (scene == null) { //what scene is being loaded float duration = Time.time - SceneStartTime; SceneStartTime = Time.time; new CustomEvent("c3d.SceneChange").SetProperty("Duration", duration).Send(); } else { //what scene is being loaded float duration = Time.time - SceneStartTime; SceneStartTime = Time.time; new CustomEvent("c3d.SceneChange").SetProperty("Duration", duration).SetProperty("Scene Name", scene.SceneName).SetProperty("Scene Id", scene.SceneId).Send(); } //just to send this scene change event Core.InvokeSendDataEvent(); ForceWriteSessionMetadata = true; TrackingSceneId = ""; TrackingSceneVersionNumber = 0; TrackingSceneName = ""; TrackingScene = null; if (scene != null) { TrackingSceneId = scene.SceneId; TrackingSceneVersionNumber = scene.VersionNumber; TrackingSceneName = scene.SceneName; TrackingScene = scene; } }
/// <summary> /// has folder for scene. can be empty /// </summary> /// <param name="currentSceneSettings"></param> /// <returns></returns> public static bool HasSceneExportFolder(CognitiveVR_Preferences.SceneSettings currentSceneSettings) { if (currentSceneSettings == null) { return(false); } string sceneExportDirectory = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "CognitiveVR_SceneExplorerExport" + Path.DirectorySeparatorChar + currentSceneSettings.SceneName + Path.DirectorySeparatorChar; var SceneExportDirExists = Directory.Exists(sceneExportDirectory); return(SceneExportDirExists); }
public static void SetTrackingScene(CognitiveVR_Preferences.SceneSettings scene) { TrackingSceneId = ""; TrackingSceneVersionNumber = 0; TrackingSceneName = ""; TrackingScene = null; if (scene != null) { TrackingSceneId = scene.SceneId; TrackingSceneVersionNumber = scene.VersionNumber; TrackingSceneName = scene.SceneName; TrackingScene = scene; } }
public override void OnInspectorGUI() { if (!hasCheckedRenderType) { CheckGazeRenderType(); hasCheckedRenderType = true; } var p = (CognitiveVR_Preferences)target; p.ApplicationKey = EditorGUILayout.TextField("Application Key", p.ApplicationKey); p.EnableLogging = EditorGUILayout.Toggle("Enable Logging", p.EnableLogging); p.EnableDevLogging = EditorGUILayout.Toggle("Enable Development Logging", p.EnableDevLogging); EditorGUILayout.Space(); EditorGUILayout.LabelField("3D Player Tracking", EditorStyles.boldLabel); //TODO change tooltip based on selected gaze type p.GazeType = (GazeType)EditorGUILayout.EnumPopup("Gaze Type", p.GazeType); if (GUI.changed) { CheckGazeRenderType(); } p.SnapshotInterval = EditorGUILayout.FloatField("Snapshot Interval", p.SnapshotInterval); p.DynamicObjectSearchInParent = EditorGUILayout.Toggle(new GUIContent("Dynamic Object Search in Parent", "When capturing gaze on a Dynamic Object, also search in the collider's parent for the dynamic object component"), p.DynamicObjectSearchInParent); bool eyetracking = false; #if CVR_TOBIIVR || CVR_FOVE || CVR_NEURABLE || CVR_PUPIL || CVR_AH || CVR_SNAPDRAGON || CVR_VIVEPROEYE || CVR_VARJO eyetracking = true; #endif if (p.GazeType == GazeType.Physics || eyetracking) { LayerMask gazeMask = new LayerMask(); gazeMask.value = p.GazeLayerMask; gazeMask = EditorGUILayout.MaskField("Gaze Layer Mask", gazeMask, (UnityEditorInternal.InternalEditorUtility.layers)); p.GazeLayerMask = gazeMask.value; } LayerMask dynamicMask = new LayerMask(); dynamicMask.value = p.DynamicLayerMask; dynamicMask = EditorGUILayout.MaskField("Dynamic Object Layer Mask", dynamicMask, (UnityEditorInternal.InternalEditorUtility.layers)); p.DynamicLayerMask = dynamicMask.value; p.TrackGPSLocation = EditorGUILayout.Toggle(new GUIContent("Track GPS Location", "Record GPS location and compass direction at the interval below"), p.TrackGPSLocation); EditorGUI.BeginDisabledGroup(!p.TrackGPSLocation); EditorGUI.indentLevel++; gpsFoldout = EditorGUILayout.Foldout(gpsFoldout, "GPS Options"); if (gpsFoldout) { p.SyncGPSWithGaze = EditorGUILayout.Toggle(new GUIContent("Sync with Player Update", "Request new GPS location every time the player position and gaze is recorded"), p.SyncGPSWithGaze); EditorGUI.BeginDisabledGroup(p.SyncGPSWithGaze); p.GPSInterval = Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent("GPS Update Interval", "Interval in seconds to record new GPS location data"), p.GPSInterval), 0.1f, 60f); EditorGUI.EndDisabledGroup(); p.GPSAccuracy = Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent("GPS Accuracy", "Desired accuracy in meters. Using higher values like 500 may not require GPS and may save battery power"), p.GPSAccuracy), 1f, 500f); } EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); p.RecordFloorPosition = EditorGUILayout.Toggle(new GUIContent("Record Floor Position", "Includes the floor position below the HMD in a VR experience"), p.RecordFloorPosition); EditorGUILayout.Space(); EditorGUILayout.LabelField("360 Player Tracking", EditorStyles.boldLabel); p.SnapshotInterval = EditorGUILayout.FloatField("Snapshot Interval", p.SnapshotInterval); p.SnapshotInterval = Mathf.Clamp(p.SnapshotInterval, 0.1f, 10); EditorGUILayout.Space(); EditorGUILayout.LabelField("Sending Data Batches", EditorStyles.boldLabel); //gaze EditorGUI.indentLevel++; EditorGUILayout.LabelField("Gaze", EditorStyles.boldLabel); EditorGUI.indentLevel--; p.GazeSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Gaze Snapshot Batch Size", "The number of Gaze datapoints to record before automatically sending a web request to the dashboard"), p.GazeSnapshotCount), 64, 1500); //transactions EditorGUI.indentLevel++; EditorGUILayout.LabelField("Events", EditorStyles.boldLabel); EditorGUI.indentLevel--; p.TransactionSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Event Snapshot Batch Size", "The number of Events to record before automatically sending a web request to the dashboard"), p.TransactionSnapshotCount), 1, 1000); p.TransactionExtremeSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Event Extreme Batch Size", "Threshold for ignoring the Event Minimum Timer. If this many Events have been recorded, immediately send"), p.TransactionExtremeSnapshotCount), p.TransactionSnapshotCount, 1000); p.TransactionSnapshotMinTimer = EditorGUILayout.IntField(new GUIContent("Event Minimum Timer", "Time (in seconds) that must be elapsed before sending a new batch of Event data. Ignored if the batch size reaches Event Extreme Limit"), Mathf.Clamp(p.TransactionSnapshotMinTimer, 1, 10)); p.TransactionSnapshotMaxTimer = EditorGUILayout.IntField(new GUIContent("Event Automatic Send Timer", "The time (in seconds) to automatically send any outstanding Event data"), Mathf.Clamp(p.TransactionSnapshotMaxTimer, p.TransactionSnapshotMinTimer, 60)); //dynamics EditorGUI.indentLevel++; EditorGUILayout.LabelField("Dynamics", EditorStyles.boldLabel); EditorGUI.indentLevel--; p.DynamicSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Dynamic Snapshot Batch Size", "The number of Dynamic snapshots and manifest entries to record before automatically sending a web request to the dashboard"), p.DynamicSnapshotCount), 16, 1500); p.DynamicExtremeSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Dynamic Extreme Batch Size", "Threshold for ignoring the Dynamic Minimum Timer. If this many Dynamic snapshots have been recorded, immediately send"), p.DynamicExtremeSnapshotCount), p.DynamicSnapshotCount, 1500); //p.DynamicSnapshotMinTimer = EditorGUILayout.IntField(new GUIContent("Dynamic Minimum Timer", "Time (in seconds) that must be elapsed before sending a new batch of Dynamic data. Ignored if the batch size reaches Dynamic Extreme Limit"), Mathf.Clamp(p.DynamicSnapshotMinTimer, 1, 60)); p.DynamicSnapshotMaxTimer = EditorGUILayout.IntField(new GUIContent("Dynamic Automatic Send Timer", "The time (in seconds) to automatically send any outstanding Dynamic snapshots or Manifest entries"), Mathf.Clamp(p.DynamicSnapshotMaxTimer, 1, 600)); //sensors EditorGUI.indentLevel++; EditorGUILayout.LabelField("Sensors", EditorStyles.boldLabel); EditorGUI.indentLevel--; p.SensorSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Sensor Snapshot Batch Size", "The number of Sensor datapoints to record before automatically sending a web request to the dashboard"), p.SensorSnapshotCount), 64, 1500); p.SensorExtremeSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Sensor Extreme Batch Size", "Threshold for ignoring the Sensor Minimum Timer. If this many Sensor datapoints have been recorded, immediately send"), p.SensorExtremeSnapshotCount), p.SensorSnapshotCount, 1500); p.SensorSnapshotMinTimer = EditorGUILayout.IntField(new GUIContent("Sensor Minimum Timer", "Time (in seconds) that must be elapsed before sending a new batch of Sensor data. Ignored if the batch size reaches Sensor Extreme Limit"), Mathf.Clamp(p.SensorSnapshotMinTimer, 1, 60)); p.SensorSnapshotMaxTimer = EditorGUILayout.IntField(new GUIContent("Sensor Automatic Send Timer", "The time (in seconds) to automatically send any outstanding Sensor data"), Mathf.Clamp(p.SensorSnapshotMaxTimer, p.SensorSnapshotMinTimer, 600)); //fixations EditorGUI.indentLevel++; EditorGUILayout.LabelField("Fixations", EditorStyles.boldLabel); EditorGUI.indentLevel--; p.FixationSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Fixation Snapshot Batch Size", "The number of Fixations to record before automatically sending a web request to the dashboard"), p.FixationSnapshotCount), 1, 1000); p.FixationExtremeSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Fixation Extreme Batch Size", "Threshold for ignoring the Fixation Minimum Timer. If this many Fixations have been recorded, immediately send"), p.FixationExtremeSnapshotCount), p.FixationSnapshotCount, 1000); p.FixationSnapshotMinTimer = EditorGUILayout.IntField(new GUIContent("Fixation Minimum Timer", "Time (in seconds) that must be elapsed before sending a new batch of Fixation data. Ignored if the batch size reaches Fixation Extreme Limit"), Mathf.Clamp(p.FixationSnapshotMinTimer, 1, 10)); p.FixationSnapshotMaxTimer = EditorGUILayout.IntField(new GUIContent("Fixation Automatic Send Timer", "The time (in seconds) to automatically send any outstanding Fixation data"), Mathf.Clamp(p.FixationSnapshotMaxTimer, p.FixationSnapshotMinTimer, 60)); EditorGUILayout.Space(); EditorGUILayout.LabelField("Local Data Cache", EditorStyles.boldLabel); //local storage p.LocalStorage = EditorGUILayout.Toggle("Save data to Local Cache if no internet connection", p.LocalStorage); EditorGUI.BeginDisabledGroup(!p.LocalStorage); GUILayout.BeginHorizontal(); p.LocalDataCacheSize = EditorGUILayout.LongField("Cache Size", p.LocalDataCacheSize); if (p.LocalDataCacheSize < 1048576) { p.LocalDataCacheSize = 1048576; } //at least 1mb of storage (1048576 bytes) EditorGUILayout.LabelField(EditorUtility.FormatBytes(p.LocalDataCacheSize), GUILayout.Width(100)); GUILayout.EndHorizontal(); p.ReadLocalCacheCount = EditorGUILayout.IntField(new GUIContent("Upload Local Cache Rate", "For each successful network response, read this number of cached requests from the local data cache"), p.ReadLocalCacheCount); p.ReadLocalCacheCount = Mathf.Max(p.ReadLocalCacheCount, 0); if (p.ReadLocalCacheCount == 0 && p.LocalStorage) { EditorGUILayout.HelpBox("Saved data will only be uploaded if manually called! See Docs", MessageType.Warning); } EditorGUI.EndDisabledGroup(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Sending Data", EditorStyles.boldLabel); CognitiveVR_Preferences.Instance.Protocol = EditorGUILayout.TextField(new GUIContent("Custom Protocol", "https"), CognitiveVR_Preferences.Instance.Protocol); CognitiveVR_Preferences.Instance.Gateway = EditorGUILayout.TextField(new GUIContent("Custom Gateway", "data.cognitive3d.com"), CognitiveVR_Preferences.Instance.Gateway); CognitiveVR_Preferences.Instance.Viewer = EditorGUILayout.TextField(new GUIContent("Custom Viewer", "sceneexplorer.com/scene/"), CognitiveVR_Preferences.Instance.Viewer); CognitiveVR_Preferences.Instance.Dashboard = EditorGUILayout.TextField(new GUIContent("Custom Dashboard", "app.cognitive3d.com"), CognitiveVR_Preferences.Instance.Dashboard); p.SendDataOnHMDRemove = EditorGUILayout.Toggle("Send Data on HMD Remove", p.SendDataOnHMDRemove); p.SendDataOnLevelLoad = EditorGUILayout.Toggle("Send Data on Level Load", p.SendDataOnLevelLoad); p.SendDataOnQuit = EditorGUILayout.Toggle("Send Data on Quit", p.SendDataOnQuit); p.SendDataOnHotkey = EditorGUILayout.Toggle("Send Data on Hotkey", p.SendDataOnHotkey); EditorGUI.indentLevel++; EditorGUI.BeginDisabledGroup(!p.SendDataOnHotkey); GUILayout.BeginHorizontal(); p.SendDataHotkey = (KeyCode)EditorGUILayout.EnumPopup("Hotkey", p.SendDataHotkey); if (p.HotkeyShift) { GUI.color = Color.green; } if (GUILayout.Button("Shift", EditorStyles.miniButtonLeft)) { p.HotkeyShift = !p.HotkeyShift; } GUI.color = Color.white; if (p.HotkeyCtrl) { GUI.color = Color.green; } if (GUILayout.Button("Ctrl", EditorStyles.miniButtonMid)) { p.HotkeyCtrl = !p.HotkeyCtrl; } GUI.color = Color.white; if (p.HotkeyAlt) { GUI.color = Color.green; } if (GUILayout.Button("Alt", EditorStyles.miniButtonRight)) { p.HotkeyAlt = !p.HotkeyAlt; } GUI.color = Color.white; /*if (remapHotkey) * { * GUILayout.Button("Any Key", EditorStyles.miniButton, GUILayout.Width(100)); * Event e = Event.current; * * if (e.type == EventType.keyDown && e.keyCode != KeyCode.None && e.keyCode != KeyCode.LeftShift && e.keyCode != KeyCode.RightShift && e.keyCode != KeyCode.LeftControl && e.keyCode != KeyCode.RightControl && e.keyCode != KeyCode.LeftAlt && e.keyCode != KeyCode.RightAlt) * { * p.HotkeyAlt = e.alt; * p.HotkeyShift = e.shift; * p.HotkeyCtrl = e.control; * p.SendDataHotkey = e.keyCode; * remapHotkey = false; * Repaint(); * } * } * else * { * if (GUILayout.Button("Remap", EditorStyles.miniButton,GUILayout.Width(100))) * { * remapHotkey = true; * } * }*/ GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; EditorGUILayout.Space(); EditorGUILayout.LabelField("Scene Export", EditorStyles.boldLabel); EditorGUI.indentLevel++; var v = CognitiveVR_Preferences.FindCurrentScene(); if (v == null || string.IsNullOrEmpty(v.SceneId)) { EditorGUILayout.LabelField("Current Scene: " + UnityEngine.SceneManagement.SceneManager.GetActiveScene().name + " Version: not uploaded"); } else { EditorGUILayout.LabelField("Current Scene: " + v.SceneName + " Version: " + v.VersionNumber); } EditorGUILayout.Space(); GUIContent[] textureQualityNames = new GUIContent[] { new GUIContent("Full"), new GUIContent("Half"), new GUIContent("Quarter"), new GUIContent("Eighth"), new GUIContent("Sixteenth"), new GUIContent("Thirty Second"), new GUIContent("Sixty Fourth") }; int[] textureQualities = new int[] { 1, 2, 4, 8, 16, 32, 64 }; p.TextureResize = EditorGUILayout.IntPopup(new GUIContent("Texture Export Quality", "Reduce textures when uploading to scene explorer"), p.TextureResize, textureQualityNames, textureQualities); //EditorCore.ExportSettings.TextureQuality = EditorGUILayout.IntPopup(new GUIContent("Texture Export Quality", "Reduce textures when uploading to scene explorer"), EditorCore.ExportSettings.TextureQuality, textureQualityNames, textureQualities); p.ExportSceneLODLowest = EditorGUILayout.Toggle("Export Lowest LOD from LODGroup components", p.ExportSceneLODLowest); p.ExportAOMaps = EditorGUILayout.Toggle("Export AO Maps", p.ExportAOMaps); GUILayout.BeginHorizontal(); //GUILayout.Space(15); //TODO texture export settings //the full process //refresh scene versions //save screenshot //export scene //decimate scene //confirm upload of scene. new scene? new version? //export dynamics //confirm uploading dynamics //confirm upload manifest if (GUILayout.Button("Export", "ButtonLeft")) { if (string.IsNullOrEmpty(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name)) { if (EditorUtility.DisplayDialog("Export Failed", "Cannot export scene that is not saved.\n\nDo you want to save now?", "Save", "Cancel")) { if (UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes()) { } else { return;//cancel from save scene window } } else { return;//cancel from 'do you want to save' popup } } CognitiveVR_SceneExportWindow.ExportGLTFScene(); string fullName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name; string objPath = CognitiveVR_SceneExportWindow.GetDirectory(fullName); string jsonSettingsContents = "{ \"scale\":1,\"sceneName\":\"" + fullName + "\",\"sdkVersion\":\"" + Core.SDK_VERSION + "\"}"; System.IO.File.WriteAllText(objPath + "settings.json", jsonSettingsContents); //CognitiveVR.CognitiveVR_SceneExportWindow.ExportScene(true, EditorCore.ExportSettings.ExportStaticOnly, EditorCore.ExportSettings.MinExportGeoSize, EditorCore.ExportSettings.TextureQuality, EditorCore.DeveloperKey, EditorCore.ExportSettings.DiffuseTextureName); CognitiveVR_Preferences.AddSceneSettings(UnityEngine.SceneManagement.SceneManager.GetActiveScene()); UnityEditor.AssetDatabase.SaveAssets(); } bool hasUploadFiles = EditorCore.HasSceneExportFolder(CognitiveVR_Preferences.FindCurrentScene()); EditorGUI.BeginDisabledGroup(!hasUploadFiles); if (GUILayout.Button("Upload", "ButtonRight")) { System.Action completedmanifestupload = delegate() { CognitiveVR_SceneExportWindow.UploadAllDynamicObjects(true); }; System.Action completedRefreshSceneVersion2 = delegate() { ManageDynamicObjects.UploadManifest(completedmanifestupload); }; //upload dynamics System.Action completeSceneUpload = delegate() { EditorCore.RefreshSceneVersion(completedRefreshSceneVersion2); //likely completed in previous step, but just in case }; //upload scene System.Action completedRefreshSceneVersion1 = delegate() { CognitiveVR_Preferences.SceneSettings current = CognitiveVR_Preferences.FindCurrentScene(); if (current == null || string.IsNullOrEmpty(current.SceneId)) { //new scene if (EditorUtility.DisplayDialog("Upload New Scene", "Upload " + current.SceneName + " to SceneExplorer?", "Ok", "Cancel")) { CognitiveVR_SceneExportWindow.UploadDecimatedScene(current, completeSceneUpload); } } else { //new version if (EditorUtility.DisplayDialog("Upload New Version", "Upload a new version of this existing scene? Will archive previous version", "Ok", "Cancel")) { CognitiveVR_SceneExportWindow.UploadDecimatedScene(current, completeSceneUpload); } } }; //get the latest verion of the scene if (string.IsNullOrEmpty(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name)) { if (EditorUtility.DisplayDialog("Upload Failed", "Cannot upload scene that is not saved.\n\nDo you want to save now?", "Save", "Cancel")) { if (UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes()) { EditorCore.RefreshSceneVersion(completedRefreshSceneVersion1); } else { return;//cancel from save scene window } } else { return;//cancel from 'do you want to save' popup } } else { EditorCore.RefreshSceneVersion(completedRefreshSceneVersion1); } } GUIContent ButtonContent = new GUIContent("Upload Screenshot"); if (v == null) { GUILayout.Button(ButtonContent); } else { if (GUILayout.Button(ButtonContent)) { EditorCore.UploadScreenshot(); } } EditorGUI.EndDisabledGroup(); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; GUILayout.EndHorizontal(); if (GUILayout.Button(new GUIContent("Refresh Latest Scene Versions", "Get the latest versionnumber and versionid for this scene"))) //ask scene explorer for all the versions of this active scene. happens automatically post scene upload { EditorCore.RefreshSceneVersion(null); } EditorGUILayout.Space(); EditorGUILayout.PropertyField(serializedObject.FindProperty("sceneSettings"), true); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); if (GUI.changed) { EditorUtility.SetDirty(p); } }
//writes manifest entry and object snapshot to string then send http request public IEnumerator Thread_StringThenSend(Queue <DynamicObjectManifestEntry> SendObjectManifest, Queue <DynamicObjectSnapshot> SendObjectSnapshots, CognitiveVR_Preferences.SceneSettings trackingSettings, string uniqueid, double sessiontimestamp, string sessionid) { //save and clear snapshots and manifest entries DynamicObjectManifestEntry[] tempObjectManifest = new DynamicObjectManifestEntry[SendObjectManifest.Count]; SendObjectManifest.CopyTo(tempObjectManifest, 0); SendObjectManifest.Clear(); DynamicObjectSnapshot[] tempSnapshots = new DynamicObjectSnapshot[SendObjectSnapshots.Count]; SendObjectSnapshots.CopyTo(tempSnapshots, 0); //for (int i = 0; i<tempSnapshots.Length; i++) //{ // var s = DynamicObject.SetSnapshot(tempSnapshots[i]); // Debug.Log(">>>>>>>>>>>>>queue snapshot " + s); //} //write manifest entries to thread List <string> manifestEntries = new List <string>(); bool done = true; if (tempObjectManifest.Length > 0) { done = false; new System.Threading.Thread(() => { for (int i = 0; i < tempObjectManifest.Length; i++) { manifestEntries.Add(DynamicObject.SetManifestEntry(tempObjectManifest[i])); } done = true; }).Start(); while (!done) { yield return(null); } } List <string> snapshots = new List <string>(); if (tempSnapshots.Length > 0) { done = false; new System.Threading.Thread(() => { for (int i = 0; i < tempSnapshots.Length; i++) { snapshots.Add(DynamicObject.SetSnapshot(tempSnapshots[i])); } //System.GC.Collect(); done = true; }).Start(); while (!done) { yield return(null); } } while (SendObjectSnapshots.Count > 0) { SendObjectSnapshots.Dequeue().ReturnToPool(); } DynamicObject.SendSavedSnapshots(manifestEntries, snapshots, trackingSettings, uniqueid, sessiontimestamp, sessionid); }
public override void OnInspectorGUI() { if (!hasCheckedRenderType) { CheckGazeRenderType(); hasCheckedRenderType = true; } var p = (CognitiveVR_Preferences)target; p.APIKey = EditorGUILayout.TextField("API Key", p.APIKey); p.EnableLogging = EditorGUILayout.Toggle("Enable Logging", p.EnableLogging); EditorGUILayout.Space(); EditorGUILayout.LabelField("3D Player Tracking", EditorStyles.boldLabel); p.GazeType = (GazeType)EditorGUILayout.EnumPopup("Gaze Type", p.GazeType); if (GUI.changed) { CheckGazeRenderType(); } p.SnapshotInterval = Mathf.Clamp(EditorGUILayout.FloatField("Snapshot Interval", p.SnapshotInterval), 0, 10); p.DynamicObjectSearchInParent = EditorGUILayout.Toggle(new GUIContent("Dynamic Object Search in Parent", "When capturing gaze on a Dynamic Object, also search in the collider's parent for the dynamic object component"), p.DynamicObjectSearchInParent); //TODO change tooltip based on selected gaze type p.TrackGPSLocation = EditorGUILayout.Toggle(new GUIContent("Track GPS Location", "Record GPS location and compass direction at the interval below"), p.TrackGPSLocation); EditorGUI.BeginDisabledGroup(!p.TrackGPSLocation); EditorGUI.indentLevel++; gpsFoldout = EditorGUILayout.Foldout(gpsFoldout, "GPS Options"); if (gpsFoldout) { p.SyncGPSWithGaze = EditorGUILayout.Toggle(new GUIContent("Sync with Player Update", "Request new GPS location every time the player position and gaze is recorded"), p.SyncGPSWithGaze); EditorGUI.BeginDisabledGroup(p.SyncGPSWithGaze); p.GPSInterval = Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent("GPS Update Interval", "Interval in seconds to record new GPS location data"), p.GPSInterval), 0.1f, 60f); EditorGUI.EndDisabledGroup(); p.GPSAccuracy = Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent("GPS Accuracy", "Desired accuracy in meters. Using higher values like 500 may not require GPS and may save battery power"), p.GPSAccuracy), 1f, 500f); } EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); p.RecordFloorPosition = EditorGUILayout.Toggle(new GUIContent("Record Floor Position", "Includes the floor position below the HMD in a VR experience"), p.RecordFloorPosition); EditorGUILayout.Space(); EditorGUILayout.LabelField("360 Player Tracking", EditorStyles.boldLabel); p.SnapshotInterval = Mathf.Clamp(EditorGUILayout.FloatField("Snapshot Interval", p.SnapshotInterval), 0, 10); //p.VideoSphereDynamicObjectId = EditorGUILayout.TextField("Video Sphere Dynamic Object Id", p.VideoSphereDynamicObjectId); //p.GazeDirectionMultiplier = Mathf.Clamp(EditorGUILayout.FloatField("Video Sphere Radius", p.GazeDirectionMultiplier), 0, 1000); EditorGUILayout.Space(); EditorGUILayout.LabelField("Sending Data Batches", EditorStyles.boldLabel); p.GazeSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField("Gaze Snapshot Batch Size", p.GazeSnapshotCount), 0, 1000); p.TransactionSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField("Event Snapshot Batch Size", p.TransactionSnapshotCount), 0, 1000); p.DynamicSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField("Dynamic Snapshot Batch Size", p.DynamicSnapshotCount), 0, 1000); p.SensorSnapshotCount = Mathf.Clamp(EditorGUILayout.IntField("Sensor Snapshot Batch Size", p.SensorSnapshotCount), 0, 1000); EditorGUILayout.Space(); EditorGUILayout.LabelField("Local Data Cache", EditorStyles.boldLabel); //local storage p.LocalStorage = EditorGUILayout.Toggle("Save data to Local Cache if no internet connection", p.LocalStorage); EditorGUI.BeginDisabledGroup(!p.LocalStorage); GUILayout.BeginHorizontal(); p.LocalDataCacheSize = EditorGUILayout.LongField("Cache Size", p.LocalDataCacheSize); if (p.LocalDataCacheSize < 1048576) { p.LocalDataCacheSize = 1048576; } //at least 1mb of storage (1048576 bytes) EditorGUILayout.LabelField(EditorUtility.FormatBytes(p.LocalDataCacheSize), GUILayout.Width(100)); GUILayout.EndHorizontal(); p.ReadLocalCacheCount = EditorGUILayout.IntField(new GUIContent("Upload Local Cache Rate", "For each successful network response, read this number of cached requests from the local data cache"), p.ReadLocalCacheCount); p.ReadLocalCacheCount = Mathf.Max(p.ReadLocalCacheCount, 0); if (p.ReadLocalCacheCount == 0 && p.LocalStorage) { EditorGUILayout.HelpBox("Saved data will only be uploaded if manually called! See Docs", MessageType.Warning); } EditorGUI.EndDisabledGroup(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Sending Data", EditorStyles.boldLabel); CognitiveVR_Preferences.Instance.Protocol = EditorGUILayout.TextField(new GUIContent("Custom Protocol", "https"), CognitiveVR_Preferences.Instance.Protocol); CognitiveVR_Preferences.Instance.Gateway = EditorGUILayout.TextField(new GUIContent("Custom Gateway", "data.cognitive3d.com"), CognitiveVR_Preferences.Instance.Gateway); CognitiveVR_Preferences.Instance.Viewer = EditorGUILayout.TextField(new GUIContent("Custom Viewer", "sceneexplorer.com/scene/"), CognitiveVR_Preferences.Instance.Viewer); CognitiveVR_Preferences.Instance.Dashboard = EditorGUILayout.TextField(new GUIContent("Custom Dashboard", "app.cognitive3d.com"), CognitiveVR_Preferences.Instance.Dashboard); p.SendDataOnHMDRemove = EditorGUILayout.Toggle("Send Data on HMD Remove", p.SendDataOnHMDRemove); p.SendDataOnLevelLoad = EditorGUILayout.Toggle("Send Data on Level Load", p.SendDataOnLevelLoad); p.SendDataOnQuit = EditorGUILayout.Toggle("Send Data on Quit", p.SendDataOnQuit); p.SendDataOnHotkey = EditorGUILayout.Toggle("Send Data on Hotkey", p.SendDataOnHotkey); EditorGUI.indentLevel++; EditorGUI.BeginDisabledGroup(!p.SendDataOnHotkey); GUILayout.BeginHorizontal(); p.SendDataHotkey = (KeyCode)EditorGUILayout.EnumPopup("Hotkey", p.SendDataHotkey); if (p.HotkeyShift) { GUI.color = Color.green; } if (GUILayout.Button("Shift", EditorStyles.miniButtonLeft)) { p.HotkeyShift = !p.HotkeyShift; } GUI.color = Color.white; if (p.HotkeyCtrl) { GUI.color = Color.green; } if (GUILayout.Button("Ctrl", EditorStyles.miniButtonMid)) { p.HotkeyCtrl = !p.HotkeyCtrl; } GUI.color = Color.white; if (p.HotkeyAlt) { GUI.color = Color.green; } if (GUILayout.Button("Alt", EditorStyles.miniButtonRight)) { p.HotkeyAlt = !p.HotkeyAlt; } GUI.color = Color.white; /*if (remapHotkey) * { * GUILayout.Button("Any Key", EditorStyles.miniButton, GUILayout.Width(100)); * Event e = Event.current; * * if (e.type == EventType.keyDown && e.keyCode != KeyCode.None && e.keyCode != KeyCode.LeftShift && e.keyCode != KeyCode.RightShift && e.keyCode != KeyCode.LeftControl && e.keyCode != KeyCode.RightControl && e.keyCode != KeyCode.LeftAlt && e.keyCode != KeyCode.RightAlt) * { * p.HotkeyAlt = e.alt; * p.HotkeyShift = e.shift; * p.HotkeyCtrl = e.control; * p.SendDataHotkey = e.keyCode; * remapHotkey = false; * Repaint(); * } * } * else * { * if (GUILayout.Button("Remap", EditorStyles.miniButton,GUILayout.Width(100))) * { * remapHotkey = true; * } * }*/ GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; EditorGUILayout.Space(); EditorGUILayout.LabelField("Scene Export", EditorStyles.boldLabel); EditorGUI.indentLevel++; var v = CognitiveVR_Preferences.FindCurrentScene(); if (v == null || string.IsNullOrEmpty(v.SceneId)) { EditorGUILayout.LabelField("Current Scene: " + UnityEngine.SceneManagement.SceneManager.GetActiveScene().name + " Version: not uploaded"); } else { EditorGUILayout.LabelField("Current Scene: " + v.SceneName + " Version: " + v.VersionNumber); } EditorGUILayout.Space(); GUILayout.BeginHorizontal(); EditorCore.BlenderPath = EditorGUILayout.TextField("Blender Path", EditorCore.BlenderPath); if (GUILayout.Button("...", GUILayout.Width(40))) { EditorCore.BlenderPath = EditorUtility.OpenFilePanel("Select Blender", string.IsNullOrEmpty(EditorCore.BlenderPath) ? "c:\\" : EditorCore.BlenderPath, ""); } GUILayout.EndHorizontal(); EditorCore.ExportSettings.ExportStaticOnly = EditorGUILayout.Toggle(new GUIContent("Export Static Meshes Only", "Only export meshes marked as static. Dynamic objects (such as vehicles, doors, etc) will not be exported"), EditorCore.ExportSettings.ExportStaticOnly); EditorCore.ExportSettings.MinExportGeoSize = Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent("Minimum Export size", "Ignore exporting meshes that are below this size(pebbles, grass,etc)"), EditorCore.ExportSettings.MinExportGeoSize), 0, 100); EditorCore.ExportSettings.ExplorerMinimumFaceCount = Mathf.Max(EditorGUILayout.IntField(new GUIContent("Minimum Face Count", "Ignore decimating objects with fewer faces than this value"), EditorCore.ExportSettings.ExplorerMinimumFaceCount), 0); EditorCore.ExportSettings.ExplorerMaximumFaceCount = Mathf.Max(EditorGUILayout.IntField(new GUIContent("Maximum Face Count", "Objects with this many faces will be decimated to 10% of their original face count"), EditorCore.ExportSettings.ExplorerMaximumFaceCount), EditorCore.ExportSettings.ExplorerMinimumFaceCount); EditorCore.ExportSettings.DiffuseTextureName = EditorGUILayout.TextField(new GUIContent("Diffuse Texture Name", "The name of the main diffuse texture to export. Generally _MainTex, but possibly something else if you are using a custom shader"), EditorCore.ExportSettings.DiffuseTextureName); GUIContent[] textureQualityNames = new GUIContent[] { new GUIContent("Full"), new GUIContent("Half"), new GUIContent("Quarter"), new GUIContent("Eighth"), new GUIContent("Sixteenth") }; int[] textureQualities = new int[] { 1, 2, 4, 8, 16 }; EditorCore.ExportSettings.TextureQuality = EditorGUILayout.IntPopup(new GUIContent("Texture Export Quality", "Reduce textures when uploading to scene explorer"), EditorCore.ExportSettings.TextureQuality, textureQualityNames, textureQualities); GUILayout.BeginHorizontal(); GUILayout.Space(15); //the full process //refresh scene versions //save screenshot //export scene //decimate scene //confirm upload of scene. new scene? new version? //export dynamics //confirm uploading dynamics //confirm upload manifest if (GUILayout.Button("Export", "ButtonLeft")) { if (string.IsNullOrEmpty(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name)) { if (EditorUtility.DisplayDialog("Export Failed", "Cannot export scene that is not saved.\n\nDo you want to save now?", "Save", "Cancel")) { if (UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes()) { } else { return;//cancel from save scene window } } else { return;//cancel from 'do you want to save' popup } } CognitiveVR.CognitiveVR_SceneExportWindow.ExportScene(true, EditorCore.ExportSettings.ExportStaticOnly, EditorCore.ExportSettings.MinExportGeoSize, EditorCore.ExportSettings.TextureQuality, EditorCore.DeveloperKey, EditorCore.ExportSettings.DiffuseTextureName); CognitiveVR_Preferences.AddSceneSettings(UnityEngine.SceneManagement.SceneManager.GetActiveScene()); UnityEditor.AssetDatabase.SaveAssets(); } bool hasUploadFiles = EditorCore.HasSceneExportFolder(CognitiveVR_Preferences.FindCurrentScene()); EditorGUI.BeginDisabledGroup(!hasUploadFiles); if (GUILayout.Button("Upload", "ButtonRight")) { System.Action completedmanifestupload = delegate() { CognitiveVR_SceneExportWindow.UploadAllDynamicObjects(true); }; System.Action completedRefreshSceneVersion2 = delegate() { ManageDynamicObjects.UploadManifest(completedmanifestupload); }; //upload dynamics System.Action completeSceneUpload = delegate() { EditorCore.RefreshSceneVersion(completedRefreshSceneVersion2); //likely completed in previous step, but just in case }; //upload scene System.Action completedRefreshSceneVersion1 = delegate() { CognitiveVR_Preferences.SceneSettings current = CognitiveVR_Preferences.FindCurrentScene(); if (current == null || string.IsNullOrEmpty(current.SceneId)) { //new scene if (EditorUtility.DisplayDialog("Upload New Scene", "Upload " + current.SceneName + " to SceneExplorer?", "Ok", "Cancel")) { CognitiveVR_SceneExportWindow.UploadDecimatedScene(current, completeSceneUpload); } } else { //new version if (EditorUtility.DisplayDialog("Upload New Version", "Upload a new version of this existing scene? Will archive previous version", "Ok", "Cancel")) { CognitiveVR_SceneExportWindow.UploadDecimatedScene(current, completeSceneUpload); } } }; //get the latest verion of the scene if (string.IsNullOrEmpty(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name)) { if (EditorUtility.DisplayDialog("Upload Failed", "Cannot upload scene that is not saved.\n\nDo you want to save now?", "Save", "Cancel")) { if (UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes()) { EditorCore.RefreshSceneVersion(completedRefreshSceneVersion1); } else { return;//cancel from save scene window } } else { return;//cancel from 'do you want to save' popup } } else { EditorCore.RefreshSceneVersion(completedRefreshSceneVersion1); } } GUIContent ButtonContent = new GUIContent("Upload Screenshot"); if (v == null) { GUILayout.Button(ButtonContent); } else { if (GUILayout.Button(ButtonContent)) { EditorCore.UploadScreenshot(); } } EditorGUI.EndDisabledGroup(); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; GUILayout.EndHorizontal(); if (GUILayout.Button(new GUIContent("Refresh Latest Scene Versions", "Get the latest versionnumber and versionid for this scene"))) //ask scene explorer for all the versions of this active scene. happens automatically post scene upload { EditorCore.RefreshSceneVersion(null); } EditorGUILayout.Space(); EditorGUILayout.PropertyField(serializedObject.FindProperty("sceneSettings"), true); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); if (GUI.changed) { EditorUtility.SetDirty(p); } }
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; }
void DrawNextButton() { bool buttonDisabled = false; bool appearDisabled = false; //used on dynamic upload page to skip step string text = "Next"; System.Action onclick = () => currentPage++; Rect buttonrect = new Rect(410, 460, 80, 30); switch (pageids[currentPage]) { case "welcome": break; case "authenticate": buttonrect = new Rect(350, 460, 140, 30); onclick += () => SaveKeys(); buttonDisabled = apikey == null || apikey.Length == 0 || developerkey == null || developerkey.Length == 0; if (buttonDisabled) { text = "Keys Required"; } else { text = "Next"; } break; case "tagdynamics": break; case "selectsdk": onclick += () => EditorCore.SetPlayerDefine(selectedsdks); onclick += () => { var found = Object.FindObjectOfType <CognitiveVR_Manager>(); if (found == null) //add cognitivevr_manager { string gameobjectName = "CognitiveVR_Manager"; #if CVR_NEURABLE gameobjectName = "Neurable Cognitive Engine"; #endif EditorCore.SpawnManager(gameobjectName); } }; break; case "listdynamics": var dynamics = GetDynamicObjects; int dynamicsFromSceneExported = 0; for (int i = 0; i < dynamics.Length; i++) { if (EditorCore.GetExportedDynamicObjectNames().Contains(dynamics[i].MeshName) || !dynamics[i].UseCustomMesh) { dynamicsFromSceneExported++; } } appearDisabled = dynamicsFromSceneExported != dynamics.Length; if (appearDisabled) { onclick = () => { if (EditorUtility.DisplayDialog("Continue", "Are you sure you want to continue without uploading all Dynamic Objects?", "Yes", "No")) { currentPage++; } }; } if (dynamics.Length == 0 && dynamicsFromSceneExported == 0) { text = "Skip Dynamics"; } else { text = dynamicsFromSceneExported + "/" + dynamics.Length + " Uploaded"; } buttonrect = new Rect(350, 460, 140, 30); break; case "uploadscene": //buttonDisabled = !EditorCore.HasSceneExportFiles(CognitiveVR_Preferences.FindCurrentScene()); buttonrect = new Rect(1000, 1000, 100, 100); onclick = () => { Debug.Log("custom button"); }; /*appearDisabled = !EditorCore.HasSceneExportFiles(CognitiveVR_Preferences.FindCurrentScene()); * if (appearDisabled) * { * onclick = () => { if (EditorUtility.DisplayDialog("Continue", "Are you sure you want to continue without exporting this scene?", "Yes", "No")) { currentPage++; } }; * }*/ break; case "upload": onclick += () => EditorCore.RefreshSceneVersion(null); if (understandRevealTime > EditorApplication.timeSinceStartup) { buttonDisabled = true; } text = "I understand, Continue"; buttonrect = new Rect(290, 460, 200, 30); break; case "uploadsummary": System.Action completedmanifestupload = delegate() { CognitiveVR_SceneExportWindow.UploadAllDynamicObjects(true); currentPage = 9; }; //fifth upload manifest System.Action completedRefreshSceneVersion = delegate() { //TODO this might cause a race condition for uploading dynamics and manifest ManageDynamicObjects.UploadManifest(completedmanifestupload); }; //fourth upload dynamics System.Action completeSceneUpload = delegate() { EditorCore.RefreshSceneVersion(completedRefreshSceneVersion); //likely completed in previous step, but just in case }; //third upload scene System.Action completeScreenshot = delegate(){ CognitiveVR_Preferences.SceneSettings current = CognitiveVR_Preferences.FindCurrentScene(); if (current == null || string.IsNullOrEmpty(current.SceneId)) { if (EditorUtility.DisplayDialog("Upload New Scene", "Upload " + current.SceneName + " to SceneExplorer?", "Ok", "Cancel")) { //new scene CognitiveVR_SceneExportWindow.UploadDecimatedScene(current, completeSceneUpload); } } else { //new version if (EditorUtility.DisplayDialog("Upload New Version", "Upload a new version of this existing scene? Will archive previous version", "Ok", "Cancel")) { CognitiveVR_SceneExportWindow.UploadDecimatedScene(current, completeSceneUpload); } } }; //second save screenshot System.Action completedRefreshSceneVersion1 = delegate() { EditorCore.SaveCurrentScreenshot(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name, completeScreenshot); }; //first refresh scene version onclick = () => { if (string.IsNullOrEmpty(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name)) //scene not saved. "do want save?" popup { if (EditorUtility.DisplayDialog("Upload Failed", "Cannot upload scene that is not saved.\n\nDo you want to save now?", "Save", "Cancel")) { if (UnityEditor.SceneManagement.EditorSceneManager.SaveOpenScenes()) { EditorCore.RefreshSceneVersion(completedRefreshSceneVersion1); } else { return;//cancel from save scene window } } else { return;//cancel from 'do you want to save' popup } } else { EditorCore.RefreshSceneVersion(completedRefreshSceneVersion1); } }; buttonDisabled = !EditorCore.HasSceneExportFolder(CognitiveVR_Preferences.FindCurrentScene()); text = "Upload"; break; case "done": onclick = () => Close(); text = "Close"; break; } if (appearDisabled) { if (GUI.Button(buttonrect, text, "button_disabled")) { onclick.Invoke(); } } else if (buttonDisabled) { GUI.Button(buttonrect, text, "button_disabled"); } else { if (GUI.Button(buttonrect, text)) { if (onclick != null) { onclick.Invoke(); } } } }