/// <summary> /// Sets the physical dimensions of the sprite in the XY plane to be used when clipped. We need separate sizes because /// the sprite should still have the same height/width for measuring even though it is clipped by another view. /// Note: setting this DOES NOT automatically set the sprite as clipped. Size should be set after uvFrameClipped! /// </summary> public void setClippedSize(float width, float height, UIClippingPlane clippingPlane) { _clippedWidth = width; _clippedHeight = height; switch (clippingPlane) { case UIClippingPlane.Left: { _clippedLeftXOffset = _width - _clippedWidth; break; } case UIClippingPlane.Right: { _clippedLeftXOffset = 0; break; } case UIClippingPlane.Top: { _clippedTopYOffset = _height - _clippedHeight; break; } case UIClippingPlane.Bottom: { _clippedTopYOffset = 0; break; } } updateVertPositions(); updateTransform(); }
private int _originalWidth; // used internally for clipping #endregion Fields #region Constructors /// <summary> /// Automatically converts coordinates to UV space as specified by textureSize /// </summary> public UIUVRect( int x, int y, int width, int height, Vector2 textureSize ) { _originalCoordinates.x = x; _originalCoordinates.y = y; _originalWidth = width; lowerLeftUV = new Vector2( x / textureSize.x, 1.0f - ( ( y + height ) / textureSize.y ) ); uvDimensions = new Vector2( width / textureSize.x, height / textureSize.y ); clippingPlane = UIClippingPlane.None; }
/// <summary> /// Automatically converts coordinates to UV space as specified by textureSize /// </summary> public UIUVRect(int x, int y, int width, int height, Vector2 textureSize) { _originalCoordinates.x = x; _originalCoordinates.y = y; _originalWidth = width; lowerLeftUV = new Vector2(x / textureSize.x, 1.0f - ((y + height) / textureSize.y)); uvDimensions = new Vector2(width / textureSize.x, height / textureSize.y); clippingPlane = UIClippingPlane.None; }
/// <summary> /// Automatically converts coordinates to UV space as specified by textureSize /// </summary> public UIUVRect(int x, int y, int width, int height, Vector2 textureSize) { //Hack: Steve edit: added the 0.5 to the line (didn't have it originally) //Gabo edit: changed Steve's 0.5 to 0.1 because it was blowing up on me, now works universally. _originalCoordinates.x = x + 0.01f; _originalCoordinates.y = y + 0.01f; _originalWidth = width; //Hack: Steve edit: commented out line and added one below to replace it. //lowerLeftUV = new Vector2( x / textureSize.x, 1.0f - ( ( y + height ) / textureSize.y ) ); lowerLeftUV = new Vector2(_originalCoordinates.x / textureSize.x, 1.0f - ((_originalCoordinates.y + height) / textureSize.y)); uvDimensions = new Vector2(width / textureSize.x, height / textureSize.y); clippingPlane = UIClippingPlane.None; }
private int _originalWidth; // used internally for clipping #endregion Fields #region Constructors /// <summary> /// Automatically converts coordinates to UV space as specified by textureSize /// </summary> public UIUVRect( int x, int y, int width, int height, Vector2 textureSize ) { //Hack: Steve edit: added the 0.5 to the line (didn't have it originally) //Gabo edit: changed Steve's 0.5 to 0.1 because it was blowing up on me, now works universally. _originalCoordinates.x = x + 0.01f; _originalCoordinates.y = y + 0.01f; _originalWidth = width; //Hack: Steve edit: commented out line and added one below to replace it. //lowerLeftUV = new Vector2( x / textureSize.x, 1.0f - ( ( y + height ) / textureSize.y ) ); lowerLeftUV = new Vector2(_originalCoordinates.x / textureSize.x, 1.0f - ((_originalCoordinates.y + height) / textureSize.y)); uvDimensions = new Vector2( width / textureSize.x, height / textureSize.y ); clippingPlane = UIClippingPlane.None; }
public UIUVRect rectClippedToBounds(float width, float height, UIClippingPlane clippingPlane, Vector2 textureSize) { var uv = this; uv.clippingPlane = clippingPlane; // if we are clipping the top or right, only the uvDimensions need adjusting switch (clippingPlane) { case UIClippingPlane.Left: { var widthDifference = _originalWidth - width; uv.lowerLeftUV = new Vector2(((_originalCoordinates.x + widthDifference) / textureSize.x), 1.0f - ((_originalCoordinates.y + height) / textureSize.y)); uv.uvDimensions = new Vector2(width / textureSize.x, height / textureSize.y); break; } case UIClippingPlane.Right: { uv.lowerLeftUV = new Vector2(_originalCoordinates.x / textureSize.x, 1.0f - ((_originalCoordinates.y + height) / textureSize.y)); uv.uvDimensions = new Vector2(width / textureSize.x, height / textureSize.y); break; } case UIClippingPlane.Top: { uv.uvDimensions = new Vector2(width / textureSize.x, height / textureSize.y); break; } case UIClippingPlane.Bottom: { uv.lowerLeftUV = new Vector2(_originalCoordinates.x / textureSize.x, 1.0f - ((_originalCoordinates.y + height) / textureSize.y)); uv.uvDimensions = new Vector2(width / textureSize.x, height / textureSize.y); break; } } return(uv); }
public UIUVRect rectClippedToBounds( float width, float height, UIClippingPlane clippingPlane, Vector2 textureSize ) { var uv = this; uv.clippingPlane = clippingPlane; // if we are clipping the top or right, only the uvDimensions need adjusting switch( clippingPlane ) { case UIClippingPlane.Left: { var widthDifference = _originalWidth - width; uv.lowerLeftUV = new Vector2( ( ( _originalCoordinates.x + widthDifference ) / textureSize.x ), 1.0f - ( ( _originalCoordinates.y + height ) / textureSize.y ) ); uv.uvDimensions = new Vector2( width / textureSize.x, height / textureSize.y ); break; } case UIClippingPlane.Right: { uv.lowerLeftUV = new Vector2( _originalCoordinates.x / textureSize.x, 1.0f - ( ( _originalCoordinates.y + height ) / textureSize.y ) ); uv.uvDimensions = new Vector2( width / textureSize.x, height / textureSize.y ); break; } case UIClippingPlane.Top: { uv.uvDimensions = new Vector2( width / textureSize.x, height / textureSize.y ); break; } case UIClippingPlane.Bottom: { uv.lowerLeftUV = new Vector2( _originalCoordinates.x / textureSize.x, 1.0f - ( ( _originalCoordinates.y + height ) / textureSize.y ) ); uv.uvDimensions = new Vector2( width / textureSize.x, height / textureSize.y ); break; } } return uv; }
/// <summary> /// Sets the physical dimensions of the sprite in the XY plane to be used when clipped. We need separate sizes because /// the sprite should still have the same height/width for measuring even though it is clipped by another view. /// Note: setting this DOES NOT automatically set the sprite as clipped. Size should be set after uvFrameClipped! /// </summary> public void setClippedSize( float width, float height, UIClippingPlane clippingPlane ) { _clippedWidth = width; _clippedHeight = height; switch( clippingPlane ) { case UIClippingPlane.Left: { _clippedLeftXOffset = _width - _clippedWidth; break; } case UIClippingPlane.Right: { _clippedLeftXOffset = 0; break; } case UIClippingPlane.Top: { _clippedTopYOffset = _height - _clippedHeight; break; } case UIClippingPlane.Bottom: { _clippedTopYOffset = 0; break; } } updateVertPositions(); updateTransform(); }