private void ShowDecoratorsControls()
        {
            var decorators = _controller.Decorators;

            if (PlayerSettings.defaultInterfaceOrientation == UIOrientation.AutoRotation)
            {
                EditorGUI.BeginDisabledGroup(true);
            }

            UndoableInputFieldUtils.BoolFieldWithTooltip(() => decorators.ParallaxAutoRotation, v =>
            {
                decorators.ParallaxAutoRotation = v;

#if UNITY_EDITOR && UNITY_ANDROID
                if (PlayerSettings.defaultInterfaceOrientation == UIOrientation.AutoRotation && v)
                {
                    this.Warning(EnabledParallaxWarning);
                }
#endif
            }

                                                         , ParallaxFieldLabel, "Only accessible when Player Settings -> Android -> Resolution and presentation -> Default orientation is not AutoRotation", _controller.Settings);

            if (PlayerSettings.defaultInterfaceOrientation == UIOrientation.AutoRotation)
            {
                EditorGUI.EndDisabledGroup();
            }

            if (Application.isPlaying)
            {
                EditorGUI.BeginDisabledGroup(true);
            }

            UndoableInputFieldUtils.BoolFieldWithTooltip(() => decorators.AlphaBlending, v => decorators.AlphaBlending = v, AlphaBlendingLabel,
                                                         alphaBlendingTooltip,
                                                         _controller.Settings);

            if (Application.isPlaying)
            {
                EditorGUI.EndDisabledGroup();
            }

            // Edit > Project Settings > Player settings > Other > Scripting define symbols
#if LEIA_ADVANCED_USER
            // for ShowTiles param on LeiaDisplay decorator
            // setting does not persist between runs
            if (Application.isEditor && Application.isPlaying)
            {
                UndoableInputFieldUtils.BoolField(() => _controller.Decorators.ShowTiles, (bool b) =>
                {
                    decorators.ShowTiles = b;
                    _controller.IsDirty  = true;
                }, ShowTilesFieldLabel);
            }
#endif

            _controller.Decorators = decorators;
        }
Пример #2
0
        public void OnGUI()
        {
            if (window == null)
            {
                Init();
            }
            EditorWindowUtils.TitleTexture(_bannerImage);

            if (issueCount == 0)
            {
                EditorWindowUtils.Space(2);
                var style = new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Bold
                };
                EditorWindowUtils.Label("Fantastic! You're good to go!", style);
            }
            else
            {
                EditorWindowUtils.HelpBox("Recommended Unity Editor settings for LeiaLoft SDK:", MessageType.Warning);
            }

            scrollPosition = EditorWindowUtils.BeginScrollView(scrollPosition);
            EditorWindowUtils.Space(5);

            if (recommendations != null)
            {
                for (int i = 0; i < recommendations.Count; i++)
                {
                    recommendations[i].CheckRecommendation();
                }
            }
            EditorWindowUtils.EndScrollView();
            EditorWindowUtils.BeginHorizontal();

            UndoableInputFieldUtils.BoolFieldWithTooltip(() => { forceShow = EditorPrefs.GetBool(editor_Recommendation_ForcePopUp, false); return(forceShow); }, b => { forceShow = b; EditorPrefs.SetBool(editor_Recommendation_ForcePopUp, b); }, "  Automatically Pop-up", "Display this window when LeiaLoft detects unrecommended Unity Settings. Alternatively, this widow can be opened from LeiaLoft-> Recommended Unity Settings", window);

            if (ignoreCount > 0)
            {
                EditorWindowUtils.Button(() =>
                {
                    for (int i = 0; i < recommendations.Count; i++)
                    {
                        if (EditorPrefs.HasKey(recommendations[i].IgnoreKey))
                        {
                            EditorPrefs.DeleteKey(recommendations[i].IgnoreKey);
                            recommendations[i].IsIgnored = false;
                        }
                    }
                }, string.Format("Reset Ignores ({0})", ignoreCount));
            }
            EditorWindowUtils.EndHorizontal();
            EditorWindowUtils.Space(2);
        }
        /// <summary>
        /// User needs to be able to set DisplayConfig once and have setting persist through play/edit process.
        ///
        /// Dev needs to be able to retrieve DisplayConfig data without chaining through LeiaDisplay -> DeviceFactory -> OfflineEmulationLeiaDevice.
        /// These objects may be reconstructed and drop pointers on play, or some code which we want to be editor-only would have to be included in builds.
        /// </summary>
        void ShowDisplayConfigDropdown()
        {
            // build a path to subfolder where display config files are found
            string searchPath = Application.dataPath;

            foreach (string subfolder in new[] { "LeiaLoft", "Resources" })
            {
                searchPath = System.IO.Path.Combine(searchPath, subfolder);
            }

            string fileSearchString   = "DisplayConfiguration_";
            string fileTerminalString = ".json";

            // convert file paths into short names which can be displayed to user
            string[]      displayConfigPathMatches = System.IO.Directory.GetFiles(searchPath, fileSearchString + "*.json");
            List <string> displayConfigFilenames   = new List <string>();

            for (int i = 0; i < displayConfigPathMatches.Length; i++)
            {
                displayConfigFilenames.Add(System.IO.Path.GetFileName(displayConfigPathMatches[i]));
            }

            // write user-selection into editor prefs
            int ind = Mathf.Max(0, displayConfigFilenames.IndexOf(OfflineEmulationLeiaDevice.EmulatedDisplayConfigFilename));

            if (ind >= displayConfigFilenames.Count)
            {
                LogUtil.Log(LogLevel.Error, "No DisplayConfiguration files found in Assets/LeiaLoft/Resources! Please reinstall your LeiaLoft Unity SDK");
                return;
            }

            string[] trimmedDisplayConfigFilenameArray = displayConfigFilenames.Select(x => x.Replace(fileSearchString, "").Replace(fileTerminalString, "")).ToArray();

            // suppress DisplayConfig dropdown selection when build player window is open. This avoids a bug where selecting a new build target,
            // not switching platform, and then changing emulated device profile would cause Unity to throw a GUI error
            bool isBuildPlayerWindowOpen = IsWindowOpen <BuildPlayerWindow>();

            EditorGUI.BeginDisabledGroup(Application.isPlaying || isBuildPlayerWindowOpen);
            UndoableInputFieldUtils.PopupLabeled(
                (int i) =>
            {
                OfflineEmulationLeiaDevice.EmulatedDisplayConfigFilename = displayConfigFilenames[i];
            }, "Editor Emulated Device", ind, trimmedDisplayConfigFilenameArray);
            if (isBuildPlayerWindowOpen)
            {
                EditorGUILayout.LabelField("Close build player window before changing emulated device profile");
            }

            UndoableInputFieldUtils.BoolFieldWithTooltip(
                () =>
            {
                return(LeiaPreferenceUtil.GetUserPreferenceBool(true, OfflineEmulationLeiaDevice.updateGameViewResOnDisplayProfileChange, Application.dataPath));
            },
                (bool b) =>
            {
                LeiaPreferenceUtil.SetUserPreferenceBool(OfflineEmulationLeiaDevice.updateGameViewResOnDisplayProfileChange, b, Application.dataPath);
            },
                "Set game view resolution when Editor Emulated Device changes", "", null);
            EditorGUILayout.LabelField("");

            EditorGUI.EndDisabledGroup();
        }