增加场景自动从main启动
增加相机QE移动
This commit is contained in:
parent
91cfd1738e
commit
4e911ce005
17
Assets/Scripts/Editor/OpeanCustomScene.cs
Normal file
17
Assets/Scripts/Editor/OpeanCustomScene.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
public class OpeanCustomScene : MonoBehaviour
|
||||||
|
{
|
||||||
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||||
|
private static void Initialize()
|
||||||
|
{
|
||||||
|
Scene scene = SceneManager.GetActiveScene();
|
||||||
|
if (!scene.name.Equals("Main"))
|
||||||
|
{
|
||||||
|
SceneManager.LoadScene("Main");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/Editor/OpeanCustomScene.cs.meta
Normal file
11
Assets/Scripts/Editor/OpeanCustomScene.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 671e7429ed8534e44b87ad20e1b7f70b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -30,6 +30,24 @@ public class FreeCameraController : MonoBehaviour
|
|||||||
|
|
||||||
Global.appSetting.MouseMoveSpeed.RegisterWithInitValue(v => rotateSpeed = v);
|
Global.appSetting.MouseMoveSpeed.RegisterWithInitValue(v => rotateSpeed = v);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 添加相机QE上下移动功能
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Vector3 GetInputTranslationDirection()
|
||||||
|
{
|
||||||
|
Vector3 direction = new Vector3();
|
||||||
|
|
||||||
|
if ( Input.GetKey(KeyCode.Q))
|
||||||
|
{
|
||||||
|
direction += Vector3.up;
|
||||||
|
}
|
||||||
|
if ( Input.GetKey(KeyCode.E))
|
||||||
|
{
|
||||||
|
direction += Vector3.down;
|
||||||
|
}
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
@ -40,7 +58,11 @@ public class FreeCameraController : MonoBehaviour
|
|||||||
float vertical = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;
|
float vertical = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;
|
||||||
|
|
||||||
Vector3 move = transform.right * horizontal + transform.forward * vertical;
|
Vector3 move = transform.right * horizontal + transform.forward * vertical;
|
||||||
|
|
||||||
transform.position += move;
|
transform.position += move;
|
||||||
|
//添加相机QE上下移动功能
|
||||||
|
transform.position+= GetInputTranslationDirection()*0.01f;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (isRot)
|
if (isRot)
|
||||||
{
|
{
|
||||||
@ -51,6 +73,9 @@ public class FreeCameraController : MonoBehaviour
|
|||||||
SyncRotation();
|
SyncRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (Input.GetMouseButtonUp(1))
|
if (Input.GetMouseButtonUp(1))
|
||||||
{
|
{
|
||||||
isDragging = false;
|
isDragging = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user