| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.EventSystems; |
| | 4 | |
|
| | 5 | | public interface IDragAndDropSceneObjectView |
| | 6 | | { |
| | 7 | | Canvas GetGeneralCanvas(); |
| | 8 | | event Action OnDrop; |
| | 9 | |
|
| | 10 | | void Drop(); |
| | 11 | | } |
| | 12 | |
|
| | 13 | | public class DragAndDropSceneObjectView : MonoBehaviour, IDragAndDropSceneObjectView |
| | 14 | | { |
| | 15 | | public Canvas generalCanvas; |
| | 16 | | public event Action OnDrop; |
| | 17 | |
|
| | 18 | | [SerializeField] internal EventTrigger dragAndDropEventTrigger; |
| | 19 | |
|
| | 20 | | private const string VIEW_PATH = "GodMode/DragAndDropSceneObjectView"; |
| | 21 | |
|
| | 22 | | internal static DragAndDropSceneObjectView Create() |
| | 23 | | { |
| 1 | 24 | | var view = Instantiate(Resources.Load<GameObject>(VIEW_PATH)).GetComponent<DragAndDropSceneObjectView>(); |
| 1 | 25 | | view.gameObject.name = "_DragAndDropSceneObjectView"; |
| | 26 | |
|
| 1 | 27 | | return view; |
| | 28 | | } |
| | 29 | |
|
| 40 | 30 | | private void Awake() { BIWUtils.ConfigureEventTrigger(dragAndDropEventTrigger, EventTriggerType.Drop, (eventData) => |
| | 31 | |
|
| 40 | 32 | | private void OnDestroy() { BIWUtils.RemoveEventTrigger(dragAndDropEventTrigger, EventTriggerType.Drop); } |
| | 33 | |
|
| 0 | 34 | | public Canvas GetGeneralCanvas() { return generalCanvas; } |
| | 35 | |
|
| 2 | 36 | | public void Drop() { OnDrop?.Invoke(); } |
| | 37 | | } |