45 lines
1004 B
C#
45 lines
1004 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public abstract class SpriteButton : MonoBehaviour
|
|
{
|
|
private bool _isHold;
|
|
private bool _isButtonActive;
|
|
|
|
private void Update()
|
|
{
|
|
// 如果按钮未激活就直接返回
|
|
if (!_isButtonActive) return;
|
|
|
|
// 发射射线
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);
|
|
|
|
// 检查射线是否与当前按钮接触
|
|
if (hit.collider.gameObject == gameObject)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
protected virtual void OnButtonDown()
|
|
{
|
|
|
|
}
|
|
|
|
protected virtual void OnButtonUp()
|
|
{
|
|
|
|
}
|
|
|
|
protected virtual void OnButtonHold()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|