33 lines
773 B
C#
33 lines
773 B
C#
using UnityEngine;
|
|
|
|
namespace AibisDream.Framework
|
|
{
|
|
public class SpriteButtonKit : IMonoKit
|
|
{
|
|
private readonly Camera _camera = Camera.main;
|
|
private GameObject _curButton;
|
|
|
|
public void OnUpdate()
|
|
{
|
|
// 发射射线进行检测
|
|
Ray ray = _camera.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);
|
|
|
|
// 射线没有碰撞到东西
|
|
if (!hit.collider)
|
|
{
|
|
_curButton = null;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public interface ISpriteButton
|
|
{
|
|
public void OnMouseEnter();
|
|
public void OnMouseExit();
|
|
|
|
}
|
|
} |