Blogger Information
Blog 95
fans 0
comment 11
visits 248625
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
GUI管理 鼠标左键点击界面方向键,摄像机移动移动
龍__遇见彩虹的博客
Original
978 people have browsed it
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;
    }
}


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post