当设置为时,我正在尝试使用第一人称控制器与世界空间UI进行交互.Cursor.lockStateCursorLockMode.Locked
但是当光标被锁定时,光标位置设置为(-1,-1),这是从Inspector告知的.
我进行了图形光线投射EventSystem.RaycastAll,Sreen.width/2和PointerEventData.EventSystem.current.RaycastAll收集屏幕中间的所有UI对象,但不会向它们发送任何事件.
我还试图ExecuteEvents.Execute<IEventSystemHandler>将事件发送到UI目标.当我向其发送'submit'事件时,这适用于按钮.显然这不是一个优雅的解决方案.我也不知道如何向滑块发送消息.
// manully send a 'submit' event to UI elements
List<RaycastResult> results = new List<RaycastResult>();
void Update() {
if (Input.GetButtonUp("Fire1")) {
PointerEventData data = new PointerEventData(EventSystem.current);
data.position = new Vector2(Screen.width / 2, Screen.height / 2);
EventSystem.current.RaycastAll(data, results);
foreach (var result in results) {
ExecuteEvents.ExecuteHierarchy<ISubmitHandler>(
result.gameObject, data,
ExecuteEvents.submitHandler
);
}
}
}
Run Code Online (Sandbox Code Playgroud)
在Windows上全屏播放时,这种疯狂的尝试都有效.2333
[System.Runtime.InteropServices.DllImport("user32.dll")] …Run Code Online (Sandbox Code Playgroud)