Android Unity3D游戏开发之切割方块

时间:2014-11-30 09:14:37
【文件属性】:

文件名称: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) { }


网友评论

  • 觉得挺不错啊 很有用
  • 可能是版本不匹配的原因,总是出错
  • 可能是版本不匹配的原因,总是出错
  • 代码写的不错,学习了!
  • 代码写的不错,谢谢楼主分享,学习了!
  • 代码写的不错,谢谢楼主分享,学习了!
  • 不知道是不是我的原因,没能运行……