-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathInventorySlot_NotDragAble.cs
98 lines (72 loc) · 3.56 KB
/
InventorySlot_NotDragAble.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#region Header
/* ============================================
* Author : Strix
* Initial Creation Date : 2020-01-30
* Summary :
* Template : For Unity Editor V1
============================================ */
#endregion Header
using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UIFramework.InventorySlotLogic;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UIFramework
{
/// <summary>
/// 주의) 드래그가 안될 수 있음
/// </summary>
public class InventorySlot_NotDragAble : InventorySlot, IBeginDragHandler, IDragHandler, IEndDragHandler
{
/* const & readonly declaration */
/* enum & struct declaration */
/* public - Field declaration */
public event System.Action<InventorySlot, PointerEventData> OnDragBeginSlot;
public event System.Action<InventorySlot, PointerEventData> OnDragSlot;
public event System.Action<InventorySlot, PointerEventData> OnDragEndSlot;
[Header("드래그 유무")]
public bool bIsDragAble = false;
/* protected & private - Field declaration */
// ========================================================================== //
/* public - [Do~Something] Function */
public override void DoInit_SlotCommandLogic(InventorySlot_CommandLogic[] arrSlotCommandLogic)
{
OnDragBeginSlot -= ExecuteLogic_CommandEvent_OnDragBegin;
OnDragBeginSlot += ExecuteLogic_CommandEvent_OnDragBegin;
OnDragSlot -= ExecuteLogic_CommandEvent_OnDrag;
OnDragSlot += ExecuteLogic_CommandEvent_OnDrag;
OnDragEndSlot -= ExecuteLogic_CommandEvent_OnDragEnd;
OnDragEndSlot += ExecuteLogic_CommandEvent_OnDragEnd;
}
public void OnBeginDrag(PointerEventData eventData) { if (bIsDragAble) OnDragBeginSlot?.Invoke(this, eventData); }
public void OnDrag(PointerEventData eventData) { if (bIsDragAble) OnDragSlot?.Invoke(this, eventData); }
public void OnEndDrag(PointerEventData eventData)
{
if (bIsDragAble == false)
return;
EventSystem.current.RaycastAll(eventData, g_listHit);
for (int i = 0; i < g_listHit.Count; i++)
{
InventorySlot pSlot = g_listHit[i].gameObject.GetComponentInParent<InventorySlot>();
if (pSlot == null || pSlot == this || pSlot.bIsClone)
continue;
Event_OnSwapSlot(pInventory, this, pSlot.pInventory, pSlot);
break;
}
OnDragEndSlot?.Invoke(this, eventData);
}
// ========================================================================== //
/* protected - [Override & Unity API] */
/* protected - [abstract & virtual] */
// ========================================================================== //
#region Private
void ExecuteLogic_CommandEvent_OnDragBegin(InventorySlot arg1, PointerEventData arg2) { ExecuteLogic_Command(EInventorySlot_CommandEvent.OnDragBegin, arg2); }
void ExecuteLogic_CommandEvent_OnDrag(InventorySlot arg1, PointerEventData arg2) { ExecuteLogic_Command(EInventorySlot_CommandEvent.OnDrag, arg2); }
void ExecuteLogic_CommandEvent_OnDragEnd(InventorySlot arg1, PointerEventData arg2) { ExecuteLogic_Command(EInventorySlot_CommandEvent.OnDragEnd, arg2); }
#endregion Private
}
}