- Home /
Question by
Anthony Lapshin · Jan 23, 2014 at 03:38 PM ·
c#spriteloadingcreate a texture
How to create Sprite from loaded texture
I'm trying to create a sprite from texture, it looks like this:
SpriteRenderer renderer = this.transform.GetChild(0).gameObject.GetComponent<SpriteRenderer>();
Sprite sprite = Sprite.Create(tex, new Rect(0,0,130,130), new Vector2(1, 1), 100.0f);
renderer.sprite = sprite;
texture I create from byte [], which I load from network:
Texture2D tex = new Texture2D (textureWidth, textureHeight);
tex.LoadImage(data);
as a result I have broken sprite.
What am I doing wrong?
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Ball Bouncing 1 Answer
How do i flip my character and its objects and not just the sprite 2 Answers
How to do a sprite flip 1 Answer