GetTextureWidth() публичный статический Метод

public static GetTextureWidth ( int textureID ) : int
textureID int
Результат int
Пример #1
0
    public void Update()
    {
        if (_texture == null)
        {
            _texture            = new Texture2D(1, 1, TextureFormat.Alpha8, false);
            _texture.hideFlags  = HideFlags.HideInInspector | HideFlags.DontSave;
            _texture.filterMode = FilterMode.Point;
            _texture.wrapMode   = TextureWrapMode.Clamp;
            //Debug.Log("Texture2D creation: " + _texture.GetNativeTextureID());
        }

        int textureID = _texture.GetNativeTextureID();

        SysFont.QueueTexture(_text, FontName, _fontSize, _isBold,
                             _isItalic, _alignment, _isMultiLine, _maxWidthPixels,
                             _maxHeightPixels, textureID);

        _textWidthPixels  = SysFont.GetTextWidth(textureID);
        _textHeightPixels = SysFont.GetTextHeight(textureID);
        _widthPixels      = SysFont.GetTextureWidth(textureID);
        _heightPixels     = SysFont.GetTextureHeight(textureID);

        SysFont.UpdateQueuedTexture(textureID);

        _lastText            = _text;
        _lastFontName        = FontName;
        _lastFontSize        = _fontSize;
        _lastIsBold          = _isBold;
        _lastIsItalic        = _isItalic;
        _lastAlignment       = _alignment;
        _lastIsMultiLine     = _isMultiLine;
        _lastMaxWidthPixels  = _maxWidthPixels;
        _lastMaxHeightPixels = _maxHeightPixels;
    }
    public bool Update()
    {
        if (_texture == null)
        {
            _texture            = new Texture2D(1, 1, TextureFormat.Alpha8, false);
            _texture.hideFlags  = HideFlags.HideInInspector | HideFlags.DontSave;
            _texture.filterMode = FilterMode.Point;
            _texture.wrapMode   = TextureWrapMode.Clamp;
            _texture.Apply(false, true);
            _textureId = 0;
        }

        if (_textureId == 0)
        {
            _textureId = _texture.GetNativeTextureID();

            if (_textureId == 0)
            {
                // texture not ready, it may happen on multi-threaded rendering
                return(false);
            }

            //Debug.Log("Texture2D creation: " + _textureId);
        }

        SysFont.QueueTexture(_text, FontName, _fontSize, _isBold,
                             _isItalic, _alignment, _isMultiLine, _maxWidthPixels,
                             _maxHeightPixels, _textureId);

        _textWidthPixels  = SysFont.GetTextWidth(_textureId);
        _textHeightPixels = SysFont.GetTextHeight(_textureId);
        _widthPixels      = SysFont.GetTextureWidth(_textureId);
        _heightPixels     = SysFont.GetTextureHeight(_textureId);

        SysFont.UpdateQueuedTexture(_textureId);

        _lastText            = _text;
        _lastFontName        = FontName;
        _lastFontSize        = _fontSize;
        _lastIsBold          = _isBold;
        _lastIsItalic        = _isItalic;
        _lastAlignment       = _alignment;
        _lastIsMultiLine     = _isMultiLine;
        _lastMaxWidthPixels  = _maxWidthPixels;
        _lastMaxHeightPixels = _maxHeightPixels;
        _lastScaleSize       = _scaleSize;
        return(true);
    }