- Getting Start
- Project Settings
- Rich Text
- Cocos Creator
- Cry Engine
SDK - Unity
- Insert 3D
- Curved UI
To make a component draggable, it’s very simple, just set the draggable property, for example:
After setting, when the player holds the component, they can drag it at will. You can set a rectangle to limit the drag range:
You can get notifications about the start of dragging, the process of dragging, and the end of dragging:
If you don’t want to click anywhere on the component and drag it, you can use alternative drag. For example, the window in FairyGUI, click its title bar, you can drag the window, we use this as an example to analyze how to achieve:
In the above way, when _dragArea is attempted to be dragged, it will be converted to the drag of the Window itself.
Dragging can only be moved within the parent component of the component. If you need to move within the full screen, you need to use dragging by substitute. The startup method of avatar drag needs to be converted first:
After using the double drag, if you want to detect the end of the drag, you can no longer listen to the original object, you should use:
DragDropManager also provides the commonly used drag-> drop function. If a component needs to receive events that other components drag into it and release, you can use:
DragDropManager uses an image resource to represent the alias. This image is displayed by the loader. This loader is DragDropManager.inst.dragAgent, you can adjust its parameters to fit the actual project needs.
If your stand-in is not as simple as an image, for example, you need to use a component as a stand-in, then you can define your own DragDropManager, copy a DragDropManager directly, modify and write your own logic on it, and then use your DragDropManager. The design of the DragDropManager class does not take into account all practical situations, it is only used as a reference.