文件名称:Android Unity3D游戏开发之切割方块
文件大小:393KB
文件格式:RAR
更新时间:2014-11-30 09:14:37
Android Unity3D游戏开发
var target1 : Transform; var target1C : Transform; var target2 : Transform; var target2C : Transform; var mousePos1 : Vector3; var mousePos2 : Vector3; var cursorImage : Texture; var Mouse : GUISkin; private var MouseImg : boolean = false; function Update() { if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { if(Input.touchCount == 1) { mousePos1 = Input.touches[0].position; } else if(Input.touchCount == 2) { mousePos1 = Input.touches[0].position; mousePos2 = Input.touches[1].position; } } else { mousePos1 = Input.mousePosition; } target1.position = camera.ScreenToWorldPoint (Vector3(mousePos1.x,mousePos1.y,1)); target2.position = camera.ScreenToWorldPoint (Vector3(mousePos2.x,mousePos2.y,1)); } function LateUpdate() { if(Input.GetKey(KeyCode.Escape)) { Application.Quit(); } } function OnGUI() { if(MouseImg) { GUI.skin = Mouse; var windowRect : Rect = Rect (mousePos1.x - cursorImage.width/2, Screen.height - mousePos1.y - cursorImage.height/2, cursorImage.width, cursorImage.height); windowRect = GUI.Window (0, windowRect, DoMyWindow, "My Window"); } if(GUILayout.Button("PlanA")) { Screen.showCursor = !Screen.showCursor; target1.gameObject.active = !target1.gameObject.active; target1C.gameObject.active = target1.gameObject.active; if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { target2.gameObject.active = !target2.gameObject.active; target2C.gameObject.active = target2.gameObject.active; } } else if(GUILayout.Button("PlanB")) { Screen.showCursor = !Screen.showCursor; MouseImg = !MouseImg; } else if(GUILayout.Button("Restart")) { Application.LoadLevel(0); } if(GUI.Button(new Rect(Screen.width-120,Screen.height-40,120,30),"Click to YUHUA!")) { Application.OpenURL("http://blog.csdn.net/libeifs"); } GUI.color = Color.white; GUILayout.Label("fps:" + FPS.fps.ToString("f0") + " " + FPS.afps.ToString("f0")); } function DoMyWindow (windowID : int) { }