您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
40 行
1.1 KiB
40 行
1.1 KiB
using System;
|
|
using UnityEngine;
|
|
|
|
namespace UnityEditor.Experimental.Rendering.Universal.Path2D.GUIFramework
|
|
{
|
|
internal class ClickAction : HoveredControlAction
|
|
{
|
|
private int m_Button;
|
|
private bool m_UseEvent;
|
|
|
|
public Action<IGUIState, Control> onClick;
|
|
|
|
public ClickAction(Control control, int button, bool useEvent = true) : base(control)
|
|
{
|
|
m_Button = button;
|
|
m_UseEvent = useEvent;
|
|
}
|
|
|
|
protected override bool GetTriggerContidtion(IGUIState guiState)
|
|
{
|
|
return guiState.mouseButton == m_Button && guiState.eventType == EventType.MouseDown;
|
|
}
|
|
|
|
protected override void OnTrigger(IGUIState guiState)
|
|
{
|
|
base.OnTrigger(guiState);
|
|
|
|
if (onClick != null)
|
|
onClick(guiState, hoveredControl);
|
|
|
|
if (m_UseEvent)
|
|
guiState.UseCurrentEvent();
|
|
}
|
|
|
|
protected override bool GetFinishContidtion(IGUIState guiState)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|