Search Issue Tracker
By Design
Votes
0
Found in
2018.4
2019.3.4f1
2020.2
Issue ID
1267688
Regression
No
Sprite's rect is cropped when called with Texture2D.LoadImage right after Sprite creation
How to reproduce:
1. Open attached project "case1267688.zip" and scene "TestScene"
2. Enter Play Mode
3. Observe the Sprite B (the middle one) in the Game view
Expected result: The loaded image is displayed correctly
Actual result: The loaded image is displayed incorrectly
Reproducible with: 2018.4.26f1, 2019.4.7f1, 2020.1.1f1, 2020.2.0a20
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Texture is stored upside down when using Blit
- [VFX] Missing Expand Toggle with Output Slot
- [OpenGLES][XR] Zooming in on the camera's URP opaque texture causes "double vision" on Quest in OpenGLES3
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
Resolution Note:
This is as expected. Sprite UVs are calculated the first time it is rendered.
A.sprite = Sprite.Create(texture2D, new Rect(0, 0, 64, 64), Vector2.one * 0.5f);
yield return null; <- Since rendering is happening here, the UV for the Sprite is now set to take up the whole sprite
yield return null;
B.sprite = Sprite.Create(texture2D, new Rect(0, 0, 64, 64), Vector2.one * 0.5f);
texture2D.LoadImage(File.ReadAllBytes(Application.dataPath + @"\A_Simple_128x128_Image.png"));
C.sprite = Sprite.Create(texture2D, new Rect(0, 0, 128, 128), Vector2.one * 0.5f);
// When the first render happens, B.sprite will be calculated based on the the new data in texture2D which is now 128x128