冯乐乐的《Unity Shader入门精要》附带项目,其中部分shader已经修改测试
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

3 years ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChariotEditorCamera : MonoBehaviour {
public float maxRotateVertical = 30;
//public float maxRotateHorizontal = 180;
public float speed;
private bool isCameraRotate;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update()
{
float CameraV = Input.GetAxis("Vertical");
float CameraH = Input.GetAxis("Horizontal");
float CameraZ = Input.GetAxis("Mouse ScrollWheel");
if (transform.GetChild(0)) {
transform.GetChild(0).localPosition += new Vector3(0,0,CameraZ);
}
if (Input.GetButtonDown("Scroll Button")) {
isCameraRotate = true;
}else if (Input.GetButtonUp("Scroll Button")) {
isCameraRotate = false;
}
if (isCameraRotate) {
CameraV = Input.GetAxis("Mouse Y");
CameraH = -Input.GetAxis("Mouse X");
}
if (transform.localEulerAngles.x + CameraV <= maxRotateVertical || transform.localEulerAngles.x + CameraV >= 360 - maxRotateVertical)
{
transform.localEulerAngles += new Vector3(CameraV, CameraH, 0) * speed;
}
}
}