- Home /
Best practice : Image.enable vs go.SetAactive()
I have a game object with a image component that I want to hide and show programmatically. What (and why) is the best practice between :
Storing the game object and call go.SetActive(true);
Storing the image component and call img.enable = true;
Thanks
Answer by Dailyalex · Jan 12 at 11:54 AM
I would suggest to use SetActive()
, because Unity wont update inactive object (maybe its tiny difference, but still it is better performance).
But it depends on your needs, e.g. if there is some other component apart of image which should be updated, but not shown, then you can't turn this game object off with SetActive()
. Thats all :)
Just a question, does an object disabled by SetActive() still consume memory, i know it doesn't consume cpu, but does it consume memory?