Author Topic: Dont know how to do this behavior with NGUI, Pls help  (Read 4325 times)

sk1989

  • Guest
Dont know how to do this behavior with NGUI, Pls help
« on: August 20, 2012, 11:26:57 AM »
So in my game i need a panel that I can drag it down with touch. So its kind like how items are placed in a grid where the user is able to scroll through the list with the mouse by clicking it and dragging the items in the grid . I need my panel to be able to spring down when i click on it and drag it down and when i swipe it up the panel will then spring back to the top where the user cant see the menu anymore.

BTW this game is for an iphone, any suggestions how i can approach this sort of behavior.

sk1989

  • Guest
Re: Dont know how to do this behavior with NGUI, Pls help
« Reply #1 on: August 20, 2012, 01:33:31 PM »
I wanna know how i can make the panel drag with mouse click and drag. I am talking about the about the whole panel not just contents in the panel. I wanna be able drag the whole panel with its contents up and down. Is that possible with NGUI? if so how pls. Im trying everything rite now and nothing is working

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dont know how to do this behavior with NGUI, Pls help
« Reply #2 on: August 20, 2012, 02:15:48 PM »
Look at the quest log example. You can drag the window by dragging it by the NGUI logo. It's achieved using the UIDragObject script.

sk1989

  • Guest
Re: Dont know how to do this behavior with NGUI, Pls help
« Reply #3 on: August 20, 2012, 04:41:12 PM »
so you want me to use the UIDragObject on the panel itself, because thts not working for me rite now.

sk1989

  • Guest
Re: Dont know how to do this behavior with NGUI, Pls help
« Reply #4 on: August 20, 2012, 04:54:02 PM »
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class panelDrag : MonoBehaviour {
  5.   TweenPosition tween;
  6.   public Transform grid;
  7.         bool clicked = false;
  8.  
  9.   void Start()
  10.   {
  11.                 tween = gameObject.GetComponent<TweenPosition>();
  12.                 transform.localPosition = new Vector3(0,500,0);
  13.                 tween.from = transform.localPosition;
  14.                        
  15.   }
  16.   void Update()
  17.   {
  18.        
  19.                        
  20.                
  21.   }
  22.   void OnClick()
  23.   {
  24.         tween.to = new Vector3(0,-500,0);
  25.        
  26.         Debug.Log("CLICKED");
  27.                
  28.                
  29.   }
  30.   void OnDrag()
  31.   {
  32.                
  33.   }
  34.  
  35. }


my tween.To for the panel doesnt work onClick. but if i do it in the inspect view it works for some reason.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dont know how to do this behavior with NGUI, Pls help
« Reply #5 on: August 20, 2012, 07:20:59 PM »
You're using the tween wrong. TweenPosition.Begin() is how you activate it. Setting the 'to' parameter does nothing.