Exemplo n.º 1
0
        public void CrossFadeStyle(RectStyle newStyle, float duration, EasingType easing = EasingType.Linear)
        {
            if (_oldStyle == null)
            {
                _oldStyle = ScriptableObject.CreateInstance <RectStyle>();
            }

            if (style != null)
            {
                _oldStyle.CopyFrom(style);
            }

            style = newStyle;

            if (duration <= 0f)
            {
                _crossFading = false;
                return;
            }

            _crossFading       = true;
            _crossFadeProgress = 0f;
            _crossFadeSpeed    = 1f / duration;
            _crossFadeEasing   = easing;
        }
Exemplo n.º 2
0
        protected override void UpdateMaterial()
        {
            if (_styleForRendering == null)
            {
                _styleForRendering = ScriptableObject.CreateInstance <RectStyle>();
            }

            if (_crossFading && _oldStyle != null && style != null)
            {
                _styleForRendering.CopyFromLerped(_oldStyle, style, Ease(_crossFadeProgress, _crossFadeEasing));
            }
            else if (style != null)
            {
                _styleForRendering.CopyFrom(style);
            }

            var mat = materialForRendering;

            _styleForRendering.UpdateMaterial(mat, transform.rect.size);

            base.UpdateMaterial();
        }