コード例 #1
0
ファイル: TutorialWindow.cs プロジェクト: Draz96/possessione
        void OnEnable()
        {
            window         = this;
            window.minSize = new Vector2(300f, 380f);
            if (m_CurrentTutorial == null)
            {
                string[] guids = AssetDatabase.FindAssets("t:Tutorial");
                if (guids.Length > 0)
                {
                    var tutorial = AssetDatabase.LoadAssetAtPath <Tutorial>(AssetDatabase.GUIDToAssetPath(guids[0]));
                    m_CurrentTutorial = tutorial;
                }
            }
            this.titleContent.text = "Tutorials";

            m_AuthoringMode = ProjectMode.IsAuthoringMode();

            GUIViewProxy.positionChanged    += OnGUIViewPositionChanged;
            HostViewProxy.actualViewChanged += OnHostViewActualViewChanged;
            Tutorial.tutorialPagesChanged   += OnTutorialPagesChanged;
            // test for page completion state changes (rather than criteria completion/invalidation directly) so that page completion state will be up-to-date
            TutorialPage.criteriaCompletionStateTested         += OnTutorialPageCriteriaCompletionStateTested;
            TutorialPage.tutorialPageMaskingSettingsChanged    += OnTutorialPageMaskingSettingsChanged;
            TutorialPage.tutorialPageNonMaskingSettingsChanged += OnTutorialPageNonMaskingSettingsChanged;
            EditorApplication.playModeStateChanged             -= TrackPlayModeChanging;
            EditorApplication.playModeStateChanged             += TrackPlayModeChanging;

            SetUpTutorial();

            ApplyMaskingSettings(true);
        }
コード例 #2
0
        void StartTutorialImmediateEditMode()
        {
            if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                return;
            }

            // Prevent Game view flashing briefly when starting tutorial.
            EditorWindow.GetWindow <SceneView>().Focus();

            SaveOriginalScenes();
            SaveOriginalWindowLayout();
            SaveSceneViewState();

            m_Tutorial.LoadWindowLayout();

            // Ensure TutorialWindow is open and set the current tutorial
            var tutorialWindow = EditorWindow.GetWindow <TutorialWindow>();

            tutorialWindow.SetTutorial(m_Tutorial, false);

            m_Tutorial.ResetProgress();

            // Do not overwrite workspace in authoring mode, use version control instead.
            if (!ProjectMode.IsAuthoringMode())
            {
                LoadTutorialDefaultsIntoAssetsFolder();
            }
        }
コード例 #3
0
        void StartTutorialInEditMode()
        {
            // TODO HACK double delay to resolve various issue (e.g. black screen during save modifications dialog
            // Revisit and fix properly.
            EditorApplication.delayCall += delegate
            {
                EditorApplication.delayCall += delegate
                {
                    if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                    {
                        return;
                    }

                    // TODO document why this is done
                    EditorWindow.GetWindow <SceneView>().Focus();

                    SaveOriginalScenes();
                    SaveOriginalWindowLayout();

                    m_Tutorial.LoadWindowLayout();

                    // Ensure TutorialWindow is open and set the current tutorial
                    var tutorialWindow = EditorWindow.GetWindow <TutorialWindow>();
                    tutorialWindow.SetTutorial(m_Tutorial);

                    m_Tutorial.ResetProgress();

                    // Do not overwrite workspace in authoring mode, use version control instead.
                    if (!ProjectMode.IsAuthoringMode())
                    {
                        LoadTutorialDefaultsIntoAssetsFolder();
                    }
                };
            };
        }
コード例 #4
0
        void OnEnable()
        {
            window         = this;
            window.minSize = new Vector2(300f, 380f);
            if (m_CurrentTutorial == null)
            {
                m_CurrentTutorial = TutorialProjectSettings.instance.startupTutorial;
            }
            this.titleContent.text = "Tutorials";

            m_AuthoringMode = ProjectMode.IsAuthoringMode();

            m_VideoPlaybackManager.OnEnable();

            GUIViewProxy.positionChanged    += OnGUIViewPositionChanged;
            HostViewProxy.actualViewChanged += OnHostViewActualViewChanged;
            Tutorial.tutorialPagesChanged   += OnTutorialPagesChanged;
            // test for page completion state changes (rather than criteria completion/invalidation directly) so that page completion state will be up-to-date
            TutorialPage.criteriaCompletionStateTested         += OnTutorialPageCriteriaCompletionStateTested;
            TutorialPage.tutorialPageMaskingSettingsChanged    += OnTutorialPageMaskingSettingsChanged;
            TutorialPage.tutorialPageNonMaskingSettingsChanged += OnTutorialPageNonMaskingSettingsChanged;
            EditorApplication.playModeStateChanged             -= TrackPlayModeChanging;
            EditorApplication.playModeStateChanged             += TrackPlayModeChanging;

            SetUpTutorial();

            ApplyMaskingSettings(true);
        }
コード例 #5
0
 void Update()
 {
     // Force repaint so that changes to WelcomePage can be previed immediately.
     if (ProjectMode.IsAuthoringMode())
     {
         Repaint();
     }
 }
コード例 #6
0
 private static void LogWarningOnlyInAuthoringMode(string message)
 {
     // We don't want to spam users with warning messages
     // but we want to catch them while creating tutorials
     if (ProjectMode.IsAuthoringMode())
     {
         Debug.LogWarning(message);
     }
 }
コード例 #7
0
        public void ReloadTutorial()
        {
            LoadWindowLayout();
            ResetProgress();

            // Do not overwrite workspace in authoring mode, use version control instead.
            if (!ProjectMode.IsAuthoringMode())
            {
                LoadTutorialDefaultsIntoAssetsFolder();
            }
        }
コード例 #8
0
 public void OnAfterDeserialize()
 {
     // Remove "-testable" suffix from assembly names
     if (!ProjectMode.IsAuthoringMode() && m_TypeName != null)
     {
         m_TypeName = m_TypeName.Replace("Assembly-CSharp-Editor-firstpass-testable", "Assembly-CSharp-Editor-firstpass");
         m_TypeName = m_TypeName.Replace("Assembly-CSharp-Editor-testable", "Assembly-CSharp-Editor");
         m_TypeName = m_TypeName.Replace("Assembly-CSharp-firstpass-testable", "Assembly-CSharp-firstpass");
         m_TypeName = m_TypeName.Replace("Assembly-CSharp-testable", "Assembly-CSharp");
     }
 }
コード例 #9
0
        void ResetTutorialInEditMode()
        {
            if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                return;
            }

            m_Tutorial.LoadWindowLayout();
            m_Tutorial.ResetProgress();

            // Do not overwrite workspace in authoring mode, use version control instead.
            if (!ProjectMode.IsAuthoringMode())
            {
                LoadTutorialDefaultsIntoAssetsFolder();
            }
        }
コード例 #10
0
        static UserStartupCode()
        {
            if (ProjectMode.IsAuthoringMode())
            {
                return;
            }
            if (IsDontRunInitCodeMarkerSet())
            {
                return;
            }
            if (IsInitilized())
            {
                return;
            }

            EditorApplication.update += InitRunStartupCode;
        }
コード例 #11
0
        static UserStartupCode()
        {
            if (ProjectMode.IsAuthoringMode())
            {
                return;
            }
            if (IsDontRunInitCodeMarkerSet())
            {
                return;
            }
            if (IsInitilized())
            {
                return;
            }

            //we delay the call because (i think) all tutorial assets are not loaded yet
            EditorApplication.update += InitRunStartupCode;
        }
コード例 #12
0
        void StartTutorialInEditMode()
        {
            if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
            {
                return;
            }

            // Postpone start of tutorial until window is closed
            var tutorialWindow = GetTutorialWindow();

            if (tutorialWindow != null)
            {
                tutorialWindow.Close();
                AfterWindowClosed += StartTutorialInEditMode;
                return;
            }

            AfterWindowClosed -= StartTutorialInEditMode;

            SaveOriginalScenes();
            SaveOriginalWindowLayout();

            m_Tutorial.LoadWindowLayout();

            // Ensure TutorialWindow is open and set the current tutorial
            tutorialWindow = EditorWindow.GetWindow <TutorialWindow>();
            tutorialWindow.SetTutorial(m_Tutorial);

            m_Tutorial.ResetProgress();

            // Do not overwrite workspace in authoring mode, use version control instead.
            if (!ProjectMode.IsAuthoringMode())
            {
                LoadTutorialDefaultsIntoAssetsFolder();
            }
        }
コード例 #13
0
ファイル: TutorialWindow.cs プロジェクト: Draz96/possessione
        private void ApplyMaskingSettings(bool applyMask)
        {
            MaskingManager.Unmask();

            if (!applyMask || !maskingEnabled || m_CurrentTutorial == null || m_CurrentTutorial.currentPage == null || IsParentNull())
            {
                InternalEditorUtility.RepaintAllViews();
                return;
            }

            var maskingSettings = m_CurrentTutorial.currentPage.currentMaskingSettings;

            try
            {
                if (maskingSettings != null && maskingSettings.enabled)
                {
                    var unmaskedViews = UnmaskedView.GetViewsAndRects(maskingSettings.unmaskedViews);

                    if (m_CurrentTutorial.currentPageIndex <= m_FarthestPageCompleted)
                    {
                        unmaskedViews = new UnmaskedView.MaskData();
                    }

                    UnmaskedView.MaskData highlightedViews;

                    // if the current page contains no instructions, assume unmasked views should be highlighted because they are called out in narrative text
                    if (unmaskedViews.Count > 0 && !m_CurrentTutorial.currentPage.paragraphs.Any(p => p.type == ParagraphType.Instruction))
                    {
                        highlightedViews = (UnmaskedView.MaskData)unmaskedViews.Clone();
                    }
                    // otherwise, if the current page is completed, highlight this window
                    else if (canMoveToNextPage)
                    {
                        highlightedViews = new UnmaskedView.MaskData();
                        highlightedViews.AddParent(this);
                    }
                    // otherwise, highlight manually specified control rects if there are any
                    else
                    {
                        var unmaskedControls = new List <GUIControlSelector>();
                        var unmaskedViewsWithControlsSpecified =
                            maskingSettings.unmaskedViews.Where(v => v.GetUnmaskedControls(unmaskedControls) > 0).ToArray();
                        // if there are no manually specified control rects, highlight all unmasked views
                        highlightedViews = UnmaskedView.GetViewsAndRects(
                            unmaskedViewsWithControlsSpecified.Length == 0 ?
                            maskingSettings.unmaskedViews : unmaskedViewsWithControlsSpecified
                            );
                    }

                    // ensure tutorial window's HostView and tooltips are not masked
                    unmaskedViews.AddParent(this);
                    unmaskedViews.AddTooltipViews();

                    // tooltip views should not be highlighted
                    highlightedViews.RemoveTooltipViews();

                    MaskingManager.Mask(
                        unmaskedViews,
                        m_Styles == null ? Color.magenta * new Color(1f, 1f, 1f, 0.8f) : m_Styles.maskingColor,
                        highlightedViews,
                        m_Styles == null ? Color.cyan * new Color(1f, 1f, 1f, 0.8f) : m_Styles.highlightColor,
                        m_Styles == null ? 3f : m_Styles.highlightThickness
                        );
                }
            }
            catch (ArgumentException e)
            {
                if (ProjectMode.IsAuthoringMode())
                {
                    Debug.LogException(e, m_CurrentTutorial.currentPage);
                }
                else
                {
                    Console.WriteLine(StackTraceUtility.ExtractStringFromException(e));
                }
            }
            finally
            {
                InternalEditorUtility.RepaintAllViews();
            }
        }
コード例 #14
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;
        }