unity中 鼠标按下移动端与pc端的位置

if (Input.GetMouseButtonDown(0))

{

Vector2 V = Input.touchCount > 0 ? Input.GetTouch(0).position : new Vector2(Input.mousePosition.x, Input.mousePosition.y);

}

射线检测

if (Input.GetMouseButtonDown(0))

{

ray = Input.touchCount > 0 ? Camera.main.ScreenPointToRay(Input.GetTouch(0).position) : Camera.main.ScreenPointToRay(Input.mousePosition);

}

相关推荐
星火撩猿4 小时前
常见游戏引擎介绍与对比
unity·ue5·游戏引擎·godot
sky_smile_Allen5 小时前
[Unity]-[UI]-[Prefab] 关于Unity UGUI 的布局及组件讲解
ui·unity·游戏引擎
虾球xz7 小时前
游戏引擎学习第244天: 完成异步纹理下载
c++·学习·游戏引擎
太妃糖耶11 小时前
URP-利用矩阵在Shader中实现物体的平移和缩放
unity·矩阵
Magnum Lehar14 小时前
ApophisZerg游戏引擎项目目录展示
人工智能·vscode·编辑器·游戏引擎
Tandy12356_17 小时前
Godot开发2D冒险游戏——第一节:主角登场!
python·游戏引擎·godot
是阿根1 天前
unity使用iTextSharp生成PDF文件
unity·c#·游戏引擎
常城1 天前
Unity中通过TMP使用图片字体
unity·游戏引擎
惊鸿醉1 天前
⭐Unity 开发 | 如何通过 NTP 网络时间实现精准的跨平台时间同步【附完整源码 + UI 模块 + 偏差分析】
网络·unity·游戏引擎
虾球xz1 天前
游戏引擎学习第243天:异步纹理下载
c++·学习·游戏引擎