using UnityEngine; using System.Collections; using UnityEngine.UI; /* * GUI管理 * 鼠标左键点击界面方向键,摄像机移动移动 */ public class GUIManager : MonoBehaviour { //前后左右移动 private float moveSpeed = 200; public GameObject startPosition; private bool isTop = false; private bool isDown = false; private bool isLeft = false; private bool isRight = false; public void toTop() { isTop = true; } public void toDown() { isDown = true; } public void toLeft() { isLeft = true; } public void toRight() { isRight = true; } private void FixedUpdate() { if (isTop) { //Debug.Log("to top"); startPosition.transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime); } if (isDown) { //Debug.Log("to down"); startPosition.transform.Translate((-Vector3.forward) * moveSpeed * Time.deltaTime); } if (isLeft) { //Debug.Log("to left"); startPosition.transform.Translate((-Vector3.right) * moveSpeed * Time.deltaTime); } if (isRight) { //Debug.Log("to right"); startPosition.transform.Translate(Vector3.right * moveSpeed * Time.deltaTime); } isTop = false; isDown = false; isLeft = false; isRight = false; } }