Ejemplo n.º 1
0
            public void Update(OptimizedFilledImage image)
            {
                switch (image.fillMethod)
                {
                case FillMethod.Horizontal:
                case FillMethod.Vertical:
                    break;

                default:
                    // NOT SUPPORT
                    return;
                }

                var size = image.rectTransform.sizeDelta;

                var fillBorderMin = 0f;
                var fillBorderMax = 0f;

                var offsetMin = image.offsetMin;
                var offsetMax = image.offsetMax;

                switch (image.fillMethod)
                {
                case FillMethod.Horizontal:
                    this.start    = offsetMin.x;
                    this.range    = size.x - (this.start + offsetMax.x);
                    fillBorderMin = image.borderMin.x / size.x;
                    fillBorderMax = image.borderMax.x / size.x;
                    break;

                case FillMethod.Vertical:
                    this.start    = offsetMin.y;
                    this.range    = size.y - (this.start + offsetMax.y);
                    fillBorderMin = image.borderMin.y / size.y;
                    fillBorderMax = image.borderMax.y / size.y;
                    break;
                }

                var fillAmount = image.FillAmount;

                this.ratio = Mathf.Lerp(fillBorderMin, 1 - fillBorderMax, fillAmount);

                if (image.pixelPerfect)
                {
                    var current = this.start + this.range * this.ratio;
                    this.ratio = 0 < this.range ? (Mathf.Floor(current) - this.start) / this.range : 0;
                }
            }
Ejemplo n.º 2
0
        protected override void OnEditorSetting()
        {
            base.OnEditorSetting();

            this.image = this.GetComponent <OptimizedFilledImage>();
        }