您的位置:首页 > 其它

U3D 随笔

2013-08-14 17:00 197 查看
http://unity3d.com/ 资源站

http://docs.unity3d.com/Documentation/ScriptReference/index.html 最新API

new Rect(100f/1024*Screen.width, 160f/768*Screen.height, 800, 580) 格式化分辨率(不靠谱。以后可以用插件)

public enum Menu
{start=1, option, help, quite}

//枚举 可以规定起始值 默认为0(Menu option_t = Menu.option ; option_t.GetHashCode()=2)

Vector2(2维向量)

Vector2 center = new Vector2(Screen.width/2f, Screen.height/2f) ;//移到屏幕中心

Time.time(当前时间)

Texture2D(二维纹理)

Vector2 mousePos = new Vector2(Input.mousePosition.x, Screen.height-Input.mousePosition.y) ;//坐标系转换为GUI坐标系(左上0,0)
angle = Mathf.Atan2(center.x-mousePos.x, mousePos.y-center.y)*Mathf.Rad2Deg ;//获得当前角度

Update控制播放速度和物体朝向

void Update () {
  if(Time.time>lasttime+stepTime){
    cnt = (cnt + 1)%10 ;
    lasttime = Time.time ;
  }
  Vector2 mousePos = new Vector2(Input.mousePosition.x, Screen.height-Input.mousePosition.y) ;
  angle = Mathf.Atan2(center.x-mousePos.x, mousePos.y-center.y)*Mathf.Rad2Deg ;//获得当前角度
  // if(Input.GetMouseButton(0)){
  // StartCoroutine(playMove(mousePos)) ;
  // }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: