using System.Collections; using System.Collections.Generic; using UnityEngine; public class CustomCursor : MonoBehaviour { public Texture2D cursorTexture; public Vector3 rotationCorrection; // 旋转修正,你可以在 Inspector 中设置 private void Start() { // 设置旋转修正 transform.rotation = Quaternion.Euler(rotationCorrection); } private void Update() { // 设置自定义光标的位置为鼠标的位置 Vector2 cursorPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); transform.position = cursorPos; } private void OnEnable() { // 当启用自定义光标时,隐藏默认的鼠标光标 Cursor.visible = false; } private void OnDisable() { // 当禁用自定义光标时,显示默认的鼠标光标 Cursor.visible = true; } public void Shake(float intensity, float speed) { float shakeAmount = Mathf.Sin(Time.time * speed) * intensity; transform.rotation = Quaternion.Euler(rotationCorrection + new Vector3(0, 0, shakeAmount)); } }