added code from unity
This commit is contained in:
23
Runtime/UI/PopupReference.cs
Normal file
23
Runtime/UI/PopupReference.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Jovian.PopupSystem.UI {
|
||||
/// <summary>
|
||||
/// Reference-only MonoBehaviour for a popup prefab. Holds serialized scene references
|
||||
/// to the content container, canvas group, and background. All behavior is in
|
||||
/// <see cref="PopupView"/>.
|
||||
/// </summary>
|
||||
public class PopupReference : MonoBehaviour {
|
||||
[SerializeField] RectTransform content;
|
||||
[SerializeField] CanvasGroup canvasGroup;
|
||||
[SerializeField] RectTransform background;
|
||||
|
||||
/// <summary>The content RectTransform where popup elements are parented.</summary>
|
||||
public RectTransform Content => content;
|
||||
|
||||
/// <summary>The CanvasGroup for fade animation control.</summary>
|
||||
public CanvasGroup CanvasGroup => canvasGroup;
|
||||
|
||||
/// <summary>The background RectTransform that sizes to content.</summary>
|
||||
public RectTransform Background => background;
|
||||
}
|
||||
}
|
||||
2
Runtime/UI/PopupReference.cs.meta
Normal file
2
Runtime/UI/PopupReference.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc25da4712d7cc4419eb6f364e032431
|
||||
48
Runtime/UI/PopupTrigger.cs
Normal file
48
Runtime/UI/PopupTrigger.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Jovian.PopupSystem.UI {
|
||||
/// <summary>
|
||||
/// Reference holder MonoBehaviour for popup triggers. Attach to any UI element with a
|
||||
/// Graphic component (Image, TMP_Text, etc.) that has Raycast Target enabled.
|
||||
/// Configure category, anchor side, and position mode in the Inspector.
|
||||
/// Forwards pointer events to the bound <see cref="PopupTriggerView"/>.
|
||||
/// </summary>
|
||||
public class PopupTrigger : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler {
|
||||
[SerializeField] PopupCategory category;
|
||||
[SerializeField] AnchorSide anchorSide = AnchorSide.Below;
|
||||
[SerializeField] PopupPositionMode positionMode = PopupPositionMode.AnchorToElement;
|
||||
|
||||
PopupTriggerView handler;
|
||||
|
||||
/// <summary>The popup category this trigger belongs to.</summary>
|
||||
public PopupCategory Category => category;
|
||||
|
||||
/// <summary>Which side of this element the popup anchors to.</summary>
|
||||
public AnchorSide AnchorSide => anchorSide;
|
||||
|
||||
/// <summary>Whether the popup anchors to this element or follows the mouse.</summary>
|
||||
public PopupPositionMode PositionMode => positionMode;
|
||||
|
||||
/// <summary>The bound behavior handler. Null until <see cref="Bind"/> is called.</summary>
|
||||
public PopupTriggerView Handler => handler;
|
||||
|
||||
/// <summary>
|
||||
/// Binds a <see cref="PopupTriggerView"/> to this trigger. Called automatically
|
||||
/// by <see cref="IPopupSystem.ScanTriggers"/> or <see cref="IPopupSystem.InitializeTriggersInChildren"/>.
|
||||
/// </summary>
|
||||
public void Bind(PopupTriggerView view) {
|
||||
handler = view;
|
||||
}
|
||||
|
||||
/// <summary>Forwards pointer enter to the bound handler.</summary>
|
||||
public void OnPointerEnter(PointerEventData eventData) {
|
||||
handler?.OnPointerEnter(this);
|
||||
}
|
||||
|
||||
/// <summary>Forwards pointer exit to the bound handler.</summary>
|
||||
public void OnPointerExit(PointerEventData eventData) {
|
||||
handler?.OnPointerExit(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Runtime/UI/PopupTrigger.cs.meta
Normal file
2
Runtime/UI/PopupTrigger.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ef9d21a19cd4db4f9d5491202547c05
|
||||
Reference in New Issue
Block a user