小彬彬 发表于 2012-8-11 11:38

Unity3D鼠标选中物品并拖动物品的方法

1.效果图

2.


代码:


var speed = 10;
function OnMouseDrag () {
transform.position += Vector3.right * Time.deltaTime*Input.GetAxis ("Mouse X") * speed;
transform.position += Vector3.forward * Time.deltaTime*Input.GetAxis ("Mouse Y")* speed;
}

在地平面上被托动

var speed = 10;
function OnMouseDrag () {
transform.position += Vector3.right * Time.deltaTime*Input.GetAxis ("Mouse X") * speed;
transform.position += Vector3.up * Time.deltaTime*Input.GetAxis ("Mouse Y")* speed;
}

在屏幕方向被托动

static var up : Vector3 (0, 1, 0)

static var right: Vector3 (1.0.0)

static var forward: Vector3 (0.0.1)


wai2dance 发表于 2012-11-26 22:08

支持啊谢谢分享
求哪位 大神能 出一个视频 细讲讲背包教学
网上 有一个 JavaScript的    求C#版本GUI物品栏教学啊
包含 物品栏提示属性
                  移动位置
                  移出物品栏   松开鼠标 丢弃
                  装备到   另外一个 GUI (例如从 物品栏拖到   人物装备栏装备 等等)

求哪位大神 出个教学谢谢

ss0102113 发表于 2013-5-26 22:45

Input.GetAxis("Mouse X")
Input.GetAxis("Mouse Y")
手都快摆酸了 一直返回0

引兔那么写 发表于 2017-4-7 07:57

楼主是超人

v75273278 发表于 2017-4-7 07:54

好帖就是要顶

tiaoshiok2 发表于 2017-4-7 08:32

难得一见的好帖

v75273278 发表于 2017-4-7 07:46

不错不错

/shd冬眠 发表于 2017-4-7 08:12

LZ真是人才

lionelcg 发表于 2017-6-3 20:19

很不错

hbszqf 发表于 2017-6-3 19:57

楼主是超人
页: [1]
查看完整版本: Unity3D鼠标选中物品并拖动物品的方法