Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: ankit khetrapal on July 08, 2013, 05:53:20 AM
-
Hi,
i am adding data dynamically on a UIDraggablePanel, now suppose i added 10 widgets and now the user is scrolling down and down to see all the widgets, now how can i determine that the user has reached the end so that i can add more data to the list.
-
Keep in mind that the draggable panel isn't meant to have dynamically added content like that, so I suggest you make a copy of the draggable panel script and modify it to suit your needs.
You will want to look at UIDraggablePanel.RestrictWithinBounds function -- particularly the "if (constraint.magnitude > 0.001f)" part.
-
if Draggable panel isn't meant to have dynamically added content, then what other alternative does NGUI provide for dynamic entries.
-
Let me clarify: draggable panel isn't meant to have content added while you are dragging. It works with fixed size content dimensions.
As I said, if you need something that adds content while you are dragging the panel, write your own custom draggable panel script.
-
well i guess writing custom drag-able panel script might have taken a lot of time and i didn't pay NGUI to write custom code so i modified UIDraggablePanel to match my requirement
Just change the RestrictWithinBounds to this add some global declarations at the top
/// <summary>
/// Bool to determine whether to inform other object when the user has reached top limit or bottom limit of a dragable panel
/// </summary>
[SerializeField] private bool postLimitEvent;
/// <summary>
/// Reciever game object to send Limit notification.
/// </summary>
[SerializeField] private GameObject recieverGameObject;
/// <summary>
/// Method to be called when top limit reached
/// </summary>
[SerializeField] private string topLimitMethodName;
/// <summary>
/// Method to be called when bottom limit reached
/// </summary>
[SerializeField] private string bottomLimitMethodName;
public bool RestrictWithinBounds (bool instant)
{
Vector3 constraint = mPanel.CalculateConstrainOffset(bounds.min, bounds.max);
if(postLimitEvent)
{
if(constraint.y > 0)
recieverGameObject.SendMessage(topLimitMethodName,SendMessageOptions.RequireReceiver);
if(constraint.y < 0)
recieverGameObject.SendMessage(bottomLimitMethodName,SendMessageOptions.RequireReceiver);
}
if (constraint.magnitude > 0.001f)
{
if (!instant && dragEffect == DragEffect.MomentumAndSpring)
{
// Spring back into place
SpringPanel.Begin(mPanel.gameObject, mTrans.localPosition + constraint, 13f);
}
else
{
// Jump back into place
MoveRelative(constraint);
mMomentum = Vector3.zero;
mScroll = 0f;
}
return true;
}
return false;
}
Hope other might find it help full.