Example #1
0
        /// <summary>
        /// Set graphics colors.
        /// </summary>
        /// <param name="foregroundColor">Foreground color.</param>
        /// <param name="backgroundColor">Background color.</param>
        /// <param name="fadeDuration">Fade duration.</param>
        public virtual void GraphicsColoring(Color foregroundColor, Color backgroundColor, float fadeDuration = 0.0f)
        {
            // reset default color to white, otherwise it will look darker than specified color,
            // because actual color = Text.color * Text.CrossFadeColor
            if (!GraphicsColorSetted)
            {
                GraphicsForeground.ForEach(GraphicsReset);
                GraphicsBackground.ForEach(GraphicsReset);
            }

            // change color instantly for first time
            foreach (var gf in GraphicsForeground)
            {
                if (gf != null)
                {
                    gf.CrossFadeColor(foregroundColor, GraphicsColorSetted ? fadeDuration : 0f, true, true);
                }
            }

            foreach (var gb in GraphicsBackground)
            {
                if (gb != null)
                {
                    gb.CrossFadeColor(backgroundColor, GraphicsColorSetted ? fadeDuration : 0f, true, true);
                }
            }

            GraphicsColorSetted = true;
        }
Example #2
0
        /// <summary>
        /// Reset graphics.
        /// </summary>
        protected virtual void ResetGraphics()
        {
#if UNITY_EDITOR
            var is_playmode = UnityEditor.EditorApplication.isPlaying;
#else
            var is_playmode = true;
#endif

            if (is_playmode)
            {
                GraphicsForeground.ForEach(GraphicsReset);
                GraphicsBackground.ForEach(GraphicsReset);
            }
        }