| | 1 | | using System.Diagnostics.Tracing; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | | using UnityEngine.EventSystems; |
| | 5 | | using DCL.Interface; |
| | 6 | |
|
| | 7 | | namespace DCL.Components |
| | 8 | | { |
| | 9 | | public class UIReferencesContainer : MonoBehaviour, IPointerDownHandler |
| | 10 | | { |
| | 11 | | [System.NonSerialized] public UIShape owner; |
| | 12 | |
|
| | 13 | | [Header("Basic Fields")] |
| | 14 | | [Tooltip("This needs to always have the root RectTransform.")] |
| | 15 | | public RectTransform rectTransform; |
| | 16 | |
|
| | 17 | | public CanvasGroup canvasGroup; |
| | 18 | |
|
| | 19 | | public HorizontalLayoutGroup layoutGroup; |
| | 20 | | public LayoutElement layoutElement; |
| | 21 | | public RectTransform layoutElementRT; |
| | 22 | |
|
| | 23 | | [Tooltip("Children of this UI object will reparent to this rectTransform.")] |
| | 24 | | public RectTransform childHookRectTransform; |
| | 25 | |
|
| | 26 | | bool VERBOSE = false; |
| | 27 | |
|
| | 28 | | public void OnPointerDown(PointerEventData eventData) |
| | 29 | | { |
| 133 | 30 | | UIShape.Model ownerModel = (UIShape.Model) owner.GetModel(); |
| | 31 | |
|
| 133 | 32 | | if (VERBOSE) |
| | 33 | | { |
| 0 | 34 | | Debug.Log("pointer current raycast: " + eventData.pointerCurrentRaycast, |
| | 35 | | eventData.pointerCurrentRaycast.gameObject); |
| 0 | 36 | | Debug.Log("pointer press raycast: " + eventData.pointerPressRaycast, |
| | 37 | | eventData.pointerPressRaycast.gameObject); |
| | 38 | | } |
| | 39 | |
|
| 133 | 40 | | if (!string.IsNullOrEmpty(ownerModel.onClick) && |
| | 41 | | eventData.pointerPressRaycast.gameObject == childHookRectTransform.gameObject) |
| | 42 | | { |
| 5 | 43 | | WebInterface.ReportOnClickEvent(owner.scene.sceneData.id, ownerModel.onClick); |
| | 44 | | } |
| 133 | 45 | | } |
| | 46 | | } |
| | 47 | | } |