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
- Blank, Light-Themed "Create Node" window becomes visible on the next project open
- UI Elements/Layout inconsistencies in the Particle System component
- The Game view and Scene view fail to render when launching the Editor with a maximized Render Graph Viewer window
- "List is empty" is poorly visible in the "Create Node" window
- [Android] GameObject with a custom shader becomes invisible when deployed with the Vulkan Graphics API
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