I was wondering if parenting an image label to nil is more performant than just setting its visible property to nil? I am planning on having potentially hundreds to thousands of image labels and I really just need to know whether parenting the image label to nil is more performant than setting their visible property to false?
definately dont take my word for it but i believe that with images parenting to nill will do better than just making transparency 0. Depending where you put it that is. For example in server storage it wont take space on the clients device but it will for the server. Its just an image so im not sure that its really that big of a deal.
it’d only be the few devs that see it here but if that doesnt change your mind then thats cool.
I did some reading and am alittle more confident that parenting to nil is more efficient becuase it takes the object out of the game entirely. The visible property however only stops the image from being rendered. The GUI object is still in the game when visible is set to false.
I saw a post awhile back that might be beneficial to you, although I can’t find it. The idea is similar to frustrum culling that Roblox does behind the scenes. If you don’t already know what that is, essentially the only instances on your client that are loaded are the ones that your camera has view of. This video is a good example of how it works.
The post had a similar approach to UIObjects under a ScrollingFrame. Instead of hundreds or thousands of frames being under that UI, only a select few were loaded at a time depending on where you were along that scroll wheel.
If you can, try benchmarking it with a bunch of elements. If there’s any performance gain from changing properties I would guess it’s from maybe some connections being disconnected when you parent to nil, but I don’t think that happens at all.
Sadly instances are just expensive to work with.
You mean add to Debris…? I don’t think that’s relevant here, he probably wants to reuse them, or has them deactivated and activated rapidly. Creating instances is a bit expensive as well.
Yeah, Debris:AddItem(), and you’re right checking the thread it seems they want the instances to remain active just hidden. I’d assume setting the “Visible” property to false would be better since if they are parented to nil then they would still be rendered.
Yeah, I kinda made the assumption that they weren’t rendered unless on-screen as that was the only time that image labels could fail to load, however it becomes problematic when I have a bunch of frames that have their visible property set to false, particularly when tweening a frame as it causes frames to drop which sucks. I don’t think image labels are rendered when they’re not visible in a ScrollingFrame either though.
@Limited_Unique, I need access to the image labels, I can’t just destroy them or add them to debris. Also as NoParameters said, they are only rendered if on-screen, so parenting them to nil shouldn’t render them.
Perhaps this is because if visible is false the other properties are ignored whereas if the image is parented to nil then those other properties are still considered relevant/necessary.