| | 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 | | { |
| 66 | 30 | | UIShape.Model ownerModel = (UIShape.Model) owner.GetModel(); |
| | 31 | |
|
| 66 | 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 | |
|
| 66 | 40 | | if (!string.IsNullOrEmpty(ownerModel.onClick) && |
| | 41 | | eventData.pointerPressRaycast.gameObject == childHookRectTransform.gameObject) |
| | 42 | | { |
| 5 | 43 | | WebInterface.ReportOnClickEvent(owner.scene.sceneData.id, ownerModel.onClick); |
| | 44 | | } |
| 66 | 45 | | } |
| | 46 | |
|
| | 47 | | #if UNITY_EDITOR |
| | 48 | | [Header("Debug")] |
| | 49 | | public bool forceRefresh; |
| | 50 | |
|
| | 51 | | public void LateUpdate() |
| | 52 | | { |
| 1339 | 53 | | if (forceRefresh) |
| | 54 | | { |
| 0 | 55 | | owner.RefreshAll(); |
| 0 | 56 | | forceRefresh = false; |
| | 57 | | } |
| 1339 | 58 | | } |
| | 59 | | #endif |
| | 60 | | } |
| | 61 | | } |