case3
This commit is contained in:
41
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/CamController.cs
vendored
Normal file
41
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/CamController.cs
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Boxophobic.Utility
|
||||
{
|
||||
public class CamController : MonoBehaviour
|
||||
{
|
||||
public float movementSpeed = 5f;
|
||||
public float accelerationMultiplier = 2f;
|
||||
public float sensitivity = 2f;
|
||||
|
||||
private float yaw = 0f;
|
||||
private float pitch = 0f;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Store the initial rotation of the camera
|
||||
yaw = transform.eulerAngles.y;
|
||||
pitch = transform.eulerAngles.x;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float currentSpeed = movementSpeed;
|
||||
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
|
||||
{
|
||||
currentSpeed *= accelerationMultiplier;
|
||||
}
|
||||
|
||||
float horizontalMovement = Input.GetAxis("Horizontal") * currentSpeed * Time.deltaTime;
|
||||
float verticalMovement = Input.GetAxis("Vertical") * currentSpeed * Time.deltaTime;
|
||||
|
||||
transform.Translate(horizontalMovement, 0, verticalMovement);
|
||||
|
||||
yaw += sensitivity * Input.GetAxis("Mouse X");
|
||||
pitch -= sensitivity * Input.GetAxis("Mouse Y");
|
||||
pitch = Mathf.Clamp(pitch, -90f, 90f);
|
||||
|
||||
transform.rotation = Quaternion.Euler(pitch, yaw, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/CamController.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/CamController.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 195d4c9b85f7ea146aac46a389a6f08f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
58
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/FPSController.cs
vendored
Normal file
58
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/FPSController.cs
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
//Stripped down version from https://sharpcoderblog.com/blog/unity-3d-fps-controller
|
||||
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Boxophobic.Utility
|
||||
{
|
||||
[RequireComponent(typeof(UnityEngine.CharacterController))]
|
||||
public class FPSController : MonoBehaviour
|
||||
{
|
||||
public float walkingSpeed = 2.0f;
|
||||
public float lookSpeed = 2.0f;
|
||||
public float lookXLimit = 45.0f;
|
||||
|
||||
[Space(10)]
|
||||
public GameObject playerCamera;
|
||||
|
||||
UnityEngine.CharacterController characterController;
|
||||
float rotationX = 0;
|
||||
|
||||
void Start()
|
||||
{
|
||||
characterController = GetComponent<UnityEngine.CharacterController>();
|
||||
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
var runSpeed = 1.0f;
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
runSpeed = 3.0f;
|
||||
}
|
||||
|
||||
Vector3 forward = transform.TransformDirection(Vector3.forward);
|
||||
Vector3 right = transform.TransformDirection(Vector3.right);
|
||||
Vector3 moveDirection = (forward * walkingSpeed * runSpeed * Input.GetAxis("Vertical")) + (right * walkingSpeed * runSpeed * Input.GetAxis("Horizontal"));
|
||||
|
||||
if (characterController.isGrounded == false)
|
||||
{
|
||||
moveDirection += Physics.gravity;
|
||||
}
|
||||
|
||||
characterController.Move(moveDirection * Time.deltaTime);
|
||||
|
||||
rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
|
||||
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
|
||||
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
|
||||
transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/FPSController.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/FPSController.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14dd81840028bd24ebee23af01e480fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/NPCController.cs
vendored
Normal file
34
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/NPCController.cs
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Boxophobic.Utility
|
||||
{
|
||||
public class NPCController : MonoBehaviour
|
||||
{
|
||||
private float timeToChangeDirection;
|
||||
Vector3 direction;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
ChangeDirection();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
timeToChangeDirection -= Time.deltaTime;
|
||||
|
||||
if (timeToChangeDirection <= 0)
|
||||
{
|
||||
ChangeDirection();
|
||||
}
|
||||
|
||||
transform.Translate(direction, Space.World);
|
||||
}
|
||||
|
||||
private void ChangeDirection()
|
||||
{
|
||||
var speed = Random.Range(0.005f, 0.01f);
|
||||
direction = new Vector3(Random.Range(-1f, 1f) * speed, 0, Random.Range(-1f, 1f) * speed);
|
||||
timeToChangeDirection = Random.Range(0.5f, 2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/NPCController.cs.meta
vendored
Normal file
11
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/NPCController.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb3be98ee36cd8b4f8710bbb0a16160b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
120
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/SceneSwitch.cs
vendored
Normal file
120
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/SceneSwitch.cs
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
// Cristian Pop - https://boxophobic.com/
|
||||
|
||||
using UnityEngine;
|
||||
using Boxophobic.StyledGUI;
|
||||
using UnityEngine.Rendering;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.SceneManagement;
|
||||
#endif
|
||||
|
||||
namespace Boxophobic.Utility
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class SceneSwitch : StyledMonoBehaviour
|
||||
{
|
||||
[StyledBanner("Switch")]
|
||||
public bool styledBanner;
|
||||
|
||||
public GameObject setupStandard;
|
||||
public GameObject setupUniversal;
|
||||
public GameObject setupHD;
|
||||
[HideInInspector]
|
||||
public GameObject objectStandard;
|
||||
[HideInInspector]
|
||||
public GameObject objectUniversal;
|
||||
[HideInInspector]
|
||||
public GameObject objectHD;
|
||||
|
||||
[Space(10)]
|
||||
public bool setRenderSettings;
|
||||
|
||||
[Space(10)]
|
||||
public Material skyboxMaterial;
|
||||
[Range(0, 8)]
|
||||
public float skyboxAmbient = 1;
|
||||
[Range(0, 1)]
|
||||
public float skyboxReflection = 1;
|
||||
|
||||
[StyledSpace(5)]
|
||||
public bool styledSpace;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int pipeline = 0;
|
||||
|
||||
if (GraphicsSettings.defaultRenderPipeline != null)
|
||||
{
|
||||
if (GraphicsSettings.defaultRenderPipeline.GetType().ToString().Contains("Universal"))
|
||||
{
|
||||
pipeline = 1;
|
||||
}
|
||||
|
||||
if (GraphicsSettings.defaultRenderPipeline.GetType().ToString().Contains("HD"))
|
||||
{
|
||||
pipeline = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (QualitySettings.renderPipeline != null)
|
||||
{
|
||||
if (QualitySettings.renderPipeline.GetType().ToString().Contains("Universal"))
|
||||
{
|
||||
pipeline = 1;
|
||||
}
|
||||
|
||||
if (QualitySettings.renderPipeline.GetType().ToString().Contains("HD"))
|
||||
{
|
||||
pipeline = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (pipeline == 0)
|
||||
{
|
||||
if (setupStandard != null && objectStandard == null)
|
||||
{
|
||||
objectStandard = Instantiate(setupStandard, gameObject.transform);
|
||||
objectStandard.name = objectStandard.name.Replace("(Clone)", "");
|
||||
}
|
||||
}
|
||||
|
||||
if (pipeline == 1)
|
||||
{
|
||||
if (setupUniversal != null && objectUniversal == null)
|
||||
{
|
||||
objectUniversal = Instantiate(setupUniversal, gameObject.transform);
|
||||
objectUniversal.name = objectUniversal.name.Replace("(Clone)", "");
|
||||
}
|
||||
}
|
||||
|
||||
if (pipeline == 2)
|
||||
{
|
||||
if (setupHD != null && objectHD == null)
|
||||
{
|
||||
objectHD = Instantiate(setupHD, gameObject.transform);
|
||||
objectHD.name = objectHD.name.Replace("(Clone)", "");
|
||||
}
|
||||
}
|
||||
|
||||
if (setRenderSettings)
|
||||
{
|
||||
RenderSettings.skybox = skyboxMaterial;
|
||||
RenderSettings.ambientIntensity = skyboxAmbient;
|
||||
RenderSettings.reflectionIntensity = skyboxReflection;
|
||||
|
||||
DynamicGI.UpdateEnvironment();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
14
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/SceneSwitch.cs.meta
vendored
Normal file
14
Assets/ThirdParty/BOXOPHOBIC/Utils/Scripts/Runtime/SceneSwitch.cs.meta
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f8925abba486f64284bccfcd3bd4bb6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- turbulenceTexture: {instanceID: 0}
|
||||
- arrowMesh: {fileID: 4300000, guid: f4cbcdade646b3b4098dfd993b9a6ec9, type: 3}
|
||||
- arrowMaterial: {fileID: 2100000, guid: a5093d3a1e3c2b44c9af26e965a12e62, type: 2}
|
||||
executionOrder: -123
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user