Unity3D学习笔记(1)-简单的unity&n…

来源:互联网 发布:php截取中间字符串 编辑:程序博客网 时间:2024/05/16 16:59
首先,安装好Unity3D; 然后,绑定MonoDevelop。

为了调试方便,把MonoDevelop调试绑定到unity3D吧
Unity3D学习笔记(1)-简单的unity <wbr>2d贴图

弹出窗口,选择右下角attach,OK可以使用MonoDevelop调试了。

强烈建议先熟悉一个Unity3D入门教程,其他的就不说了。

建议用C#写哦,JS不太规范.

因为没有安装任何插件,那么还是用代码来实现:

  1. using UnityEngine;
  2. using System.Collections;
  3. public class clickscreen : MonoBehaviour {
  4.     //在外部拖拽图片绑定用public
  5.     publicTexturetex_menu_;    //添加背景图片
  6.     publicTexturetex_finger_;   // 添加手指图片
  7.     privateVector3[] current_pos_ = new Vector3[5];    //创建五个位置,为什么呢?因为只支持五个触摸点,呵~呵
  8.     privateint   touch_count_;   // 点击计数
  9.    
  10.     // Usethis for initialization
  11.     voidStart () {
  12.        //这里是初始化哦
  13.     }
  14.    
  15.     //Update is called once per frame
  16.     voidOnGUI () {
  17.        //这里是一直持续描绘
  18.       
  19.       GUI.DrawTexture( new Rect(0,0,640,960),tex_menu_);   // 描绘背景贴图
  20.       
  21.        // 保护后庭
  22.        if(touch_count_>0 )
  23.        {
  24.           for( int i=0; i
  25.           {
  26.             GUI.DrawTexture(new Rect(current_pos_[i].x, 960 -current_pos_[i].y, 106, 106), tex_finger_);
  27.           }
  28.        }
  29.     }
  30.     voidUpdate()
  31.     {
  32.        //这里是一直持续更新
  33.       if(Input.GetMouseButtonDown(0))
  34.        {
  35.           ++touch_count_;
  36.          current_pos_[touch_count_-1] = Input.mousePosition;
  37.        }
  38.     }
  39. }

同时把这个文件拖拽至Main Camera,然后把准备好的背景图和按钮图与public Texturetex_menu_、public Texture tex_finger_链接起来,build and run看看效果把,只有点击机会哦!
0 0
原创粉丝点击