コード例 #1
0
        public override void OnInspectorGUI()
        {
            if (GUILayout.Button(Localization.Tr(MenuItems.ShowTutorials)))
            {
                // Make sure we will display 'this' container in the window.
                var window = Target.ProjectLayout != null
                    ? TutorialWindow.CreateWindowAndLoadLayout(Target)
                    : TutorialWindow.CreateNextToInspector();

                window.ActiveContainer = Target;
            }

            if (k_IsAuthoringMode)
            {
                EditorGUILayout.Space(10);
                DrawPropertiesExcluding(serializedObject, k_PropertiesToHide);
                serializedObject.ApplyModifiedProperties();
            }
        }
コード例 #2
0
        /// <summary>
        /// Shows Tutorials window using the currently specified behaviour.
        /// </summary>
        /// <remarks>
        /// Different behaviors:
        /// 1. If a single TutorialContainer asset that has TutorialContainer.ProjectLayout specified exists,
        ///    the window is loaded and shown using the specified project window layout (old behaviour).
        ///    If the project layout does not contain Tutorials window, the window is shown an as free-floating window.
        /// 2. If no TutorialContainer assets exist, or TutorialContainer.ProjectLayout is not specified, the window is shown
        ///     by anchoring and docking it next to the Inspector (new behaviour). If the Inspector is not available,
        ///     the window is shown an as free-floating window.
        /// 3. If there is more than one TutorialContainer asset with different Project Layout setting in the project,
        ///    one asset is chosen randomly to specify the behavior.
        /// 4. If Tutorials window is already created, it is simply brought to the foreground and focused.
        /// </remarks>
        /// <returns>The the created, or aleady existing, window instance.</returns>
        public static TutorialWindow ShowTutorialWindow()
        {
            var containers       = TutorialEditorUtils.FindAssets <TutorialContainer>();
            var defaultContainer = containers.FirstOrDefault();
            var projectLayout    = defaultContainer?.ProjectLayout;

            if (containers.Any(container => container.ProjectLayout != projectLayout))
            {
                Debug.LogWarningFormat(
                    "There is more than one TutorialContainers asset with different Project Layout setting in the project. " +
                    "Using asset at path {0} for the window behavior settings.",
                    AssetDatabase.GetAssetPath(defaultContainer)
                    );
            }

            TutorialWindow window = null;

            if (!containers.Any() || defaultContainer.ProjectLayout == null)
            {
                window = TutorialWindow.CreateNextToInspector();
            }
            else if (defaultContainer.ProjectLayout != null)
            {
                window = TutorialWindow.CreateWindowAndLoadLayout(defaultContainer);
            }

            window.SetContainers(containers);

            // If we have only one tutorial container, we set it active immediately
            if (containers.Count() == 1)
            {
                window.ActiveContainer = defaultContainer;
            }

            return(window);
        }