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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
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