BS 0.2.0 Visual
This commit is contained in:
16
Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseBeginDragBehaviour : MonoBehaviour, IBeginDragHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<PointerEventData> OnBeginDragEvent;
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
OnBeginDragEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/BaseBeginDragBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 521ce1a0929016d4e9e94fa46517292e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BaseCancelBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BaseCancelBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseCancelBehaviour : MonoBehaviour, ICancelHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<BaseEventData> OnCancelEvent;
|
||||
|
||||
public void OnCancel(BaseEventData eventData)
|
||||
{
|
||||
OnCancelEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/BaseCancelBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/BaseCancelBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2212d17ad10dca444b7bb1c5fa038b29
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BaseDeselectBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BaseDeselectBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseDeselectBehaviour : MonoBehaviour, IDeselectHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<BaseEventData> OnDeselectEvent;
|
||||
|
||||
public void OnDeselect(BaseEventData eventData)
|
||||
{
|
||||
OnDeselectEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/BaseDeselectBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/BaseDeselectBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a0f3a17622ff7f4db3d6b72311ca7b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BaseDragBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BaseDragBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseDragBehaviour : MonoBehaviour, IDragHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<PointerEventData> OnDragEvent;
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
OnDragEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/BaseDragBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/BaseDragBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e031d99c1b1405843a30171422e8ba6b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BaseDropBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BaseDropBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseDropBehaviour : MonoBehaviour, IDropHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<PointerEventData> OnDropEvent;
|
||||
|
||||
public void OnDrop(PointerEventData eventData)
|
||||
{
|
||||
OnDropEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/BaseDropBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/BaseDropBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2ae05f07a6ad5a489e2b2f9c1d78d9c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BaseEndDragBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BaseEndDragBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseEndDragBehaviour : MonoBehaviour, IEndDragHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<PointerEventData> OnEndDragEvent;
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
OnEndDragEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/BaseEndDragBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/BaseEndDragBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdee6774c0841f84d9b54844ff020564
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseInitializePotentialDragBehaviour : MonoBehaviour, IInitializePotentialDragHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<PointerEventData> OnInitializePotentialDragEvent;
|
||||
|
||||
public void OnInitializePotentialDrag(PointerEventData eventData)
|
||||
{
|
||||
OnInitializePotentialDragEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b0477e219558a5458fbd5041b99fbba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BaseMoveBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BaseMoveBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseMoveBehaviour : MonoBehaviour, IMoveHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<AxisEventData> OnMoveEvent;
|
||||
|
||||
public void OnMove(AxisEventData eventData)
|
||||
{
|
||||
OnMoveEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/BaseMoveBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/BaseMoveBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65e71cc97af54d74e86e85f52b8fee64
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BasePointerClickBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BasePointerClickBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BasePointerClickBehaviour : MonoBehaviour, IPointerClickHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<PointerEventData> OnPointerClickEvent;
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
OnPointerClickEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b836729fafa81c940ad766b2b7a39ffe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BasePointerDownBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BasePointerDownBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BasePointerDownBehaviour : MonoBehaviour, IPointerDownHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<PointerEventData> OnPointerDownEvent;
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
OnPointerDownEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21606bade6bda96479188aa775bb7958
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BasePointerEnterBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BasePointerEnterBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BasePointerEnterBehaviour : MonoBehaviour, IPointerEnterHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<PointerEventData> OnPointerEnterEvent;
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
OnPointerEnterEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 213f8197d2e780a4eb37503ae30823ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BasePointerExitBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BasePointerExitBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BasePointerExitBehaviour : MonoBehaviour, IPointerExitHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<PointerEventData> OnPointerExitEvent;
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
OnPointerExitEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5977b725805788d429efc1ae02814fe4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BasePointerUpBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BasePointerUpBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BasePointerUpBehaviour : MonoBehaviour, IPointerUpHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<PointerEventData> OnPointerUpEvent;
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
OnPointerUpEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/BasePointerUpBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/BasePointerUpBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0aa7d709dfba11448935fe27cf70245
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BaseScrollBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BaseScrollBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseScrollBehaviour : MonoBehaviour, IScrollHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<PointerEventData> OnScrollEvent;
|
||||
|
||||
public void OnScroll(PointerEventData eventData)
|
||||
{
|
||||
OnScrollEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/BaseScrollBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/BaseScrollBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8df8288fe7377214ca4d71e78161d64a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BaseSelectBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BaseSelectBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseSelectBehaviour : MonoBehaviour, ISelectHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<BaseEventData> OnSelectEvent;
|
||||
|
||||
public void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
OnSelectEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/BaseSelectBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/BaseSelectBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d7ef3c266a619540a243e4cd07206fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BaseSubmitBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BaseSubmitBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseSubmitBehaviour : MonoBehaviour, ISubmitHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<BaseEventData> OnSubmitEvent;
|
||||
|
||||
public void OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
OnSubmitEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/BaseSubmitBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/BaseSubmitBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f7528746466caa4aa60a67fdabd3f90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Convention/[Visual]/Operater/BaseUpdateSelectedBehaviour.cs
Normal file
16
Convention/[Visual]/Operater/BaseUpdateSelectedBehaviour.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class BaseUpdateSelectedBehaviour : MonoBehaviour, IUpdateSelectedHandler, IBehaviourOperator
|
||||
{
|
||||
public UnityEvent<BaseEventData> OnUpdateSelectedEvent;
|
||||
|
||||
public void OnUpdateSelected(BaseEventData eventData)
|
||||
{
|
||||
OnUpdateSelectedEvent?.Invoke(eventData);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 331cf060da6669342b467554dd8b4493
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
117
Convention/[Visual]/Operater/DragBehaviour.cs
Normal file
117
Convention/[Visual]/Operater/DragBehaviour.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Convention.WindowsUI
|
||||
{
|
||||
public class DragBehaviour : WindowsComponent
|
||||
{
|
||||
[SerializeField, Resources] private BehaviourContextManager Context = null;
|
||||
public BehaviourContextManager GetBehaviourContext()
|
||||
{
|
||||
if (Context == null)
|
||||
Context = this.GetOrAddComponent<BehaviourContextManager>();
|
||||
return Context;
|
||||
}
|
||||
public BehaviourContextManager DragBehaviourContext
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Context == null)
|
||||
Context = this.GetOrAddComponent<BehaviourContextManager>();
|
||||
return Context;
|
||||
}
|
||||
}
|
||||
|
||||
[Setting] public bool isCanDrag = true;
|
||||
|
||||
public void SetDragAble(bool isCanDrag)
|
||||
{
|
||||
this.isCanDrag = isCanDrag;
|
||||
}
|
||||
|
||||
public void Init([In, Opt] RectTransform DragObjectInternal, [In, Opt] RectTransform DragAreaInternal)
|
||||
{
|
||||
if (DragObjectInternal != null)
|
||||
this.DragObjectInternal = DragObjectInternal;
|
||||
else if (this.DragObjectInternal == null)
|
||||
this.DragObjectInternal = rectTransform;
|
||||
if (DragAreaInternal != null)
|
||||
this.DragAreaInternal = DragAreaInternal;
|
||||
else if (this.DragAreaInternal == null)
|
||||
this.DragAreaInternal = rectTransform.parent as RectTransform;
|
||||
|
||||
DragBehaviourContext.OnBeginDragEvent ??= new();
|
||||
DragBehaviourContext.OnDragEvent ??= new();
|
||||
|
||||
DragBehaviourContext.OnBeginDragEvent.RemoveListener(this.OnBeginDrag);
|
||||
DragBehaviourContext.OnBeginDragEvent.AddListener(this.OnBeginDrag);
|
||||
DragBehaviourContext.OnDragEvent.RemoveListener(this.OnDrag);
|
||||
DragBehaviourContext.OnDragEvent.AddListener(this.OnDrag);
|
||||
DragBehaviourContext.locationValid = IsRaycastLocationValid;
|
||||
}
|
||||
|
||||
[Setting] public bool IsAutoInit = true;
|
||||
private void Start()
|
||||
{
|
||||
Init(null, null);
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
isCanDrag = true;
|
||||
DragObjectInternal = rectTransform;
|
||||
}
|
||||
|
||||
|
||||
[Setting] public bool topOnClick = true;
|
||||
|
||||
[Content, Ignore, OnlyPlayMode, SerializeField] private Vector2 originalLocalPointerPosition;
|
||||
[Content, Ignore, OnlyPlayMode, SerializeField] private Vector3 originalPanelLocalPosition;
|
||||
|
||||
[Resources, SerializeField] private RectTransform DragObjectInternal;
|
||||
|
||||
[Resources, SerializeField, WhenAttribute.Not(nameof(DragObjectInternal), null)] private RectTransform DragAreaInternal;
|
||||
|
||||
public void OnBeginDrag(PointerEventData data)
|
||||
{
|
||||
if (!isCanDrag) return;
|
||||
originalPanelLocalPosition = DragObjectInternal.localPosition;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(DragAreaInternal, data.position, data.pressEventCamera, out originalLocalPointerPosition);
|
||||
gameObject.transform.SetAsLastSibling();
|
||||
|
||||
if (topOnClick == true)
|
||||
DragObjectInternal.SetAsLastSibling();
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData data)
|
||||
{
|
||||
if (!isCanDrag) return;
|
||||
Vector2 localPointerPosition;
|
||||
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(DragAreaInternal, data.position, data.pressEventCamera, out localPointerPosition))
|
||||
{
|
||||
Vector3 offsetToOriginal = localPointerPosition - originalLocalPointerPosition;
|
||||
DragObjectInternal.localPosition = originalPanelLocalPosition + offsetToOriginal;
|
||||
}
|
||||
|
||||
ClampToArea();
|
||||
}
|
||||
|
||||
private void ClampToArea()
|
||||
{
|
||||
Vector3 pos = DragObjectInternal.localPosition;
|
||||
|
||||
Vector3 minPosition = DragAreaInternal.rect.min - DragObjectInternal.rect.min;
|
||||
Vector3 maxPosition = DragAreaInternal.rect.max - DragObjectInternal.rect.max;
|
||||
|
||||
pos.x = Mathf.Clamp(DragObjectInternal.localPosition.x, minPosition.x, maxPosition.x);
|
||||
pos.y = Mathf.Clamp(DragObjectInternal.localPosition.y, minPosition.y, maxPosition.y);
|
||||
|
||||
DragObjectInternal.localPosition = pos;
|
||||
}
|
||||
|
||||
public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
|
||||
{
|
||||
return isCanDrag || transform.childCount != 0;
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Visual]/Operater/DragBehaviour.cs.meta
Normal file
11
Convention/[Visual]/Operater/DragBehaviour.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c163c8a7285b54c4383a987f1d42065b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user