Event.mousePosition

切换到手册
public Vector2 mousePosition ;

描述

鼠标位置。

EventType.MouseMoveEventType.MouseDrag 事件中使用。

另请参阅:Event.delta

using UnityEngine;
using System.Collections;

// print the mousePosition every 10th of a second

public class ExampleClass : MonoBehaviour { private float range = 0.0f;

void OnGUI() { range = range + Time.deltaTime;

if (range > 0.1f) { Event e = Event.current; Debug.Log(e.mousePosition); range = 0.0f; } } }