public override void OnInspectorGUI() { serializedObject.Update(); // Courses can change without recompile so we have to check for them. UpdateAvailableCourses(); DrawRuntimeConfigurationDropDown(); EditorGUI.BeginDisabledGroup(IsCourseListEmpty()); { DrawCourseSelectionDropDown(); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Open Course in Workflow window")) { GlobalEditorHandler.SetCurrentCourse(CourseAssetUtils.GetCourseNameFromPath(configurator.GetSelectedCourse())); GlobalEditorHandler.StartEditingCourse(); } if (GUILayout.Button(new GUIContent("Show Course in Explorer..."))) { string absolutePath = $"{new FileInfo(CourseAssetUtils.GetCourseAssetPath(CourseAssetUtils.GetCourseNameFromPath(configurator.GetSelectedCourse())))}"; EditorUtility.RevealInFinder(absolutePath); } } GUILayout.EndHorizontal(); } EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Sets the course with given <paramref name="courseName"/> for the current scene. /// </summary> /// <param name="courseName">Name of the course.</param> public static void SetCourseInCurrentScene(string courseName) { RuntimeConfigurator.Instance.SetSelectedCourse(CourseAssetUtils.GetCourseStreamingAssetPath(courseName)); EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); GlobalEditorHandler.SetCurrentCourse(courseName); GlobalEditorHandler.StartEditingCourse(); }
private void OnGUI() { // Magic number. minSize = new Vector2(420f, 320f); titleContent = new GUIContent("Training Course Wizard"); GUIStyle labelStyle = new GUIStyle(EditorStyles.label); labelStyle.richText = true; labelStyle.wordWrap = true; EditorIcon logo = new EditorIcon("logo_creator"); Rect rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box); GUI.DrawTexture(rect, logo.Texture, ScaleMode.ScaleToFit); if (RuntimeConfigurator.Exists == false) { EditorGUILayout.HelpBox("The current scene is not a training scene. No course can be created. To automatically setup the scene, select \"Innoactive > Setup Training Scene\".", MessageType.Error); } EditorGUI.BeginDisabledGroup(RuntimeConfigurator.Exists == false); EditorGUILayout.LabelField("<b>Create a new training course.</b>", labelStyle); courseName = EditorGUILayout.TextField(new GUIContent("Training Course Name", "Set a file name for the new training course."), courseName); EditorGUILayout.LabelField("The new course will be set for the current scene."); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // ReSharper disable once InvertIf if (GUILayout.Button("Create", GUILayout.Width(128), GUILayout.Height(32))) { if (CourseAssetUtils.CanCreate(courseName, out errorMessage)) { CourseAssetManager.Import(EntityFactory.CreateCourse(courseName)); RuntimeConfigurator.Instance.SetSelectedCourse(CourseAssetUtils.GetCourseStreamingAssetPath(courseName)); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); GlobalEditorHandler.SetCurrentCourse(courseName); GlobalEditorHandler.StartEditingCourse(); Close(); } } EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (string.IsNullOrEmpty(errorMessage) == false) { EditorGUILayout.HelpBox(errorMessage, MessageType.Error); } }