Image Sprite is defaulting when GO is SetActive
Hey,
I have a panel inside another panel. I need to set the image sprite of the inner panel, and then set the outer panel to active (which in turn sets the inner panel active).
The problem, is when this happens, it defaults the inner panel's image back to its original, blank image. Here is my snippet:
Texture2D Image = new Texture2D(2, 2);
Image.LoadImage(www.bytes);
Sprite ImageSprite = Sprite.Create(Image, new Rect(0, 0, 600, 600), new Vector2(0.5f, 0.5f));
NewsImage.sprite = ImageSprite;
StartCoroutine(Utils.FadeIn(NewsPanel, 4.0f));
One of the first things Utils.FadeIn does is set the incoming GO (first parameter) to active with SetActive(true).
It is at this point that the image on NewsImage is defaulting back to its original.
Answer by pingu2k4 · Sep 28, 2016 at 12:14 AM
Never mind... I would figure it out just after submitting! I had a sprite swapping script on the NewsImage GO... >.< I swear I took ages before posting this!
Your answer
![](https://koobas.hobune.stream/wayback/20220612093611im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I make Image border not change a size? 1 Answer
Replace 3d objects with 2d image/sprite/plane when camera is at X distance? 0 Answers
Change Sprite according to user choice 0 Answers
is there simple way to put random sprite to gameobject multi child with no repating. 1 Answer
How to better manage switching out card sprites when loading a card from a deck 1 Answer