When a UI is off-screen(Y scale = 1.5), is it good practice to set Visible = false?
Why should I do this?
Does this impact performance in any way?
Is it possible to see UI if the scale is above 1?(like is it possible to see a small square if the Y scale value is set to 1.5)
depends on anchor point and size. I’m not sure what you’d need to set the position to but anchor point affects position a lot. For performance I can’t say for certain, but from personal experience it doesn’t affect performance long as its static. I tried having thousands of frames and it wasn’t really lagging unless they moved with a scrolling frame or anything else that moves it.
No, you don’t have to toggle UI’s visibility based on whether they are in view or not.
All UI in Roblox are vertices-based, meaning it takes note of the 4 corners of a UI object, and draw everything inside.
It’s designed this way for optimization - it is why you can have thousands of frames without any real lag.
The drawback though, is that Roblox has to render absolutely every single bit of that UI - it can’t selectively choose to not render a part of it just because it’s off of the viewport.
And yes, you can still see that UI even if it would clip beyond the borders of your viewport.
It’s really up to you since it’s impossible for the client to see it if it’s off screen. You do not need to make it visible if it is constantly coming back on screen. For example, if you have an update log page that goes off screen when the next page rolls in, you should keep it visible if the player scrolls back again.
BUT
If it isn’t ever gonna come back, then you could make it invisible. Heck, maybe even destroying it would make sense. if you have a loading screen and the player loads in successfully, you’re probably never gonna need it again for him, so you can just delete it if you wish to save memory
Thanks, @AMisspelledUsernaem@Solar_Eos@MysteryX2076.
I would mark you all as a solution but I can only do one so for anyone else who will see this thread I’ll mark the most detailed one as a solution
Alright noted, the reason I asked is because inside a game i have an issue where basically I’m tweening a frame in and out of the users’ screen but if you spam the button it can cause unintended behaviour with the .Visible property so I thought what if I just don’t bother changing the visibility state of it since it’s out of the screen anyway.
It has UIAspectRatioConstraint so afaik it shouldn’t show on the players screen if the position Y scale is more than 1, even if they resized their window.
It’s possible for a scale of a UI element to be over 1 or even below 0, scale is relative to its parent so if you have a small frame and put another one in it, its scale is relative to the bounds of its parent. If you’re specifically only talking about top-level Instances that are parented directly to the UI folder, you could probably get away with this. There are a few scenarios where this isn’t trustworthy like setting a UIs rotation, any child UI manager like UI aspect ratio, size constraints, and screens that have safe zones. The logic required to determine if it’s safe to make something not visible this way would have worse off optimization than just leaving it visible