Unity3d基础学习第5天

1.相机Camera

在这里插入图片描述
1.Clear Flags 清除标志

1.Skybox默认天空盒,在超出相机范围显示天空
2.Solid Color 单色纯色
3.Depth only 只通过深度
4.Don’t Clear 不清除

2.Background 当clear Flags 选择solid Color时,填充天空背景颜色
3.Culling mask 剔除遮罩 可以选择相机看到的物品
4.Projection 投射 分为Perspective透视(区分远近) 和Orthographic正交(不区分前后)
5.Field of View 视野
6.Clipping Planes Near 和 Far
7.Viewport Rect 相机在屏幕的位置和大小,左下角为x,y(0,0),右上角(w ,h);
8.Depth 深度
9.Rendering Path 渲染路径
10.Target Texture 目标纹理。用于制作头像和小地图
11. occlusion culling遮挡剔除

2.天空盒 Skybox

1.在菜单栏选择Window - Lighting, 此种方法使同一场景多个摄像机共同渲染一个天空盒
在这里插入图片描述
2.为总Camera摄像机单独添加天空盒组件

3.虚拟摇杆 EasyTouch

快速开发触屏和鼠标的行为动作

  1. 给英雄添加移动脚本,拖拽New joystick,并修改其interaction type为Direct and event
    public float speed = 3;
	public EasyJoystick _joystick;  //创建摇杆对象
    void Update ()
	{
		float x = _joystick.JoystickTouch.x;
		float y = _joystick.JoystickTouch.y;       //控制角色正面朝向,本身位置加摇杆即可
		transform.LookAt (transform.position + new Vector3(x,0,y));  
		if (x !=0 || y!=0)
		{  //transform.Translate (Vector3.forward * speed * Time.deltaTime);
			 transform.Translate (new Vector3 (0,0,speed*Time.deltaTime));
			 GetComponent<Animation> ().CrossFade ("Run");
		} else {
			GetComponent<Animation> ().CrossFade ("idle");
		}
	}
  1. 通过拖动摇杆,触发事件,调用事件中的方法
    public float speed = 3f;
	//只要拖动摇杆,触发事件,调用事件中的方法
	void OnEnable() //当脚本激活后运行该方法,在start之前调用
	{
		EasyJoystick.On_JoystickMoveStart +=moveStart;
		EasyJoystick.On_JoystickMove +=moving;
		EasyJoystick.On_JoystickMoveEnd += moveEnd;
	}
	void moveStart (MovingJoystick move)
	{
	     
	}
	void moving (MovingJoystick move)
	{
    //  float x = move.joystick.JoystickTouch.x;
    //	float y = move.joystick.JoystickTouch.y;

		float x = move.joystickAxis.x;
		float y = move.joystickAxis.y;
		transform.LookAt (transform.position + new Vector3 (x, 0, y));
		if (x!= 0 || y!= 0) {
			transform.Translate (Vector3.forward * speed * Time.deltaTime);
			GetComponent<Animation> ().CrossFade ("Run");
		}
	}
	void moveEnd (MovingJoystick move) 
	{
		GetComponent<Animation> ().CrossFade ("idle");
	}
	void OnDisable()  //脚本变为不活跃状态
	{
		EasyJoystick.On_JoystickMoveStart -=moveStart;
		EasyJoystick.On_JoystickMove -=moving;
		EasyJoystick.On_JoystickMoveEnd -= moveEnd;
	}
	void OnDestroy()
	{
		EasyJoystick.On_JoystickMoveStart -=moveStart;
		EasyJoystick.On_JoystickMove -=moving;
		EasyJoystick.On_JoystickMoveEnd -= moveEnd;
	}

4.虚拟按钮

打对勾,给Receiver object 添加对象,给方法添加名字,最后给英雄添加按钮脚本
在这里插入图片描述

    public class Cherobutton : MonoBehaviour 
    {  void Press(string buttonname) //可以带参,为按钮的名字
	  { Debug.Log ("ttttttt");	}
    }

猜你喜欢

转载自blog.csdn.net/JingDuiTell/article/details/88787983
今日推荐