1.修复了一些错误\n2.导入了URP的Sample

This commit is contained in:
2025-10-02 22:19:52 +08:00
parent a77faec0fa
commit 1ecb1b0ba4
558 changed files with 147322 additions and 39 deletions

View File

@@ -0,0 +1,57 @@
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
[ExecuteAlways]
public class AutoLoadPipelineAsset : MonoBehaviour
{
[SerializeField]
private UniversalRenderPipelineAsset m_PipelineAsset;
private RenderPipelineAsset m_PreviousPipelineAsset;
private bool m_overrodeQualitySettings;
void OnEnable()
{
UpdatePipeline();
}
void OnDisable()
{
ResetPipeline();
}
private void UpdatePipeline()
{
if (m_PipelineAsset)
{
if (QualitySettings.renderPipeline != null && QualitySettings.renderPipeline != m_PipelineAsset)
{
m_PreviousPipelineAsset = QualitySettings.renderPipeline;
QualitySettings.renderPipeline = m_PipelineAsset;
m_overrodeQualitySettings = true;
}
else if (GraphicsSettings.renderPipelineAsset != m_PipelineAsset)
{
m_PreviousPipelineAsset = GraphicsSettings.renderPipelineAsset;
GraphicsSettings.renderPipelineAsset = m_PipelineAsset;
m_overrodeQualitySettings = false;
}
}
}
private void ResetPipeline()
{
if (m_PreviousPipelineAsset)
{
if (m_overrodeQualitySettings)
{
QualitySettings.renderPipeline = m_PreviousPipelineAsset;
}
else
{
GraphicsSettings.renderPipelineAsset = m_PreviousPipelineAsset;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 21aa50131bc134f04a14efdbeb7686be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,84 @@
using UnityEngine;
using Cursor = UnityEngine.Cursor;
[RequireComponent(typeof(CharacterController))]
public class FirstPersonController : MonoBehaviour
{
[SerializeField]
private float m_MouseSensitivity = 100f;
[SerializeField]
private float m_MovementSpeed = 5f;
[SerializeField]
private Transform m_PlayerCamera = null;
[SerializeField]
private bool m_MoveWithMouse = true;
private CharacterController m_CharacterController;
private float m_XRotation = 0f;
[SerializeField]
private byte m_ButtonMovementFlags;
void Start()
{
#if ENABLE_INPUT_SYSTEM
Debug.Log("The FirstPersonController uses the legacy input system. Please set it in Project Settings");
m_MoveWithMouse = false;
#endif
if (m_MoveWithMouse)
{
Cursor.lockState = CursorLockMode.Locked;
}
m_CharacterController = GetComponent<CharacterController>();
}
void Update()
{
Look();
Move();
}
private void Look()
{
Vector2 lookInput = GetLookInput();
m_XRotation -= lookInput.y;
m_XRotation = Mathf.Clamp(m_XRotation, -90f, 90f);
m_PlayerCamera.localRotation = Quaternion.Euler(m_XRotation, 0, 0);
transform.Rotate(Vector3.up * lookInput.x, Space.World);
}
private void Move()
{
Vector3 movementInput = GetMovementInput();
Vector3 move = transform.right * movementInput.x + transform.forward * movementInput.z;
m_CharacterController.Move(move * m_MovementSpeed * Time.deltaTime);
}
private Vector2 GetLookInput()
{
float mouseX = 0;
float mouseY = 0;
if (m_MoveWithMouse)
{
mouseX = Input.GetAxis("Mouse X") * m_MouseSensitivity * Time.deltaTime;
mouseY = Input.GetAxis("Mouse Y") * m_MouseSensitivity * Time.deltaTime;
}
return new Vector2(mouseX, mouseY);
}
private Vector3 GetMovementInput()
{
float x = 0;
float z = 0;
if (m_MoveWithMouse)
{
x = Input.GetAxis("Horizontal");
z = Input.GetAxis("Vertical");
}
return new Vector3(x, 0, z);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 94f9f55b5897449c29f5189f47cad4bc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: