- Home /
Image doesn't appear unless I hit the Set Native Size button
I'm programattically creating an image using a sprite:
MyImage.sprite = Resources.Load<Sprite>(spritePath);
MyImage.SetNativeSize();
but the sprite doesn't show up unless I hit the Set Native Size button in the inspector. As you can see, I'm already calling SetNativeSize(), and hitting the button doesn't actually change any values in the inspector (the size is already correct before I hit the button), in both debug and normal view.
I've also noticed that changing the size in the inspector (e.g. adding one pixel to the width) also makes the image appear.
What can I do to make this image appear without necessitating an action in the inspector?
Thank you.
Answer by $$anonymous$$ · Mar 23 at 02:49 PM
Hello. So basically you should set the right Texture format during loading. For example RGBA32.
new Texture2D(camWidth, camHeight, TextureFormat.RGBA32, false)
Your answer
Follow this Question
Related Questions
load all png files as resource but NOT from resource folder 2 Answers
Create PNG from dynamic mesh 1 Answer
uGui - Creating a panel frame for varius sizes 0 Answers
Changing multiple UI.Image source image downloaded via WWW class 0 Answers
How do you insert an image into the new rich text system? 1 Answer