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
- Reflection problems when unbaked Reflection Probes are present
- Light Explorer columns sorting arrow is too small
- Context menu actions (Collapse All, Expand All, Enable All, Disable All, Remove All, Reset All) do nothing in Volume component
- [Android] Audio volume decreases when returning to the app during screen recording
- Graphical issues are caused by GPU Occlusion Culling when using Amplify Shaders
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