Skip to content

Commit 2c2c759

Browse files
committed
Add new NTexture(sprite)
1 parent 4d046bb commit 2c2c759

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Source/Scripts/Core/NTexture.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ public NTexture(Texture texture) : this(texture, null, 1, 1)
109109
/// <param name="yScale"></param>
110110
public NTexture(Texture texture, Texture alphaTexture, float xScale, float yScale)
111111
{
112-
113112
_root = this;
114113
_nativeTexture = texture;
115114
_alphaTexture = alphaTexture;
@@ -176,6 +175,23 @@ public NTexture(NTexture root, Rect region, bool rotated, Vector2 originalSize,
176175
_offset = offset;
177176
}
178177

178+
/// <summary>
179+
///
180+
/// </summary>
181+
/// <param name="sprite"></param>
182+
public NTexture(Sprite sprite)
183+
{
184+
Rect rect = sprite.rect;
185+
rect.y = sprite.texture.height - rect.yMax;
186+
187+
_root = this;
188+
_nativeTexture = sprite.texture;
189+
_region = rect;
190+
_originalSize = new Vector2(_region.width, _region.height);
191+
uvRect = new Rect(_region.x / _nativeTexture.width, 1 - _region.yMax / _nativeTexture.height,
192+
_region.width / _nativeTexture.width, _region.height / _nativeTexture.height);
193+
}
194+
179195
/// <summary>
180196
///
181197
/// </summary>

0 commit comments

Comments
 (0)