- Home /
How can I get a UI Panel's size in relation to the screen size?
I'm working on draggable ui panels, which is working fine. The problem is when I try to clamp the panel inside the screen so that it can't be dragged off. I tried using the panels rect transform and screen.width and screen.height, but the latter two change with the screen size while the panel size stays the same.
Comment
Answer by AmunTech · Dec 02, 2015 at 08:09 PM
You can add a canvas scaler component to your ui object and then set the ui scale mode to "scale with screen size". You can find it by searching canvas scaler inside AddComponet menu in the inspector.
Thanks, it's still not working though. I tried adding the component, but it was grayed out and stuck on "World." Any ideas why?