예제 #1
0
            static Fonts()
            {
                FONTS = new Dictionary <string, TMP_FontAsset>(16);
                // List out all fonts shipped with the game
                foreach (var newFont in Resources.FindObjectsOfTypeAll <TMP_FontAsset>())
                {
                    string name = newFont?.name;
                    if (!string.IsNullOrEmpty(name) && !FONTS.ContainsKey(name))
                    {
                        FONTS.Add(name, newFont);
                    }
                }

                // Initialization: UI fonts
                if ((DefaultTextFont = GetFontByName(DEFAULT_FONT_TEXT)) == null)
                {
                    PUIUtils.LogUIWarning("Unable to find font " + DEFAULT_FONT_TEXT);
                }
                if ((DefaultUIFont = GetFontByName(DEFAULT_FONT_UI)) == null)
                {
                    PUIUtils.LogUIWarning("Unable to find font " + DEFAULT_FONT_UI);
                }

                // Initialization: Text style
                DefaultSize   = 14;
                TextDarkStyle = ScriptableObject.CreateInstance <TextStyleSetting>();
                TextDarkStyle.enableWordWrapping = false;
                TextDarkStyle.fontSize           = DefaultSize;
                TextDarkStyle.sdfFont            = Text;
                TextDarkStyle.style            = FontStyles.Normal;
                TextDarkStyle.textColor        = Colors.UITextDark;
                TextLightStyle                 = TextDarkStyle.DeriveStyle(newColor: Colors.UITextLight);
                UIDarkStyle                    = ScriptableObject.CreateInstance <TextStyleSetting>();
                UIDarkStyle.enableWordWrapping = false;
                UIDarkStyle.fontSize           = DefaultSize;
                UIDarkStyle.sdfFont            = UI;
                UIDarkStyle.style              = FontStyles.Normal;
                UIDarkStyle.textColor          = Colors.UITextDark;
                UILightStyle                   = UIDarkStyle.DeriveStyle(newColor: Colors.UITextLight);
            }
예제 #2
0
        /// <summary>
        /// Returns a suitable parent object for a dialog.
        /// </summary>
        /// <returns>A game object that can be used as a dialog parent depending on the game
        /// stage, or null if none is available.</returns>
        public static GameObject GetParentObject()
        {
            GameObject parent = null;
            var        fi     = FrontEndManager.Instance;

            if (fi != null)
            {
                parent = fi.gameObject;
            }
            else
            {
                // Grr unity
                var gi = GameScreenManager.Instance;
                if (gi != null)
                {
                    parent = gi.ssOverlayCanvas;
                }
                else
                {
                    PUIUtils.LogUIWarning("No dialog parent found!");
                }
            }
            return(parent);
        }