46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
namespace ShrinkTutorial
|
|
{
|
|
public class ShrinkTutorialAnchor : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
[SerializeField] private string anchorId = string.Empty;
|
|
|
|
public string AnchorId => anchorId;
|
|
public event Action<PointerEventData> Clicked;
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
Clicked?.Invoke(eventData);
|
|
}
|
|
|
|
public void SetAnchorId(string value)
|
|
{
|
|
anchorId = value ?? string.Empty;
|
|
|
|
if (isActiveAndEnabled)
|
|
ShrinkTutorialAnchorRegistry.Register(this);
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
ShrinkTutorialAnchorRegistry.Register(this);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
ShrinkTutorialAnchorRegistry.Unregister(this);
|
|
}
|
|
|
|
private void OnValidate()
|
|
{
|
|
if (!Application.isPlaying)
|
|
return;
|
|
|
|
ShrinkTutorialAnchorRegistry.Register(this);
|
|
}
|
|
}
|
|
}
|