Author Topic: Create DragWindow - iOS Notifcation Area style  (Read 7065 times)

kaz2057

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Create DragWindow - iOS Notifcation Area style
« on: October 18, 2013, 04:05:33 AM »
Dear Forum,

I ask help to create for my project a DragWindow object with some particular rules.
It need to be like iOS Notification Area, so:

1) Y axis clamp

2) OnDrag function need to have a check on position:
- OnRelease if Y delta (delta is the drag movement) is minus that the half of total Y position, dragWindow go to startPos, otherwhite it is plus, goTo endPos ...

The code is like:
if (delta) >= (Yclamp / 2) {
     iTween.MoveTo (dragWindow, from "currentPos" , to"endPos")
}
else {iTween.MoveTo (dragWindow, from "currentPos" , to"startPos")

Anybody please con help me to implement this in dragWindow? Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Create DragWindow - iOS Notifcation Area style
« Reply #1 on: October 18, 2013, 05:53:08 PM »
TweenPanel.Begin is what you'd use here instead of iTween.MoveTo. Draggable panels are always moved by tweening the panel's clipping, not position.

kaz2057

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Create DragWindow - iOS Notifcation Area style
« Reply #2 on: October 19, 2013, 12:38:32 PM »
TweenPanel.Begin is what you'd use here instead of iTween.MoveTo. Draggable panels are always moved by tweening the panel's clipping, not position.

Hi Aren, thanks for support :)

However I not use draggable Panel, but draggable WINDOWS.

What I need is to have draggable windows like iOS notification area (you find on iOS just to drag you finger from UP border of screen where you find Facebook or twitter notification) ...

I dont think draggable panel is what I need.
Infact I start from Draggable Window example that use UIDragObject script :)

I need to insert clamp function in UIDragObject.cs for Y axes and the tween controller ...

Other help? :)

kaz2057

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Create DragWindow - iOS Notifcation Area style
« Reply #3 on: October 19, 2013, 12:51:00 PM »
To UIDragObject I add the follow lines:

1) clamp vars
public Vector3 minOffset = new Vector3 (0,0,0);
public Vector3 maxOffset = new Vector3 (0,0,0);

2) In OnDrag (Vector2 delta) I add in lines:

else
{
// Adjust the position
target.position += offset;
// MY CLAMP FUNCTION
target.position = new Vector3 (Mathf.Clamp(target.position[0], minOffset[0], maxOffset[0]), Mathf.Clamp(target.position[1], minOffset[1], maxOffset[1]), Mathf.Clamp(target.position[2],minOffset[2], maxOffset[2]));

}

Using this line however I don;t understand how minOffset = -1.4 is equal to the max distance from bottom.
If i print (delta) when I drag until the end bottom, it print -1.4 and top end is equal to 0.25 ...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Create DragWindow - iOS Notifcation Area style
« Reply #4 on: October 19, 2013, 08:39:12 PM »
Don't use world position. It won't make sense to you. Instead, use localPosition. It will be (most likely) in pixels -- depending on your UIRoot setting.

kaz2057

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Create DragWindow - iOS Notifcation Area style
« Reply #5 on: October 20, 2013, 11:55:34 AM »
TweenPanel.Begin is what you'd use here instead of iTween.MoveTo. Draggable panels are always moved by tweening the panel's clipping, not position.

Sorry for question ... but I dont find any TweenPanel.Begin on help docs ... I find just TweenPosition.Begin ...

Edit: However with TweenPosition.Begin and localPosition instead of worldspace everything works fine.

Thanks for support

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Create DragWindow - iOS Notifcation Area style
« Reply #6 on: October 20, 2013, 06:15:27 PM »
Sorry, I meant SpringPanel, not TweenPanel.

kaz2057

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Create DragWindow - iOS Notifcation Area style
« Reply #7 on: October 24, 2013, 10:23:31 AM »
Hi Aren,

SpringPanel is fantastic solution :)

All works fine included also with LagPosition!