Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Littlenorwegians on September 27, 2017, 03:10:52 PM

Title: Constrain to UI Panel
Post by: Littlenorwegians on September 27, 2017, 03:10:52 PM
Hello!

Trying to work my way around an issue. Basically what I am trying to do is ensure that a UIlabel here always stays within the borders of the UI Root's panel.
https://www.dropbox.com/s/o28oj3nq01lo7nz/WithinBorders.mp4?raw=1 (https://www.dropbox.com/s/o28oj3nq01lo7nz/WithinBorders.mp4?raw=1)
(This video showcases the problem quite exactly)

I've fiddled around but I can't really find the "right words" in NGUI to confine this UI element within the bounds.
Very grateful for the help  ;D
Title: Re: Constrain to UI Panel
Post by: ArenMook on October 07, 2017, 06:13:00 AM
All the math you need is in the UIDragObject script. Look for "restrictWithinPanel" and how it uses panel.ConstrainTargetToBounds.