no message

This commit is contained in:
PC-20230316NUNE\Administrator
2024-02-20 18:39:12 +08:00
parent 97b3671979
commit 2b467e56ad
1876 changed files with 440340 additions and 35266 deletions

View File

@@ -0,0 +1,85 @@
using UnityEngine;
namespace HPJ.Examples
{
/// <summary>
/// A Example Camera Controller for the example scenes
/// </summary>
public class CameraController : MonoBehaviour
{
public float lookSpeed = 5f;
public float moveSpeed = 5f;
public float sprintSpeedMultiplier = 2f;
public float elevationSpeed = 3f;
public bool LockCurser = true;
public bool UseLockCommands = true;
private float rotationX = 0f;
private float rotationY = 0f;
private void Awake()
{
Application.targetFrameRate = 300;
}
void Start()
{
if (LockCurser)
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
rotationX = transform.rotation.eulerAngles.x;
rotationY = transform.parent.rotation.eulerAngles.y;
}
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * lookSpeed;
float mouseY = -Input.GetAxis("Mouse Y") * lookSpeed;
if (!Input.GetKey(KeyCode.LeftControl))
{
rotationX += mouseY;
rotationY += mouseX;
rotationX = Mathf.Clamp(rotationX, -90f, 90f);
transform.localRotation = Quaternion.Euler(rotationX, 0f, 0f);
transform.parent.localRotation = Quaternion.Euler(0f, rotationY, 0f);
}
Vector3 moveInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical"));
if (moveInput.magnitude > 0f)
{
moveInput = Quaternion.Euler(0f, rotationY, 0f) * moveInput;
moveInput.Normalize();
float speedMultiplier = Input.GetKey(KeyCode.LeftShift) ? sprintSpeedMultiplier : 1f;
transform.parent.position += moveInput * moveSpeed * speedMultiplier * Time.deltaTime;
}
if (Input.GetKey(KeyCode.Q))
{
transform.parent.position += Vector3.up * elevationSpeed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.E))
{
transform.parent.position -= Vector3.up * elevationSpeed * Time.deltaTime;
}
if (Input.GetKeyDown(KeyCode.Escape) && UseLockCommands)
{
if (Cursor.lockState == CursorLockMode.None)
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
else
{
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
}
}
}
}

View File

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

View File

@@ -0,0 +1,40 @@
using UnityEngine;
namespace HPJ.Examples
{
/// <summary>
/// An Example Script to ping pong an object between 2 points
/// </summary>
public class ObstaclePingPong : MonoBehaviour
{
public Transform startPoint;
public Transform endPoint;
public float speed = 5.0f;
[Range(0, 1)]
public float startingPercent = 0;
public bool ReverseDirection = false;
private float pingPongTime = 0.0f;
private void Start()
{
if (ReverseDirection)
{
startingPercent = 2 - startingPercent;
}
pingPongTime = startingPercent;
}
private void OnValidate()
{
transform.position = Vector3.Lerp(startPoint.position, endPoint.position, startingPercent);
}
void Update()
{
pingPongTime += Time.deltaTime * speed;
float pingPongValue = Mathf.PingPong(pingPongTime, 1.0f);
transform.position = Vector3.Lerp(startPoint.position, endPoint.position, pingPongValue);
}
}
}

View File

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

View File

@@ -0,0 +1,28 @@
using UnityEngine;
namespace HPJ.Examples
{
/// <summary>
/// An example script that rotates a object over time
/// </summary>
public class Rotate : MonoBehaviour
{
public float RotationSpeed = 5;
public Space RotationSpace = Space.World;
public Vector3 Rotation = new Vector3();
private Vector3 RotationVector = new Vector3();
private void Awake()
{
Rotation = Rotation.normalized;
RotationVector = Rotation * RotationSpeed;
}
// Update is called once per frame
void Update()
{
transform.Rotate(RotationVector * Time.deltaTime, RotationSpace);
}
}
}

View File

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

View File

@@ -0,0 +1,48 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.EventSystems;
namespace HPJ.Examples
{
public class SceneLoader : MonoBehaviour
{
private void Update()
{
if (EventSystem.current.currentSelectedGameObject != null)
{
return;
}
if (Input.GetKeyDown(KeyCode.KeypadMinus))
{
LoadPreviousScene();
}
else if (Input.GetKeyDown(KeyCode.KeypadPlus))
{
LoadNextScene();
}
}
public void LoadNextScene()
{
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
int nextSceneIndex = currentSceneIndex + 1;
if (nextSceneIndex == SceneManager.sceneCountInBuildSettings)
{
nextSceneIndex = 0;
}
SceneManager.LoadScene(nextSceneIndex);
}
public void LoadPreviousScene()
{
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
int previousSceneIndex = currentSceneIndex - 1;
if (previousSceneIndex < 0)
{
previousSceneIndex = SceneManager.sceneCountInBuildSettings - 1;
}
SceneManager.LoadScene(previousSceneIndex);
}
}
}

View File

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