public override void OnInspectorGUI()
        {
            if (!string.IsNullOrEmpty(m_WarningMessage))
            {
                EditorGUILayout.HelpBox(m_WarningMessage, MessageType.Warning);
            }

            EditorGUI.BeginChangeCheck();

            s_ForceOldInspector = EditorGUILayout.Toggle(Localization.Tr("Force default inspector"), s_ForceOldInspector);
            EditorGUILayout.Space(10);
            if (s_ForceOldInspector)
            {
                base.OnInspectorGUI();
            }
            else
            {
                DrawSimplifiedInspector();
            }

            if (EditorGUI.EndChangeCheck())
            {
                TutorialWindow.GetWindow().ForceInititalizeTutorialAndPage();
            }
        }
        internal static void RunStartupCode()
        {
            var projectSettings = TutorialProjectSettings.instance;

            if (projectSettings.initialScene != null)
            {
                EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(projectSettings.initialScene));
            }

            TutorialManager.WriteAssetsToTutorialDefaultsFolder();

            // Ensure Editor is in predictable state
            EditorPrefs.SetString("ComponentSearchString", string.Empty);
            Tools.current = Tool.Move;

            var readme = TutorialWindow.FindReadme();

            if (readme != null)
            {
                ShowTutorialWindow();
            }

            // NOTE camera settings can be applied successfully only after potential layout changes
            if (projectSettings.InitialCameraSettings != null && projectSettings.InitialCameraSettings.enabled)
            {
                projectSettings.InitialCameraSettings.Apply();
            }

            if (projectSettings.WelcomePage)
            {
                TutorialModalWindow.TryToShow(projectSettings.WelcomePage, () => {});
            }
        }
Beispiel #3
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);
        }
Beispiel #4
0
        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);
        }
        internal static void RunStartupCode()
        {
            var projectSettings = TutorialProjectSettings.instance;

            if (projectSettings.initialScene != null)
            {
                EditorSceneManager.OpenScene(AssetDatabase.GetAssetPath(projectSettings.initialScene));
            }

            TutorialManager.WriteAssetsToTutorialDefaultsFolder();

            if (projectSettings.startupTutorial != null)
            {
                TutorialManager.instance.StartTutorial(projectSettings.startupTutorial);
            }

            // Ensure Editor is in predictable state
            EditorPrefs.SetString("ComponentSearchString", string.Empty);
            Tools.current = Tool.Move;

            // Replace LastProjectPaths in window layouts used in tutorials so that e.g.
            // pre-saved Project window states work correctly.
            var readme = TutorialWindow.FindReadme();

            if (readme)
            {
                WindowLayoutProxy.ReplaceLastProjectPathWithCurrentProjectPath(readme.projectLayoutPath);
            }

            AssetDatabase.FindAssets($"t:{typeof(Tutorial).FullName}")
            .Select(guid =>
                    AssetDatabase.LoadAssetAtPath <Tutorial>(AssetDatabase.GUIDToAssetPath(guid)).windowLayoutPath
                    )
            .Distinct()
            .ToList()
            .ForEach(layoutPath =>
            {
                WindowLayoutProxy.ReplaceLastProjectPathWithCurrentProjectPath(layoutPath);
            });

            if (readme != null)
            {
                readme.LoadTutorialProjectLayout();
            }

            var welcomePage = FindWelcomePage();

            if (welcomePage != null)
            {
                TutorialModalWindow.TryToShow("Welcome", welcomePage, () => { });
            }

            var wnd = TutorialManager.GetTutorialWindow();

            if (wnd)
            {
                wnd.showStartHereMarker = true;
            }
        }
Beispiel #6
0
 internal static TutorialWindow GetWindow()
 {
     if (instance == null)
     {
         instance = CreateWindowAndLoadLayout();
     }
     return(instance);
 }
Beispiel #7
0
 public static TutorialWindow GetWindow()
 {
     if (window == null)
     {
         window = GetWindow <TutorialWindow>();
     }
     return(window);
 }
Beispiel #8
0
        public void SetWindow(TutorialWindow window)
        {
            m_TutorialWindow = window;

            if (m_FadeGroupAnim == null)
            {
                m_FadeGroupAnim = new AnimBool(false);
            }
            m_FadeGroupAnim.valueChanged.AddListener(window.Repaint);
        }
Beispiel #9
0
        internal static TutorialWindow CreateWindowAndLoadLayout()
        {
            instance = CreateWindow();
            var readme = FindReadme();

            if (readme != null)
            {
                readme.LoadTutorialProjectLayout();
            }
            return(instance);
        }
Beispiel #10
0
        void LoadWindowLayout()
        {
            if (m_WindowLayout == null)
            {
                return;
            }

            var layoutPath = AssetDatabase.GetAssetPath(m_WindowLayout);

            TutorialWindow.LoadWindowLayoutAndSetUpTutorial(layoutPath, this);
        }
Beispiel #11
0
        public override void OnInspectorGUI()
        {
            if (GUILayout.Button(TutorialWindowMenuItem.Item))
            {
                TutorialWindow.CreateWindowAndLoadLayout();
            }

            if (k_IsAuthoringMode)
            {
                base.OnInspectorGUI();
            }
        }
        internal static void RunStartupCode()
        {
            // Put you init code here
            // It will only be executed for the end user
            var w = TutorialWindow.CreateWindow();

            w.ResetTutorialAndWriteDefaults();

            // Ensure Editor is in predictable state
            EditorPrefs.SetString("ComponentSearchString", string.Empty);
            Tools.current = Tool.Move;
        }
        /// <summary>
        /// Shows Tutorials window using the currently specified behaviour:
        /// - if TutorialContainer exists and TutorialContainer.ProjectLayout is specified,
        ///   the window is loaded and shown using the specified window layout (old behaviour), or
        /// - else the window is shown by anchoring and docking next to the Inspector (new behaviour).
        /// </summary>
        public static void ShowTutorialWindow()
        {
            var readme = TutorialWindow.FindReadme();

            if (readme == null || readme.ProjectLayout == null)
            {
                TutorialWindow.CreateNextToInspector();
            }
            else if (readme.ProjectLayout != null)
            {
                TutorialWindow.CreateWindowAndLoadLayout();
            }
        }
        public override void OnInspectorGUI()
        {
            if (!string.IsNullOrEmpty(m_WarningMessage))
            {
                EditorGUILayout.HelpBox(m_WarningMessage, MessageType.Warning);
            }

            EditorGUI.BeginChangeCheck();
            base.OnInspectorGUI();
            if (EditorGUI.EndChangeCheck())
            {
                TutorialWindow.GetWindow().ForceInititalizeTutorialAndPage();
            }
        }
Beispiel #15
0
 internal static TutorialWindow CreateWindow()
 {
     instance         = GetWindow <TutorialWindow>(k_WindowTitleContent.text);
     instance.minSize = new Vector2(k_MinWidth, k_MinHeight);
     return(instance);
 }
Beispiel #16
0
 static void OpenTutorialWindow()
 {
     TutorialWindow.CreateWindow();
 }
 static void OpenTutorialWindow()
 {
     TutorialWindow.CreateWindowAndLoadLayout();
 }
Beispiel #18
0
        void OnEnable()
        {
            rootVisualElement.Clear();
            currentEditorLanguage = EditorPrefs.GetInt("EditorLanguage");
            instance = this;

            Criterion.criterionCompleted += UpdateNextButton;

            IMGUIContainer imguiToolBar = new IMGUIContainer(OnGuiToolbar);
            IMGUIContainer videoBox     = new IMGUIContainer(RenderVideoIfPossible);

            videoBox.style.alignSelf = new StyleEnum <Align>(Align.Center);
            videoBox.name            = "VideoBox";

            var           root                 = rootVisualElement;
            var           topBarAsset          = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>($"{UIAssetPath}/Main.uxml");
            var           tutorialContentAsset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>($"{UIAssetPath}/TutorialContents.uxml");
            VisualElement tutorialImage        = topBarAsset.CloneTree().Q("TutorialImage");
            VisualElement tutorialMenuCard     = topBarAsset.CloneTree().Q("CardContainer");

            VisualElement tutorialContents = tutorialContentAsset.CloneTree().Q("TutorialEmptyContents");

            tutorialContents.style.flexGrow = 1f;
            VisualElement TutorialContentPage = tutorialContentAsset.CloneTree().Q("TutorialPageContainer");
            VisualElement TutorialTopBar      = TutorialContentPage.Q("Header");

            VisualElement linkButton = topBarAsset.CloneTree().Q("LinkButton");

            VisualElement cardContainer = topBarAsset.CloneTree().Q("TutorialListScrollView");

            CreateTutorialMenuCards(topBarAsset, "CardContainer", "LinkCardContainer", cardContainer); //[TODO] be careful: this will also trigger analytics events even when you start a tutorial

            tutorialContents.Add(cardContainer);
            VisualElement topBarVisElement = topBarAsset.CloneTree().Q("TitleHeader");
            VisualElement footerBar        = topBarAsset.CloneTree().Q("TutorialActions");

            TextElement titleElement       = topBarVisElement.Q <TextElement>("TitleLabel");
            TextElement contextTextElement = topBarVisElement.Q <TextElement>("ContextLabel");

            UpdateTutorialHeader(contextTextElement, titleElement, topBarVisElement);

            root.Add(imguiToolBar);
            root.Add(TutorialTopBar);
            root.Add(videoBox);
            root.Add(topBarVisElement);
            root.Add(tutorialContents);

            StyleSheet rootstyle = AssetDatabase.LoadAssetAtPath <StyleSheet>($"{UIAssetPath}/Main.uss");

            root.styleSheets.Add(rootstyle);

            VisualElement tutorialContainer = TutorialContentPage.Q("TutorialContainer");

            tutorialContainer.Add(linkButton);
            root.Add(tutorialContainer);

            footerBar.Q <Button>("PreviousButton").clicked += OnPreviousButtonClicked;
            footerBar.Q <Button>("NextButton").clicked     += OnNextButtonClicked;

            // Set here in addition to CreateWindow() so that title of old saved layouts is overwritten.
            instance.titleContent = k_WindowTitleContent;

            videoPlaybackManager.OnEnable();

            GUIViewProxy.positionChanged    += OnGUIViewPositionChanged;
            HostViewProxy.actualViewChanged += OnHostViewActualViewChanged;
            Tutorial.tutorialPagesModified  += OnTutorialPagesModified;

            // 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();

            maskingEnabled = true;
            root.Add(footerBar);
            readme = FindReadme();
            EditorCoroutineUtility.StartCoroutineOwnerless(DelayedOnEnable());
        }
Beispiel #19
0
 public static TutorialWindow CreateWindow()
 {
     window         = GetWindow <TutorialWindow>();
     window.minSize = new Vector2(300f, 380f);
     return(window);
 }
 public void SetWindow(TutorialWindow window)
 {
     m_TutorialWindow = window;
 }