Author Topic: Non-Automatic UIRoot affects mouse position on drag  (Read 3541 times)

Amitloaf

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 31
    • View Profile
Non-Automatic UIRoot affects mouse position on drag
« on: August 06, 2012, 10:27:54 AM »
When dragging, the delta given to the OnDrag Method is the same as the mouse delta got from Input.mousePosition.
On automatic height UIRoot it works great. When turned off, the mouse and the object trying to follow it with Drag are progressing differently, depending on resolution.
Is there a method for converting the mouse position to the dragged object position on Manual Height UIRoot, or something similar?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Non-Automatic UIRoot affects mouse position on drag
« Reply #1 on: August 06, 2012, 01:46:28 PM »
Multiply it by UIRoot.screenSize / Screen.height.

nospam94

  • Guest
Re: Non-Automatic UIRoot affects mouse position on drag
« Reply #2 on: January 11, 2013, 12:05:12 PM »
HI, If we have multiple camera with UICamera script and different UIRoot, how to access the correct UIRoot for setting correct ondrag (delta) for example.

if it is UICamera that send the onDrag event that we receive for example in DragDropItem, would'nt be better to calculate correcte mouse delta in UICamera ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Non-Automatic UIRoot affects mouse position on drag
« Reply #3 on: January 11, 2013, 01:15:36 PM »
NGUITools.FindInParents<UIRoot>(gameObject)

enzi

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 21
    • View Profile
Re: Non-Automatic UIRoot affects mouse position on drag
« Reply #4 on: May 27, 2013, 06:00:24 PM »
Just stumbled upon this.

UIRoot.screenSize doesn't exist anymore. What can I use instead?

Thanks

edit: Got it
  1. int manualHeight = NGUITools.FindInParents<UIRoot>(gameObject).manualHeight;
  2. int screenHeight = Screen.height;
  3.  
  4. float scaleDiff = (float) manualHeight / screenHeight;
  5. delta *= scaleDiff;
  6.  
« Last Edit: May 27, 2013, 06:13:08 PM by enzi »