SetScale() public méthode

public SetScale ( float xv, float yv ) : void
xv float
yv float
Résultat void
 static public int SetScale(IntPtr l)
 {
     try {
         FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l);
         System.Single          a1;
         checkType(l, 2, out a1);
         System.Single a2;
         checkType(l, 3, out a2);
         self.SetScale(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #2
0
        private void UpdateLayout()
        {
            if (_activeObject == null)
            {
                if (_autoSize)
                {
                    _updatingLayout = true;
                    this.SetSize(50, 30);
                    _updatingLayout = false;
                }
                return;
            }

            _contentWidth  = _contentSourceWidth;
            _contentHeight = _contentSourceHeight;

            if (_autoSize)
            {
                _updatingLayout = true;
                if (_contentWidth == 0)
                {
                    _contentWidth = 50;
                }
                if (_contentHeight == 0)
                {
                    _contentHeight = 30;
                }
                this.SetSize(_contentWidth, _contentHeight);
                if (_activeObject is Image)
                {
                    ((Image)_activeObject).textureScale = Vector2.one;
                }
                else
                {
                    _activeObject.SetScale(1, 1);
                }
                _updatingLayout = false;
            }
            else
            {
                float sx = 1, sy = 1;
                if (_fill == FillType.Scale || _fill == FillType.ScaleFree)
                {
                    sx = this.width / _contentSourceWidth;
                    sy = this.height / _contentSourceHeight;

                    if (sx != 1 || sy != 1)
                    {
                        if (_fill == FillType.Scale)
                        {
                            if (sx > sy)
                            {
                                sx = sy;
                            }
                            else
                            {
                                sy = sx;
                            }
                        }
                        _contentWidth  = Mathf.FloorToInt(_contentSourceWidth * sx);
                        _contentHeight = Mathf.FloorToInt(_contentSourceHeight * sy);
                    }
                }

                if (_activeObject is Image)
                {
                    ((Image)_activeObject).textureScale = new Vector2(sx, sy);
                }
                else
                {
                    _activeObject.SetScale(sx, sy);
                }

                float nx;
                float ny;
                if (_align == AlignType.Center)
                {
                    nx = Mathf.FloorToInt((this.width - _contentWidth) / 2);
                }
                else if (_align == AlignType.Right)
                {
                    nx = Mathf.FloorToInt(this.width - _contentWidth);
                }
                else
                {
                    nx = 0;
                }
                if (_verticalAlign == VertAlignType.Middle)
                {
                    ny = Mathf.FloorToInt((this.height - _contentHeight) / 2);
                }
                else if (_verticalAlign == VertAlignType.Bottom)
                {
                    ny = Mathf.FloorToInt(this.height - _contentHeight);
                }
                else
                {
                    ny = 0;
                }
                _activeObject.SetXY(nx, ny);
            }
        }