Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: sk1989 on September 22, 2012, 09:38:28 PM
-
HI,
I have a dragganle panel with button. I want to set manually the drag delta position of each button manually on start().
I know that on onDrag(delta) the delta give me the drag position of the object. But how do i set the delta position on start.
for example
I wanna do void Start()
{
here i want to set the drag position of the button in the draggable panel
delta.x = -10;//for example. is there a function like to set the drag of a dragpanelContents
}
Thanks
-
What i really want to do is,
In my game, I have a menu with bunch of ngui buttons that are in a draggable panel being able to drag horizontally.
The game is for an iphone. Iphone has a built in compass. I got a plugin that detects the compass as well as returns values. Based on those values
i want to be able to drag the panel left and right controlled by the compass.
Essentially, I want to achieve an action where I can make the panel draggable with the compass without using any touch events.
One approach,that i thought of is if i can drag the panel in code and then with compass reading i can set those values to drag the panel.
-
I'm still not quite clear on what it is you're trying to do. o_O
-
okay Ill explain it again.
Basically all I want is to drag the panel using the compass. How can i do that with NGUI?
How can i manually drag the panel in code, that is my question
-
I see. My suggestion is don't use a draggable panel for this. Draggable panel is for user input, and since you're providing manual input, you don't need it. The slow but simple approach would be to simply move the root object directly underneath the panel. For example if you had this layout:
UIPanel (clipped)
- Root Object <-- move this around
---Widget 1
---Widget 2
---Widget 3
The faster approach would be to adjust the clipping rect of the clipped UIPanel at the same time as its position (by the opposite value), same as UIDraggablePanel does it. This approach doesn't involve rebuilding of geometry, which is why it's faster.
-
I dont understand what you mean by move the root object underneath the panel. The root object in my scene would be the UIGrid.
and in the fas approach how do you adjust clipping rect of the clipped UI panel ?
-
Everything should still be under UIRoot. Here is the full hierarchy to be clear:
UIRoot
-- UICamera
---- UIAnchor
------ UIPanel
-------- Root Object <-- move this around
---------- Widget 1
---------- Widget 2
---------- Widget 3