using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class MouseManager : MonoBehaviour
{
public static MouseManager Instance;
RaycastHit hitInfo;
public event Action<Vector3> OnMouseClicked;
void Awake()
{
if (Instance != null)
Destroy(gameObject);
Instance = this;
}
void Update()
{
SetCursorTesture();
MouseControl();
}
void SetCursorTesture()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hitInfo))
{
//切换鼠标贴图
}
}
void MouseControl()
{
if (Input.GetMouseButtonDown(0) && hitInfo.collider != null)
{
if (hitInfo.collider.gameObject.CompareTag("Ground"))
OnMouseClicked?.Invoke(hitInfo.point);
}
}
}
然后它就给我报错CS0111