Event.mousePosition

Switch to Manual
public Vector2 mousePosition ;

Description

鼠标位置。

Used in EventType.MouseMove and EventType.MouseDrag events. The top-left of the window returns (0, 0). The bottom-right returns (Screen.width, Screen.height).

另请参阅: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; } } }