随笔一

1.针旋转
GameObject a(针) Vector3 b(欧拉角)

~b=Camera.main.transform.eulerAngles;
~float c = b.y;
~Quaternion Qua = Quaternior.Euler((float)0,(float)0,c);
~a.transform.rotation = Qua;

2.游戏暂停开始

Time.timeScale = 0;暂停
Time.timeScale = 1;开始
注意:游戏暂停,但是动画不停(飞机头转动的时候(.time.deltaTime))

3.两个对象之间连线
(对象a,对象b)
用控件Line Renderer

 private LineRenderer line;
 private Transform c;

 line = GetComponent<LineRenderer>();
        line.SetPosition(0,transform.position);
        if (c!=null)
        {
            line.SetPosition(1,c.position);
        }

4.摄像机拖拽(平移,旋转)(right–x轴,up–y轴,forward–z轴)


        float _offset = Input.GetAxis("Mouse ScrollWheel");
        transform.Translate(Vector3.forward * 70 * _offset, Space.Self);
        if (Input.GetMouseButton(1))
        {//旋转
            float _offsetx = Input.GetAxis("Mouse X");
            float _offsety = Input.GetAxis("Mouse Y");
            transform.Rotate(Vector3.up, _offsetx * 70);
            transform.Rotate(Vector3.right, _offsety * 70);
            //保证旋转的时候z轴不转
            Vector3 _eular = transform.eulerAngles;
            Quaternion qua = Quaternion.Euler(_eular.x, _eular.y, (float)0);
            this.transform.rotation = qua;
        }
            if (Input.GetMouseButton(2))
            {//平移
                float _offsetx = Input.GetAxis("Mouse X");
                float _offsety = Input.GetAxis("Mouse Y");
            transform.Translate(Vector3.up*70*_offsetx*-1,Space.Self);
            transform.Translate(Vector3.up * 70 * _offsety * -1, Space.Self);
        }

5.调用其它脚本的函数

i被调用的脚本函数为static类型 脚本名.函数名()
ii GameObject.Find(“脚本所在物体名”).SendMessage(“函数名”);
iii GameObject.Find(“脚本所在物体名”).GetComponent<脚本名>().函数名();—–只能调用Public类型的函数

6.截取小数点后2位 ToString(“f2”);

7.获取系统时间
DateTime.Now.ToLocalTime().Hour
DateTime.Now.ToLocalTime().Minute

8组合键

ctrl  + A为例
    if (Input.GetKey(KeyCode.LeftControl))
        {
            if (Input.GetKeyDown(KeyCode.A))
            {

            }
        }

9全屏显示
退出全屏 Screen.fullScreen = false;
全屏显示 Screen.SetResolution(1920,1080,true);

10.禁用脚本
点一下禁用,点两下启用
a.enabled = !a.enabled;
点一下消失,点两下显示
a.SetActive(!a.activeSelf);

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值