Author Topic: Constrain to UI Panel  (Read 2739 times)

Littlenorwegians

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Constrain to UI Panel
« 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
(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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Constrain to UI Panel
« Reply #1 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.