Ejemplo n.º 1
0
        private void UpdateAvailableCourses()
        {
            if (isDirty == false)
            {
                return;
            }

            List <string> courses = CourseAssetUtils.GetAllCourses().ToList();

            // Create dummy entry if no files are present.
            if (courses.Any() == false)
            {
                trainingCourseDisplayNames.Clear();
                trainingCourseDisplayNames.Add("<none>");
                return;
            }

            trainingCourseDisplayNames = courses;
            trainingCourseDisplayNames.Sort();

            if (string.IsNullOrEmpty(configurator.GetSelectedCourse()))
            {
                SetConfiguratorSelectedCourse(CourseAssetUtils.GetCourseStreamingAssetPath(trainingCourseDisplayNames[0]));
                GlobalEditorHandler.SetCurrentCourse(CourseAssetUtils.GetCourseAssetPath(configurator.GetSelectedCourse()));
            }
        }
Ejemplo n.º 2
0
        private void DrawCourseSelectionDropDown()
        {
            int index = 0;

            string courseName = CourseAssetUtils.GetCourseNameFromPath(configurator.GetSelectedCourse());

            if (string.IsNullOrEmpty(courseName) == false)
            {
                index = trainingCourseDisplayNames.FindIndex(courseName.Equals);
            }

            index = EditorGUILayout.Popup("Selected Training Course", index, trainingCourseDisplayNames.ToArray());

            if (index < 0)
            {
                index = 0;
            }

            string newCourseStreamingAssetsPath = CourseAssetUtils.GetCourseStreamingAssetPath(trainingCourseDisplayNames[index]);

            if (IsCourseListEmpty() == false && configurator.GetSelectedCourse() != newCourseStreamingAssetsPath)
            {
                SetConfiguratorSelectedCourse(newCourseStreamingAssetsPath);
                GlobalEditorHandler.SetCurrentCourse(trainingCourseDisplayNames[index]);
            }
        }
Ejemplo n.º 3
0
 /// <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();
 }
Ejemplo n.º 4
0
        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);
            }
        }