2.给Button添加事件关联时,函数不能带有yield WaitForSeconds (waitTime);(js)必须使用协程
function OnMouseDown(waitTime:float) { yield WaitForSeconds (waitTime);} StartCoroutine(OnMouseDown(0.35));
3.Input.GetKey(KeyCode.Q))与Input.GetKeyDown(KeyCode.Escape)
4.Mathf.Lerp. lerp差值 transform.position.x = Mathf.Lerp(min:float,max:float,(Time.time - i:float)*speed);数学差值函数。
5.创建一个空物体如果他的Scale,x=0,y=0,那么这个物体的子物体改变子物体的position,他的位置也不会改变。
6.animation组件和animator组件的区别,,animator是动画状态机,animation是它子集。
7.animator的trigger变量。a.animator.settrigger("name");执行时为真,下一句自动为假。
8.状态树动画转换控制,,float h = Input.GetAxis("Horizontal"); float DirectionDampTime = 0.25; animator.SetFloat("Direction",h,DirectionDampTime,Time.deltaTime); 前跑,左跑,右跑转换。
9.截图功能:if(Input.GetKey(KeyCode.P)&&Input.GetKey(KeyCode.LeftControl)){Application.captureScreenshot("Screenshot.png");}
10.五种坐标系。c#中[DllImport("user32.dll")]
屏幕坐标和像素视口坐标Z值体现的是与摄像机中心距离的远近。
11.全屏。Screen.fullScreen = !Screen.fullScreen;
12.锁定鼠标。Screen.lockCursor = ture;
13.Switch to 800×600 windowed,切换到,,,,Screen.SetResolution(800,600,false),false代表非全屏。
14.var ScreenPos:Vector3 = camera.WorldToScreenPoint(cube.position);世界坐标转屏幕坐标。
15.var World:Vector3 = camera.ScreenToWorldPoint(Input.mousePosition);
16.var ViewportPos:Vector3 = camera.ScreenToViewportPoint(Input.mousePosition);
17.var World:Vector3 = camera.ViewportToWorldPoint(Vector3(0.5,0.5,0.4));
18.光线投射,从摄像机投到屏幕中心
var p1: Vector3 = new Vector3(-0.86,0.38,-2.05); Instantiate(sp,p1,transform.rotation); var ray: Ray = camera.ViewportPointToRay(Vector3(0.5,0.5,0)); var hit: RaycastHit; //发射光线 if (Physics.Raycast(ray,hit)){ wz.text = "I am looking at"+hit.transform.name;} else wz,text = "I am looking at noting";
19.小岛游戏存档功能使得charge数组指针超出了范围,但是游戏里没有体现具体的异常。