//each row is 30 pixels void DrawDynamicObject(DynamicObject dynamic, Rect rect, bool darkbackground) { Event e = Event.current; if (e.isMouse && e.type == EventType.mouseDown) { if (e.mousePosition.x < rect.x || e.mousePosition.x > rect.x + rect.width || e.mousePosition.y < rect.y || e.mousePosition.y > rect.y + rect.height) { } else { if (e.shift) //add to selection { GameObject[] gos = new GameObject[Selection.transforms.Length + 1]; Selection.gameObjects.CopyTo(gos, 0); gos[gos.Length - 1] = dynamic.gameObject; Selection.objects = gos; } else { Selection.activeTransform = dynamic.transform; } } } if (darkbackground) { GUI.Box(rect, "", "dynamicentry_even"); } else { GUI.Box(rect, "", "dynamicentry_odd"); } //GUI.color = Color.white; Rect mesh = new Rect(rect.x + 10, rect.y, 120, rect.height); Rect gameobject = new Rect(rect.x + 160, rect.y, 120, rect.height); //Rect id = new Rect(rect.x + 290, rect.y, 120, rect.height); Rect collider = new Rect(rect.x + 320, rect.y, 24, rect.height); Rect uploaded = new Rect(rect.x + 380, rect.y, 24, rect.height); if (dynamic.UseCustomMesh) { GUI.Label(mesh, dynamic.MeshName, "dynamiclabel"); } else { GUI.Label(mesh, dynamic.CommonMesh.ToString(), "dynamiclabel"); } GUI.Label(gameobject, dynamic.gameObject.name, "dynamiclabel"); if (!dynamic.HasCollider()) { GUI.Label(collider, new GUIContent(EditorCore.Alert, "Tracking Gaze requires a collider"), "image_centered"); } if (EditorCore.GetExportedDynamicObjectNames().Contains(dynamic.MeshName) || !dynamic.UseCustomMesh) { GUI.Label(uploaded, EditorCore.Checkmark, "image_centered"); } else { GUI.Label(uploaded, EditorCore.EmptyCheckmark, "image_centered"); } }
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(); } } } }