简体   繁体   English

在平面/立方体世界空间中获取鼠标单击位置

[英]Getting mouse click position in a Plane/Cube world Space

Hi2,嗨2,

This seems to be an easy problem to fix., but i still cannot figure it on my own.这似乎是一个容易解决的问题,但我仍然无法自己解决。

I need to be able to find the position of my mouse click at the 3D plane at world space which corresponding to plane's scale.我需要能够在世界空间的 3D 平面上找到鼠标单击的位置,该位置对应于平面的比例。

For example:例如: 在此处输入图片说明 if i click the point a in my game view., it should return me 0,0f The MainCamera however, can do move around.如果我在游戏视图中单击 a 点,它应该返回 0,0f 但是 MainCamera 可以四处移动。


在此处输入图片说明 and then if click point C it should return me a Vector2 which (i believe) should correspond with the scaling of the 3d object然后如果点击 C 点,它应该返回一个 Vector2,它(我相信)应该与 3d 对象的缩放相对应


在此处输入图片说明 and clicking inside the 3D plane, should once again return me a Vector2 according to the Object's scaling.并在 3D 平面内单击,应根据对象的缩放再次返回 Vector2。

I know that i can use Input.mousePosition but it just return me the mouse position without any relation to the plane object itself.我知道我可以使用Input.mousePosition但它只是返回鼠标位置,与平面对象本身没有任何关系。

There is " Camera.ScreenToWorldPoint" that converts to in game position.有转换为游戏位置的“Camera.ScreenToWorldPoint”。 here: https://docs.unity3d.com/2018.4/Documentation/ScriptReference/Camera.ScreenToWorldPoint.html此处: https : //docs.unity3d.com/2018.4/Documentation/ScriptReference/Camera.ScreenToWorldPoint.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM