Exemplo n.º 1
0
    private void DrawSprite()
    {
        _innerFrameWidth  = _sprite.rect.width * _scale;
        _innerFrameHeight = _sprite.rect.height * _scale;

        _outerFrameWidth  = _innerFrameWidth + 2 * _frameMargin;
        _outerFrameHeight = _innerFrameHeight + 2 * _frameMargin;

        var rect = EditorGUILayout.GetControlRect(true, _outerFrameHeight);

        _x = rect.min.x;
        _y = rect.min.y;

        //draw the rect that fills the scroll:
        GUIExtensions.DrawRect(new Rect(_x, _y, _outerFrameWidth, _outerFrameHeight), _borderColor, ref _rectTexture);

        //draw the background colour of each frame:
        _x += _frameMargin;
        _y += _frameMargin;
        GUIExtensions.DrawRect(new Rect(_x, _y, _innerFrameWidth, _innerFrameHeight), _frameColor, ref _rectTexture);

        //draw the sprite
        Texture texture       = _sprite.texture;
        Rect    textureRect   = _sprite.textureRect;
        var     textureCoords = new Rect(textureRect.x / texture.width, textureRect.y / texture.height,
                                         textureRect.width / texture.width, textureRect.height / texture.height);
        var positionRect = new Rect(_x, _y, _innerFrameWidth, _innerFrameHeight);

        GUI.DrawTextureWithTexCoords(positionRect, texture, textureCoords);
    }
Exemplo n.º 2
0
        protected override void DrawElementInternal(int draw_id, Rect view)
        {
            Rect rect = GetElementRect();

            GUIExtensions.DrawRect(
                rect.GetHeightedAnchorCenter(1.0f).GetShrunk(rect.width * 0.125f, 0.0f),
                Color.gray
                );
        }
Exemplo n.º 3
0
    private void DrawPixel(float x, float y, Color color, bool invertY = true)
    {
        bool intergerPosition = (x == Math.Floor(x) && y == Math.Floor(y));

        x = _x + x * _scale;
        if (invertY)
        {
            y = _sprite.rect.height - 1 - y;
        }
        y = _y + y * _scale;
        GUIExtensions.DrawRect(new Rect(x, y, _scale, _scale), intergerPosition ? color : _misplacedPivotColor, ref _rectTexture);
    }