基于UGUI的拖拽组件系统,主要支持以下功能:
- Item的自由拖拽及与Target的附着;
- Item和Target响应Enter、Exit、Attach、Detach等事件,并通过代理为其添加回调;
- 使用
matchingChannel
来限制只有特定通道的Item和Target可以匹配,并支持万能匹配universalMatching
; - 使用
matchingTag
来识别不同的目标类别; - 支持点击或长按Item使其从Target脱离;
- 除拖放之外,Item还支持响应点击事件,并兼容
ScrollRect
的拖动事件; - 可配置Target最大可附着的Item数量,以及当超出数量时是否替换掉最早附着的Item
用法详见工程中附带的示例,场景Scene
及脚本TestScript
。
A Drag&Drop components system based on UGUI that has the following features:
- Drag Items freely and attach them to Targets;
- Items and Targets can receive callback events like Enter, Exit, Attach, Detach etc;
- Use
matchingChannel
to make sure that only Items and Targets with exact channels can match, and alse an extrauniversalMatching
property is provided; - Use
matchingTag
to identify different Item or Target types; - Detach with long press is supported;
- Items can also receive click events and are able to work with drag events of a
ScrollRect
as well; - The max count of Items one Target can be attached to is configurable, and so is the behaviour when more Items are attached(replace the first attached or not)
For more details please run Scene
or view TestScript
.