Author Topic: Magnetic UIDraggablePanel  (Read 4817 times)

cayou

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 90
    • View Profile
Magnetic UIDraggablePanel
« on: June 14, 2012, 08:43:01 PM »
Hi everyone !
I'm trying to use a draggable panel, to show a menu filled with UILabels.
I would like to use some magnetic effect, like when the user release the mouse button, the panel will stop at a special position (each 50 pixel for example), to show always an option centered in the middle of the view.
Tell me if I'm not clear :D

I search for this options, without success.
Maybe I've to create a script to do it, but I've no starting point.

Thanks ! 

cayou

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 90
    • View Profile
Re: Magnetic UIDraggablePanel
« Reply #1 on: June 14, 2012, 09:24:14 PM »
Oh yeah, another question :)
I was wondering if it's possible to reduce the scroll speed, not to set it strictly to the mouse position, but half for example.
I changed the Scroll Wheel Factor to 0.00001, seems not working, it takes only the sign of this value.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Magnetic UIDraggablePanel
« Reply #2 on: June 16, 2012, 09:35:28 AM »
To your first question:

You have to define the stops yourself, and use SpringPanel to auto-move the panel to the position you want.

As for reducing the movement fo drag, I think it's possible, but I'm not sure how. :)

cayou

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 90
    • View Profile
Re: Magnetic UIDraggablePanel
« Reply #3 on: June 16, 2012, 11:24:55 AM »
Hi Nicki,

Quote
You have to define the stops yourself, and use SpringPanel to auto-move the panel to the position you want
Define the stop myself? How exactly? By scripting? if yes, could you tell me a starting point?

And how I use the spring panel to move my self the panel?
Seems that won't be an easy task for a little effect...

Thanks.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Magnetic UIDraggablePanel
« Reply #4 on: June 16, 2012, 11:52:34 AM »
Well, you know the size of your grid/table or whatever you are using to place items inside your draggable panel right?

Then you have to figure out which X-values should be a stopping point for the panel.

Setting up a random example: I have a panel that's 3000px wide, I want it to stop at each 200px interval.

You will want to attach your own script to the game object that has the draggable panel and intercept when OnPress(false) is sent to it. Then you can grab the actual localPosition of the panel and SpringPanel it to the desired place. If I stop at 874Px for instance, you could SpringPanel towards 800 and stop there.

I'm not entirely sure how it would interact with momentum if you have that on, but preferably you should just turn that off, when you have your own "paged view" like this.

I'm just going off the top of my head, so it might not work 100% like that, but it should give you an idea of it, and it's the way I would try to go about it. :)

cayou

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 90
    • View Profile
Re: Magnetic UIDraggablePanel
« Reply #5 on: June 17, 2012, 10:34:52 AM »
Well, I'll try to do it, and post the result here :)

Thanks !