Пример #1
0
        /// <summary>
        /// Creates and saves a new simple example scene.
        /// </summary>
        /// <remarks>The new scene is meant to be used for step by step guides.</remarks>
        public static void CreateNewSimpleExampleScene()
        {
            string courseName = SimpleExampleName;
            int    counter    = 1;

            while (CourseAssetUtils.DoesCourseAssetExist(courseName) || CourseAssetUtils.CanCreate(courseName, out string errorMessage) == false)
            {
                courseName = $"{SimpleExampleName}_{counter}";
                counter++;
            }

            CreateNewScene(courseName);

            GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            sphere.name = "Sphere";
            sphere.transform.position = new Vector3(0f, 0.5f, 2f);

            GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);

            plane.name = "Plane";
            plane.transform.localScale = new Vector3(2f, 2f, 2f);

            SetupSceneAndTraining(courseName);
        }
Пример #2
0
        /// <summary>
        /// Sets up the current scene and creates a new training course for this scene.
        /// </summary>
        /// <param name="courseName">Name of the training course.</param>
        public static void SetupSceneAndTraining(string courseName)
        {
            TrainingSceneSetup.Run();

            string errorMessage = null;

            if (CourseAssetUtils.DoesCourseAssetExist(courseName) || CourseAssetUtils.CanCreate(courseName, out errorMessage))
            {
                if (CourseAssetUtils.DoesCourseAssetExist(courseName))
                {
                    CourseAssetManager.Load(courseName);
                }
                else
                {
                    CourseAssetManager.Import(EntityFactory.CreateCourse(courseName));
                    AssetDatabase.Refresh();
                }

                SetCourseInCurrentScene(courseName);
            }

            if (string.IsNullOrEmpty(errorMessage) == false)
            {
                Debug.LogError(errorMessage);
            }

            try
            {
                EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
        /// <inheritdoc />
        public override void Draw(Rect window)
        {
            GUILayout.BeginArea(window);

            GUILayout.Label("Setup Training", CreatorEditorStyles.Title);

            GUI.enabled = loadSampleScene == false;
            GUILayout.Label("Name of your VR Training", CreatorEditorStyles.Header);
            courseName  = CreatorGUILayout.DrawTextField(courseName, MaxCourseNameLength, GUILayout.Width(window.width * 0.7f));
            GUI.enabled = true;

            if (CourseAssetUtils.CanCreate(courseName, out string errorMessage) == false && lastCreatedCourse != courseName)
            {
                GUIContent courseWarningContent = warningContent;
                courseWarningContent.text = errorMessage;
                GUILayout.Label(courseWarningContent, CreatorEditorStyles.Label, GUILayout.MinHeight(MinHeightOfInfoText));
                CanProceed = false;
            }
            else
            {
                GUILayout.Space(MinHeightOfInfoText + CreatorEditorStyles.BaseIndent);
                CanProceed = true;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Space(CreatorEditorStyles.Indent);
            GUILayout.BeginVertical();
            bool isUseCurrentScene = GUILayout.Toggle(useCurrentScene, "Take my current scene", CreatorEditorStyles.RadioButton);

            if (useCurrentScene == false && isUseCurrentScene)
            {
                useCurrentScene = true;
                createNewScene  = false;
                loadSampleScene = false;
            }

            bool isCreateNewScene = GUILayout.Toggle(createNewScene, "Create a new scene", CreatorEditorStyles.RadioButton);

            if (createNewScene == false && isCreateNewScene)
            {
                createNewScene  = true;
                useCurrentScene = false;
                loadSampleScene = false;
            }

            EditorGUILayout.Space();

            loadSampleScene = GUILayout.Toggle(loadSampleScene, "Load Step by Step Guide Scene", CreatorEditorStyles.RadioButton);
            if (loadSampleScene)
            {
                createNewScene  = false;
                useCurrentScene = false;
                CanProceed      = true;

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(CreatorEditorStyles.Indent);
                    CreatorGUILayout.DrawLink("Hello Creator – a 5-step guide to a basic training application", "https://developers.innoactive.de/documentation/creator/latest/articles/step-by-step-guides/hello-creator.html");
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (createNewScene)
            {
                GUIContent helpContent;
                string     sceneInfoText = "Scene will have the same name as the training course.";
                if (SceneSetupUtils.SceneExists(courseName))
                {
                    sceneInfoText += " Scene already exists";
                    CanProceed     = false;
                    helpContent    = warningContent;
                }
                else
                {
                    helpContent = infoContent;
                }

                helpContent.text = sceneInfoText;
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(CreatorEditorStyles.Indent);
                    EditorGUILayout.LabelField(helpContent, CreatorEditorStyles.Label, GUILayout.MinHeight(MinHeightOfInfoText));
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.EndArea();
        }