• 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创建图集

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

           

    点赞鼓励下,(づ ̄3 ̄)づ╭❤~

    作者:君莫笑
           出处:https://www.cnblogs.com/Firepad-magic/
           Unity最受欢迎插件推荐:点击查看
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    解决VMwave下卡死的办法
    深度探索C++对象模型第四章:函数语义学
    cc
    tbb库的使用
    10内核同步方法
    哈希
    django 和restful framework 初始配置轻松搞定
    linux有趣动画--代码雨
    linux有趣开机图标--佛祖保佑
    Socket是什么,通俗易懂点说
  • 原文地址:https://www.cnblogs.com/Firepad-magic/p/unity.html
Copyright © 2020-2023  润新知