更新错误的预制体
This commit is contained in:
72
Convention/[Runtime]/Camera/FreeSceneCamera.cs
Normal file
72
Convention/[Runtime]/Camera/FreeSceneCamera.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cinemachine;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Convention
|
||||
{
|
||||
public class FreeSceneCamera : MonoSingleton<FreeSceneCamera>, ILoadedInHierarchy
|
||||
{
|
||||
[Resources, InspectorDraw(InspectorDrawType.Reference)] public Transform TargetFollow;
|
||||
//[Resources, InspectorDraw(InspectorDrawType.Reference)] public CinemachineVirtualCamera VirtualCamera;
|
||||
[Setting, InspectorDraw(InspectorDrawType.Text)] public float moveSpeed = 1;
|
||||
[Setting, InspectorDraw(InspectorDrawType.Text)] public float rotationSpeed = 1;
|
||||
private bool m_IsFocus = false;
|
||||
[Setting, InspectorDraw(InspectorDrawType.Toggle)]
|
||||
public bool isFocus
|
||||
{
|
||||
get => m_IsFocus;
|
||||
set
|
||||
{
|
||||
if (m_IsFocus != value)
|
||||
{
|
||||
m_IsFocus = value;
|
||||
Cursor.lockState = m_IsFocus ? CursorLockMode.Locked : CursorLockMode.None;
|
||||
Cursor.visible = !m_IsFocus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_IsFocus = false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Vector3 dxyz = Vector3.zero;
|
||||
Vector3 rxyz = Vector3.zero;
|
||||
if (Keyboard.current[Key.W].isPressed || Keyboard.current[Key.UpArrow].isPressed)
|
||||
dxyz += TargetFollow.forward;
|
||||
if (Keyboard.current[Key.A].isPressed || Keyboard.current[Key.LeftArrow].isPressed)
|
||||
dxyz += -TargetFollow.right;
|
||||
if (Keyboard.current[Key.D].isPressed || Keyboard.current[Key.RightArrow].isPressed)
|
||||
dxyz += TargetFollow.right;
|
||||
if (Keyboard.current[Key.S].isPressed || Keyboard.current[Key.DownArrow].isPressed)
|
||||
dxyz += -TargetFollow.forward;
|
||||
if (Keyboard.current[Key.Space].isPressed)
|
||||
dxyz += TargetFollow.up;
|
||||
if (Keyboard.current[Key.LeftShift].isPressed)
|
||||
dxyz += -TargetFollow.up;
|
||||
|
||||
var drotation = Vector3.zero;
|
||||
if (isFocus)
|
||||
{
|
||||
var temp = Mouse.current.delta.ReadValue();
|
||||
drotation = new(-temp.y, temp.x, 0);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
TargetFollow.Translate(dxyz * moveSpeed, Space.Self);
|
||||
TargetFollow.Rotate(drotation * rotationSpeed, Space.Self);
|
||||
|
||||
//
|
||||
|
||||
if (Keyboard.current[Key.Escape].isPressed)
|
||||
isFocus = false;
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[Runtime]/Camera/FreeSceneCamera.cs.meta
Normal file
11
Convention/[Runtime]/Camera/FreeSceneCamera.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8a335d6894daac4c980d4519ab1e3ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user