コード例 #1
0
        void OnGUI()
        {
            if (m_Styles == null)
            {
                TutorialStyles.DisplayErrorMessage("TutorialModalWindow.cs");
                return;
            }

            if (m_WelcomePage == null)
            {
                return;
            }

            if (Event.current.isKey && Event.current.keyCode == KeyCode.Escape)
            {
                Close();
                return;
            }

            if (ProjectMode.IsAuthoringMode())
            {
                DrawToolbar();
            }

            GUISkin oldSkin = GUI.skin;

            GUI.skin = m_Styles.skin;

            using (new EditorGUILayout.HorizontalScope(GUILayout.Width(kWidth), GUILayout.Height(kHeight)))
            {
                // left column, "image column"
                using (new EditorGUILayout.VerticalScope(GUILayout.Width(kLeftColumnWidth), GUILayout.Height(kHeight)))
                {
                    GUILayout.Label(GUIContent.none);
                }
                if (m_WelcomePage.icon != null)
                {
                    GUI.DrawTexture(GUILayoutUtility.GetLastRect(), m_WelcomePage.icon, ScaleMode.StretchToFill);
                }

                // right column
                using (new EditorGUILayout.HorizontalScope(AllTutorialStyles.background))
                {
                    GUILayout.Space(8f);

                    using (new EditorGUILayout.VerticalScope(AllTutorialStyles.background, GUILayout.Height(kHeight)))
                    {
                        const bool pageCompleted     = false;
                        var        previousTaskState = true;
                        foreach (var paragraph in m_Paragraphs)
                        {
                            if (paragraph.paragraph.type == ParagraphType.Instruction)
                            {
                                GUILayout.Space(2f);
                            }

                            paragraph.Draw(ref previousTaskState, pageCompleted);
                        }

                        using (new EditorGUILayout.HorizontalScope())
                        {
                            if (GUILayout.Button(m_WelcomePage.startButtonLabel, AllTutorialStyles.welcomeDialogButton))
                            {
                                Close();
                            }
                            GUILayout.FlexibleSpace();
                        }
                    }
                }
            }

            GUI.skin = oldSkin;
        }
コード例 #2
0
ファイル: TutorialWindow.cs プロジェクト: Draz96/possessione
        void OnGUI()
        {
            //Force the GUI color to always be white, so the tutorial window
            //will not be darkened  while in playmode
            GUI.color = Color.white;

            GUISkin oldSkin = GUI.skin;

            GUI.skin = m_Styles.skin;

            if (m_AuthoringMode)
            {
                ToolbarGUI();
            }

            if (m_Styles == null)
            {
                TutorialStyles.DisplayErrorMessage("TutorialWindow.cs");
                return;
            }

            if (m_CurrentTutorial == null)
            {
                EditorGUILayout.HelpBox("No tutorial currently loaded. Please load one to begin.", MessageType.Info);
                return;
            }

            //Might be used later if a completed page is desired

            /*if (m_CurrentTutorial.IsCompletedPageShowing)
             * {
             *  DrawCompletedPage();
             * }*/

            var useGrayBackground =
                m_CurrentTutorial.currentPage != null &&
                m_CurrentTutorial.currentPage.paragraphs.All(element => element.type == ParagraphType.Narrative);

            using (var background = new EditorGUILayout.VerticalScope(useGrayBackground ? AllTutorialStyles.fullGreyBackground : AllTutorialStyles.background ?? GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)))
            {
                TopBar();

                if (m_CurrentTutorial.currentPage == null)
                {
                    GUILayout.Label(string.Format("No step {0} assigned for {1}.", m_CurrentTutorial.currentPageIndex, m_CurrentTutorial));
                }
                else
                {
                    // disable GUI except scrollbar/toolbar/gutter when revisiting a previously completed page to clearly indicate its tasks are no longer active
                    var pageCompleted = m_CurrentTutorial.currentPageIndex <= m_FarthestPageCompleted;
                    if (!string.IsNullOrEmpty(m_CurrentTutorial.currentPage.sectionTitle))
                    {
                        using (var bg = new EditorGUILayout.HorizontalScope(AllTutorialStyles.sectionTitleBackground, GUILayout.ExpandWidth(true)))
                        {
                            using (new EditorGUI.DisabledScope(pageCompleted))
                                GUILayout.Label(m_CurrentTutorial.currentPage.sectionTitle, AllTutorialStyles.sectionTitleLabel);
                        }
                    }

                    var previousTaskState = true;
                    using (var scrollView = new EditorGUILayout.ScrollViewScope(m_ScrollPosition, GUI.skin.verticalScrollbar, GUIStyle.none))
                    {
                        using (new EditorGUI.DisabledScope(pageCompleted))
                        {
                            foreach (var paragraph in m_Paragraphs)
                            {
                                if (paragraph.paragraph.type == ParagraphType.Instruction)
                                {
                                    GUILayout.Space(2f);
                                }

                                paragraph.Draw(ref previousTaskState, pageCompleted);
                            }
                        }
                        m_ScrollPosition = scrollView.scrollPosition;
                        GUILayout.FlexibleSpace();
                    }
                    GutterGUI(m_CurrentTutorial.currentPageIndex, m_CurrentTutorial.pageCount, background.rect);
                }
            }

            GUI.skin = oldSkin;
        }
コード例 #3
0
        void OnGUI()
        {
            if (m_Styles == null)
            {
                TutorialStyles.DisplayErrorMessage("TutorialModalWindow.cs");
                return;
            }

            if (m_WelcomePage == null)
            {
                return;
            }

            if (Event.current.isKey && Event.current.keyCode == KeyCode.Escape)
            {
                Close();
                return;
            }

            GUISkin oldSkin = GUI.skin;

            GUI.skin = m_Styles.skin;

            using (new EditorGUILayout.VerticalScope(AllTutorialStyles.background ?? GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)))
            {
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Box(m_WelcomePage.icon, GUI.skin.box, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                if (m_DrawAsCompleted)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Box(GUIContent.none, AllTutorialStyles.line ?? GUIStyle.none);
                    GUILayout.Label("Completed", AllTutorialStyles.instructionLabel, GUILayout.ExpandWidth(false));
                    GUILayout.Box(GUIContent.none, AllTutorialStyles.line ?? GUIStyle.none);
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.Box(GUIContent.none, AllTutorialStyles.line ?? GUIStyle.none);
                }


                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label(m_WelcomePage.title, AllTutorialStyles.headerLabel ?? GUIStyle.none);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.FlexibleSpace();
                var btnStyle = GUI.skin.button;
                btnStyle.fixedWidth   = 0;
                btnStyle.stretchWidth = true;
                if (GUILayout.Button(m_DrawAsCompleted ? m_WelcomePage.finishButtonLabel : " ", btnStyle))
                {
                    Close();
                }
            }

            GUI.skin = oldSkin;
        }