Unity初探之黑暗之光(1)

Unity初探之黑暗之光(1)

1.镜头拉近

  

 1     public float speed=10f;//镜头的移动速度
 2     public int endZ = -20;//镜头的结束位置
 3     
 4     // Update is called once per frame
 5     void Update () {
 6         if (transform.position.z<endZ)
 7         {
 8             transform.Translate(Vector3.forward * speed * Time.deltaTime);
 9         }
10         
11     }

Transform.Translate 平移

function Translate (translation : Vector3, relativeTo : Space = Space.Self) : void

Description描述

Moves the transform in the direction and distance of translation.

移动transform在translation的方向和距离。

简单的说,向某方向移动物体多少距离。

If relativeTo is left out or set to Space.Self the movement is applied relative to the transform's local axes. (the x, y and z axes shown when selecting the object inside the Scene View.) If relativeTo is Space.World the movement is applied relative to the world coordinate system.

如果relativeTo留空或者设置为Space.Self,移动被应用相对于变换的自身轴。(当在场景视图选择物体时,x、y和z轴显示)如果相对于Space.World 移动被应用相对于世界坐标系统。


2.NGUI的使用

 在unity中使用NGUI插件时要注意插件是否与当前版本的unity兼容。NGUI可方便的让我们自己向unity中添加想要使用的工具栏。

我们可以直接在scene视图中通过右击来向UI中添加相应的元素,并为其添加相应的属性。其中的Tween中我们可以为相应的游戏UI元素添加特效动画。比如随时间的变化图像的透明度发生改变。而Widget则可以创建一个容器,Attach可以为按钮添加BoxConllider。

            

其中Duration为动画的持续时间,Start delay为延迟执行时间。图中的设置为将该脚本对应的元素的透明度2秒后经过1秒从0%变为1%。


 

3.为NGUI元素添加声音

  向NGUI元素添加声音我们需要通过添加Palyer Sound组件来完成。


4.使用NGUI创建图集

  在第二部中只需要在资源中选择想要添加的图片就好,然后点击生成或更新来创建或更新图集。

       

转载于:https://www.cnblogs.com/Firepad-magic/p/unity.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值