首先,安装好Unity3D; 然后,绑定MonoDevelop。
为了调试方便,把MonoDevelop调试绑定到unity3D吧
弹出窗口,选择右下角attach,OK可以使用MonoDevelop调试了。
强烈建议先熟悉一个 Unity3D入门教程,其他的就不说了。
建议用C#写哦,JS不太规范.
因为没有安装任何插件,那么还是用代码来实现:
为了调试方便,把MonoDevelop调试绑定到unity3D吧
弹出窗口,选择右下角attach,OK可以使用MonoDevelop调试了。
强烈建议先熟悉一个 Unity3D入门教程,其他的就不说了。
建议用C#写哦,JS不太规范.
因为没有安装任何插件,那么还是用代码来实现:
- using UnityEngine;
- using System.Collections;
- public class clickscreen : MonoBehaviour {
-
// 在外部拖拽图片绑定用public -
public Texture tex_menu_; // 添加背景图片 -
public Texture tex_finger_; // 添加手指图片 -
private Vector3[] current_pos_ = new Vector3[5] ; // 创建五个位置,为什么呢?因为只支持五个触摸点,呵~呵 -
private int touch_count_; // 点击计数 -
-
// Use this for initialization -
void Start () { -
// 这里是初始化哦 -
} -
-
// Update is called once per frame -
void OnGUI () { -
// 这里是一直持续描绘 -
-
GUI.DrawTexture( new Rect(0,0,640,960), tex_menu_); // 描绘背景贴图 -
-
// 保护后庭 -
if( touch_count_>0 ) -
{ -
for( int i= 0; i -
{ -
GUI.DrawTexture(new Rect(current_pos_[i].x, 960 - current_pos_[i].y, 106, 106), tex_finger_); -
} -
} -
} -
void Update() -
{ -
// 这里是一直持续更新 -
if(Input.GetMouseButtonDown(0)) -
{ -
++ touch_count_; -
current_pos_[touch_count_-1] = Input.mousePosition; -
} -
} - }
这篇Unity3D学习笔记介绍了如何在场景中实现点击屏幕时显示手指位置的功能。通过使用Unity的Input模块检测鼠标点击,结合OnGUI方法绘制手指图像,实现了最多五个触摸点的追踪和显示。
4004

被折叠的 条评论
为什么被折叠?



