Author Topic: Move UITexture around screen with mouse  (Read 5394 times)

jacksmash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Move UITexture around screen with mouse
« on: November 24, 2014, 07:59:26 PM »
I have a UITexture using the DownloadTexture script to get the image. This works fine, but I'd like to allow the user to resize the texture with the mouse and also drag it around the screen. What is the best approach to this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Move UITexture around screen with mouse
« Reply #1 on: November 25, 2014, 01:38:15 AM »
ALT+SHIFT+C to add a collider and add UIDragObject to it.

To resize, UIDragResize. Check the chat window example, it's a resizable window.

jacksmash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Move UITexture around screen with mouse
« Reply #2 on: December 01, 2014, 07:36:31 PM »
Thanks! Dragging works great! I'm missing the resize script so I must need to update my NGUI package :)

jacksmash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Move UITexture around screen with mouse
« Reply #3 on: December 04, 2014, 07:06:54 PM »
Is there a way to have the drag script maintain the aspect ratio of the widget being resized?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Move UITexture around screen with mouse
« Reply #4 on: December 05, 2014, 01:00:57 AM »
Widgets have an aspect ratio field. You will need to set it to something other than "free".

jacksmash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Move UITexture around screen with mouse
« Reply #5 on: December 08, 2014, 07:48:32 PM »
Apologies. Missed that. All good now.