Skip to content

Commit

Permalink
Add new NTexture(sprite)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoguzhu committed Jan 21, 2019
1 parent 4d046bb commit 2c2c759
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Source/Scripts/Core/NTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public NTexture(Texture texture) : this(texture, null, 1, 1)
/// <param name="yScale"></param>
public NTexture(Texture texture, Texture alphaTexture, float xScale, float yScale)
{

_root = this;
_nativeTexture = texture;
_alphaTexture = alphaTexture;
Expand Down Expand Up @@ -176,6 +175,23 @@ public NTexture(NTexture root, Rect region, bool rotated, Vector2 originalSize,
_offset = offset;
}

/// <summary>
///
/// </summary>
/// <param name="sprite"></param>
public NTexture(Sprite sprite)
{
Rect rect = sprite.rect;
rect.y = sprite.texture.height - rect.yMax;

_root = this;
_nativeTexture = sprite.texture;
_region = rect;
_originalSize = new Vector2(_region.width, _region.height);
uvRect = new Rect(_region.x / _nativeTexture.width, 1 - _region.yMax / _nativeTexture.height,
_region.width / _nativeTexture.width, _region.height / _nativeTexture.height);
}

/// <summary>
///
/// </summary>
Expand Down

0 comments on commit 2c2c759

Please sign in to comment.