On Pointer#
UI / On Pointer
Description#
Executed when the target game object receives a pointer or navigation event. It requires a Graphic with 'Raycast Target' enabled
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime.UI
{
[Title("On Pointer")]
[Image(typeof(IconCursor), ColorTheme.Type.TextLight)]
[Description(
"Executed when the target game object receives a pointer or navigation event. " +
"It requires a Graphic with 'Raycast Target' enabled"
)]
[Category("UI/On Pointer")]
[Keywords(
"UI", "Canvas", "Pointer", "Cursor", "Mouse", "Touch", "Hover", "Click",
"Press", "Release", "Enter", "Exit", "Select", "Deselect", "Submit", "Cancel"
)]
[Serializable]
public class TriggerCoreUIPointer : TriggerHandleSourceBase<HandleOnUIPointer>
{
// EXPOSED MEMBERS: -----------------------------------------------------------------------
[SerializeField] private UIPointerChange m_When = UIPointerChange.Click;
// PROPERTIES: ----------------------------------------------------------------------------
protected override string GetTitle(GameObject source)
{
return $"{this.SourceName} Pointer {TextUtils.Humanize(this.m_When.ToString())}";
}
// OVERRIDE METHODS: ----------------------------------------------------------------------
protected override void OnTrigger(GameObject target)
{
if (this.m_Handle == null || this.m_Handle.Change != this.m_When) return;
using Args args = Args.Get(this.Component, target);
this.Run(args);
}
}
}