狗屎Minimax坏我代码
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace SickscoreGames.ExampleScene
|
||||
{
|
||||
public class ExampleBouncePrism : MonoBehaviour
|
||||
{
|
||||
#region Variables
|
||||
[Range(0f, 100f)]
|
||||
public float bounceSpeed = 3f;
|
||||
public float bounceHeight = .15f;
|
||||
private Vector3 _pos;
|
||||
#endregion
|
||||
|
||||
|
||||
#region Main Methods
|
||||
void Start ()
|
||||
{
|
||||
_pos = transform.position;
|
||||
}
|
||||
|
||||
|
||||
void Update ()
|
||||
{
|
||||
// bounce prism up & down
|
||||
if (bounceSpeed > 0f)
|
||||
{
|
||||
float newY = Mathf.Sin(Time.time * bounceSpeed) * bounceHeight + _pos.y;
|
||||
transform.position = new Vector3(transform.position.x, newY, transform.position.z);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72d3ef2e3d3e94bfabf28fa01d281665
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 103056
|
||||
packageName: HUD Navigation System
|
||||
packageVersion: 3.0.0
|
||||
assetPath: Assets/OtherPlugins/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleBouncePrism.cs
|
||||
uploadId: 884440
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SickscoreGames.ExampleScene
|
||||
{
|
||||
@@ -16,7 +14,7 @@ namespace SickscoreGames.ExampleScene
|
||||
|
||||
private Transform _transform;
|
||||
private Rigidbody _rigidbody;
|
||||
private bool isGrounded;
|
||||
private bool _isGrounded;
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -36,14 +34,18 @@ namespace SickscoreGames.ExampleScene
|
||||
void FixedUpdate ()
|
||||
{
|
||||
// check if grounded
|
||||
if (isGrounded) {
|
||||
if (_isGrounded) {
|
||||
// directional input
|
||||
Vector3 targetVelocity = new Vector3 (Input.GetAxis ("Horizontal"), 0f, Input.GetAxis ("Vertical"));
|
||||
float moveSpeed = (Input.GetKey (KeyCode.LeftShift)) ? runSpeed : walkSpeed;
|
||||
Vector3 targetVelocity = new Vector3 (ExampleUniversalInput.GetAxis("Horizontal"), 0f, ExampleUniversalInput.GetAxis ("Vertical"));
|
||||
float moveSpeed = (ExampleUniversalInput.GetKey (KeyCode.LeftShift)) ? runSpeed : walkSpeed;
|
||||
targetVelocity = _transform.TransformDirection (targetVelocity) * moveSpeed;
|
||||
|
||||
// calculate velocity and max velocity change
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
Vector3 velocity = _rigidbody.linearVelocity;
|
||||
#else
|
||||
Vector3 velocity = _rigidbody.velocity;
|
||||
#endif
|
||||
Vector3 velocityChange = (targetVelocity - velocity);
|
||||
velocityChange.x = Mathf.Clamp (velocityChange.x, -8f, 8f);
|
||||
velocityChange.z = Mathf.Clamp (velocityChange.z, -8f, 8f);
|
||||
@@ -51,14 +53,20 @@ namespace SickscoreGames.ExampleScene
|
||||
_rigidbody.AddForce (velocityChange, ForceMode.VelocityChange);
|
||||
|
||||
// jump input
|
||||
if (Input.GetKeyDown (KeyCode.Space))
|
||||
if (ExampleUniversalInput.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
_rigidbody.linearVelocity = new Vector3 (velocity.x, CalculateJumpVerticalSpeed (), velocity.z);
|
||||
#else
|
||||
_rigidbody.velocity = new Vector3 (velocity.x, CalculateJumpVerticalSpeed (), velocity.z);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// apply force to rigidbody
|
||||
_rigidbody.AddForce (new Vector3 (0f, -gravity * _rigidbody.mass, 0f));
|
||||
|
||||
isGrounded = false;
|
||||
_isGrounded = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -66,7 +74,7 @@ namespace SickscoreGames.ExampleScene
|
||||
#region Utility Methods
|
||||
void OnCollisionStay ()
|
||||
{
|
||||
isGrounded = true;
|
||||
_isGrounded = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 103056
|
||||
packageName: HUD Navigation System
|
||||
packageVersion: 2.2.0
|
||||
assetPath: Assets/Sickscore Games/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleController.cs
|
||||
uploadId: 382610
|
||||
packageVersion: 3.0.0
|
||||
assetPath: Assets/OtherPlugins/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleController.cs
|
||||
uploadId: 884440
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
using SickscoreGames.ExampleScene;
|
||||
using SickscoreGames.HUDNavigationSystem;
|
||||
using SickscoreGames.ExampleScene;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class ExampleInteractions : MonoBehaviour
|
||||
{
|
||||
@@ -16,6 +11,7 @@ public class ExampleInteractions : MonoBehaviour
|
||||
|
||||
private RaycastHit hit;
|
||||
private Transform pickupText;
|
||||
private Transform openDoorText;
|
||||
private Transform interactionText;
|
||||
private HUDNavigationSystem _HUDNavigationSystem;
|
||||
#endregion
|
||||
@@ -30,9 +26,17 @@ public class ExampleInteractions : MonoBehaviour
|
||||
|
||||
void Update ()
|
||||
{
|
||||
if (_HUDNavigationSystem == null)
|
||||
return;
|
||||
|
||||
HandleKeyInput ();
|
||||
HandleItemPickUp ();
|
||||
HandlePrismColorChange ();
|
||||
|
||||
if (_HUDNavigationSystem.isEnabled)
|
||||
{
|
||||
HandleItemPickUp ();
|
||||
HandleDoorOpening();
|
||||
HandlePrismColorChange ();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -41,78 +45,67 @@ public class ExampleInteractions : MonoBehaviour
|
||||
void HandleKeyInput ()
|
||||
{
|
||||
// update radar zoom / indicator border input
|
||||
if (Input.GetKey (KeyCode.X) && _HUDNavigationSystem.radarZoom < 5f)
|
||||
if (ExampleUniversalInput.GetKey (KeyCode.X) && _HUDNavigationSystem.radarZoom < 5f)
|
||||
_HUDNavigationSystem.radarZoom += .0175f;
|
||||
else if (Input.GetKey (KeyCode.C) && _HUDNavigationSystem.radarZoom > .25f)
|
||||
else if (ExampleUniversalInput.GetKey (KeyCode.C) && _HUDNavigationSystem.radarZoom > .25f)
|
||||
_HUDNavigationSystem.radarZoom -= .0175f;
|
||||
else if (Input.GetKey (KeyCode.V) && _HUDNavigationSystem.indicatorOffscreenBorder < .7f)
|
||||
else if (ExampleUniversalInput.GetKey (KeyCode.V) && _HUDNavigationSystem.indicatorOffscreenBorder < .7f)
|
||||
_HUDNavigationSystem.indicatorOffscreenBorder += .01f;
|
||||
else if (Input.GetKey (KeyCode.B) && _HUDNavigationSystem.indicatorOffscreenBorder > .07f)
|
||||
else if (ExampleUniversalInput.GetKey (KeyCode.B) && _HUDNavigationSystem.indicatorOffscreenBorder > .07f)
|
||||
_HUDNavigationSystem.indicatorOffscreenBorder -= .01f;
|
||||
else if (Input.GetKey (KeyCode.N) && _HUDNavigationSystem.minimapScale > .06f)
|
||||
else if (ExampleUniversalInput.GetKey (KeyCode.N) && _HUDNavigationSystem.minimapScale > .06f)
|
||||
_HUDNavigationSystem.minimapScale -= .0075f;
|
||||
else if (Input.GetKey (KeyCode.M) && _HUDNavigationSystem.minimapScale < .35f)
|
||||
else if (ExampleUniversalInput.GetKey (KeyCode.M) && _HUDNavigationSystem.minimapScale < .35f)
|
||||
_HUDNavigationSystem.minimapScale += .0075f;
|
||||
|
||||
// update feature enable / disable input
|
||||
if (Input.GetKeyDown (KeyCode.H))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.H))
|
||||
_HUDNavigationSystem.EnableSystem (!_HUDNavigationSystem.isEnabled);
|
||||
if (Input.GetKeyDown (KeyCode.Alpha1))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha1))
|
||||
_HUDNavigationSystem.EnableRadar (!_HUDNavigationSystem.useRadar);
|
||||
if (Input.GetKeyDown (KeyCode.Alpha2))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha2))
|
||||
_HUDNavigationSystem.EnableCompassBar (!_HUDNavigationSystem.useCompassBar);
|
||||
if (Input.GetKeyDown (KeyCode.Alpha3))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha3))
|
||||
_HUDNavigationSystem.EnableIndicators (!_HUDNavigationSystem.useIndicators);
|
||||
if (Input.GetKeyDown (KeyCode.Alpha4))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha4))
|
||||
_HUDNavigationSystem.EnableMinimap (!_HUDNavigationSystem.useMinimap);
|
||||
|
||||
// toggle radar / minimap mode
|
||||
if (Input.GetKeyDown (KeyCode.Alpha5))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha5))
|
||||
_HUDNavigationSystem.radarMode = (_HUDNavigationSystem.radarMode == RadarModes.RotateRadar) ? RadarModes.RotatePlayer : RadarModes.RotateRadar;
|
||||
if (Input.GetKeyDown (KeyCode.Alpha6))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha6))
|
||||
_HUDNavigationSystem.minimapMode = (_HUDNavigationSystem.minimapMode == MinimapModes.RotateMinimap) ? MinimapModes.RotatePlayer : MinimapModes.RotateMinimap;
|
||||
|
||||
// toggle minimap custom layers
|
||||
if (Input.GetKeyDown (KeyCode.Alpha7) && _HUDNavigationSystem.currentMinimapProfile != null) {
|
||||
GameObject blackWhiteLayer = _HUDNavigationSystem.currentMinimapProfile.GetCustomLayer ("exampleLayer");
|
||||
if (blackWhiteLayer != null)
|
||||
blackWhiteLayer.SetActive (!blackWhiteLayer.activeSelf);
|
||||
}
|
||||
|
||||
// toggle day/night scene
|
||||
if (Input.GetKeyUp (KeyCode.Return)) {
|
||||
if (SceneManager.GetActiveScene ().buildIndex == 0)
|
||||
SceneManager.LoadScene (1);
|
||||
else
|
||||
SceneManager.LoadScene (0);
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.Alpha7) && _HUDNavigationSystem.currentMinimapProfile) {
|
||||
GameObject customLayer = _HUDNavigationSystem.currentMinimapProfile.GetCustomLayer ("exampleLayer");
|
||||
if (customLayer)
|
||||
customLayer.SetActive (!customLayer.activeSelf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HandleItemPickUp ()
|
||||
{
|
||||
if (!_HUDNavigationSystem.isEnabled)
|
||||
return;
|
||||
|
||||
// check for pickup items
|
||||
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), out hit, interactionDistance, layerMask) && hit.collider.name.Contains ("PickUp")) {
|
||||
// get HUD navigation element component
|
||||
HUDNavigationElement element = hit.collider.gameObject.GetComponent<HUDNavigationElement> ();
|
||||
if (element != null) {
|
||||
if (element) {
|
||||
// show pickup text
|
||||
if (element.Indicator != null) {
|
||||
if (element.Indicator) {
|
||||
pickupText = element.Indicator.GetCustomTransform ("pickupText");
|
||||
if (pickupText != null)
|
||||
if (pickupText)
|
||||
pickupText.gameObject.SetActive (true);
|
||||
}
|
||||
|
||||
// wait for interaction input and destroy gameobject
|
||||
if (Input.GetKeyDown (KeyCode.E))
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.E))
|
||||
Destroy (element.gameObject);
|
||||
}
|
||||
} else {
|
||||
// reset pickup text
|
||||
if (pickupText != null) {
|
||||
if (pickupText) {
|
||||
pickupText.gameObject.SetActive (false);
|
||||
pickupText = null;
|
||||
}
|
||||
@@ -120,25 +113,56 @@ public class ExampleInteractions : MonoBehaviour
|
||||
}
|
||||
|
||||
|
||||
void HandleDoorOpening ()
|
||||
{
|
||||
// check for door
|
||||
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), out hit, interactionDistance, layerMask) && hit.collider.name.Contains ("Door")) {
|
||||
// get HUD navigation element component
|
||||
HUDNavigationElement element = hit.collider.gameObject.GetComponent<HUDNavigationElement> ();
|
||||
if (element) {
|
||||
// show text
|
||||
if (element.Indicator) {
|
||||
openDoorText = element.Indicator.GetCustomTransform ("openDoorText");
|
||||
if (openDoorText)
|
||||
openDoorText.gameObject.SetActive (true);
|
||||
}
|
||||
|
||||
// wait for input and change scene
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.E))
|
||||
{
|
||||
// toggle SkyIsland / House scene
|
||||
if (SceneManager.GetActiveScene().buildIndex == 0)
|
||||
SceneManager.LoadScene(1);
|
||||
else
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// reset text
|
||||
if (openDoorText) {
|
||||
openDoorText.gameObject.SetActive (false);
|
||||
openDoorText = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HandlePrismColorChange ()
|
||||
{
|
||||
if (!_HUDNavigationSystem.isEnabled)
|
||||
return;
|
||||
|
||||
// check for colored prisms
|
||||
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), out hit, interactionDistance, layerMask) && hit.collider.name.Contains ("Prism")) {
|
||||
// get HUD navigation element component
|
||||
HUDNavigationElement element = hit.collider.gameObject.GetComponentInChildren<HUDNavigationElement> ();
|
||||
if (element != null) {
|
||||
if (element) {
|
||||
// show interaction text
|
||||
if (element.Indicator != null) {
|
||||
if (element.Indicator) {
|
||||
interactionText = element.Indicator.GetCustomTransform ("interactionText");
|
||||
if (interactionText != null)
|
||||
if (interactionText)
|
||||
interactionText.gameObject.SetActive (true);
|
||||
}
|
||||
|
||||
// wait for interaction input and change prism color
|
||||
if (Input.GetKeyDown (KeyCode.E)) {
|
||||
if (ExampleUniversalInput.GetKeyDown (KeyCode.E)) {
|
||||
// generate random color
|
||||
Color randomColor = Random.ColorHSV (0f, 1f, 1f, 1f, .5f, 1f);
|
||||
|
||||
@@ -148,7 +172,7 @@ public class ExampleInteractions : MonoBehaviour
|
||||
}
|
||||
} else {
|
||||
// reset interaction text
|
||||
if (interactionText != null) {
|
||||
if (interactionText) {
|
||||
interactionText.gameObject.SetActive (false);
|
||||
interactionText = null;
|
||||
}
|
||||
@@ -160,7 +184,7 @@ public class ExampleInteractions : MonoBehaviour
|
||||
{
|
||||
// get renderer from prism
|
||||
Renderer prismRenderer = element.transform.parent.GetComponent<Renderer> ();
|
||||
if (prismRenderer != null)
|
||||
if (prismRenderer)
|
||||
ChangePrismColor (element, prismRenderer.material.color);
|
||||
}
|
||||
|
||||
@@ -168,31 +192,31 @@ public class ExampleInteractions : MonoBehaviour
|
||||
static void ChangePrismColor (HUDNavigationElement element, Color elementColor)
|
||||
{
|
||||
// change radar color
|
||||
if (element.Radar != null)
|
||||
if (element.Radar)
|
||||
element.Radar.ChangeIconColor (elementColor);
|
||||
|
||||
// change compass bar color
|
||||
if (element.CompassBar != null)
|
||||
if (element.CompassBar)
|
||||
element.CompassBar.ChangeIconColor (elementColor);
|
||||
|
||||
// change indicator colors
|
||||
if (element.Indicator != null) {
|
||||
if (element.Indicator) {
|
||||
element.Indicator.ChangeIconColor (elementColor);
|
||||
element.Indicator.ChangeOffscreenIconColor (elementColor);
|
||||
}
|
||||
|
||||
// change minimap color
|
||||
if (element.Minimap != null)
|
||||
if (element.Minimap)
|
||||
element.Minimap.ChangeIconColor (elementColor);
|
||||
|
||||
// change prism material color
|
||||
Renderer prismRenderer = element.transform.parent.GetComponent<Renderer> ();
|
||||
if (prismRenderer != null)
|
||||
if (prismRenderer)
|
||||
prismRenderer.material.color = new Color (elementColor.r, elementColor.g, elementColor.b, prismRenderer.material.color.a);
|
||||
|
||||
// change prism light (Night Scene)
|
||||
// change prism light (if present)
|
||||
Light prismLight = element.transform.parent.gameObject.GetComponentInChildren<Light> ();
|
||||
if (prismLight != null)
|
||||
if (prismLight)
|
||||
prismLight.color = new Color (elementColor.r, elementColor.g, elementColor.b);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -15,6 +15,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 103056
|
||||
packageName: HUD Navigation System
|
||||
packageVersion: 2.2.0
|
||||
assetPath: Assets/Sickscore Games/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleInteractions.cs
|
||||
uploadId: 382610
|
||||
packageVersion: 3.0.0
|
||||
assetPath: Assets/OtherPlugins/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleInteractions.cs
|
||||
uploadId: 884440
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace SickscoreGames.ExampleScene
|
||||
{
|
||||
@@ -14,37 +15,52 @@ namespace SickscoreGames.ExampleScene
|
||||
public Vector2 rotationLimitsY = new Vector2 (-60f, 60f);
|
||||
public float rotationSmooth = 8f;
|
||||
|
||||
private Quaternion rotationOrigin;
|
||||
private float currentRotationX, currentRotationY = 0f;
|
||||
private Quaternion _rotationOrigin;
|
||||
private float _currentRotationX, _currentRotationY = 0f;
|
||||
#endregion
|
||||
|
||||
|
||||
#region Main Methods
|
||||
void Awake ()
|
||||
{
|
||||
rotationOrigin = transform.localRotation;
|
||||
_rotationOrigin = transform.localRotation;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
sensitivityX /= 4;
|
||||
sensitivityY /= 4;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Update ()
|
||||
{
|
||||
// get input
|
||||
float mouseX = Input.GetAxis ("Mouse X");
|
||||
float mouseY = Input.GetAxis ("Mouse Y");
|
||||
float mouseX = 0f;
|
||||
float mouseY = 0f;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
if (Mouse.current != null)
|
||||
{
|
||||
mouseX = Mouse.current.delta.x.ReadValue();
|
||||
mouseY = Mouse.current.delta.y.ReadValue();
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
mouseX = Input.GetAxis ("Mouse X");
|
||||
mouseY = Input.GetAxis ("Mouse Y");
|
||||
#endif
|
||||
|
||||
// calculate and apply rotations
|
||||
if (axes == RotationAxes.MouseX) {
|
||||
currentRotationX += mouseX * sensitivityX;
|
||||
currentRotationX = this.ClampAngle (currentRotationX, rotationLimitsX.x, rotationLimitsX.y);
|
||||
Quaternion rotationX = Quaternion.AngleAxis (currentRotationX, Vector3.up);
|
||||
transform.localRotation = Quaternion.Lerp (transform.localRotation, rotationOrigin * rotationX, rotationSmooth * Time.deltaTime);
|
||||
_currentRotationX += mouseX * sensitivityX;
|
||||
_currentRotationX = this.ClampAngle (_currentRotationX, rotationLimitsX.x, rotationLimitsX.y);
|
||||
Quaternion rotationX = Quaternion.AngleAxis (_currentRotationX, Vector3.up);
|
||||
transform.localRotation = Quaternion.Lerp (transform.localRotation, _rotationOrigin * rotationX, rotationSmooth * Time.deltaTime);
|
||||
} else {
|
||||
currentRotationY += mouseY * sensitivityY;
|
||||
currentRotationY = this.ClampAngle (currentRotationY, rotationLimitsY.x, rotationLimitsY.y);
|
||||
Quaternion rotationY = Quaternion.AngleAxis (-currentRotationY, Vector3.right);
|
||||
transform.localRotation = Quaternion.Lerp (transform.localRotation, rotationOrigin * rotationY, rotationSmooth * Time.deltaTime);
|
||||
_currentRotationY += mouseY * sensitivityY;
|
||||
_currentRotationY = this.ClampAngle (_currentRotationY, rotationLimitsY.x, rotationLimitsY.y);
|
||||
Quaternion rotationY = Quaternion.AngleAxis (-_currentRotationY, Vector3.right);
|
||||
transform.localRotation = Quaternion.Lerp (transform.localRotation, _rotationOrigin * rotationY, rotationSmooth * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 103056
|
||||
packageName: HUD Navigation System
|
||||
packageVersion: 2.2.0
|
||||
assetPath: Assets/Sickscore Games/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleMouseLook.cs
|
||||
uploadId: 382610
|
||||
packageVersion: 3.0.0
|
||||
assetPath: Assets/OtherPlugins/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleMouseLook.cs
|
||||
uploadId: 884440
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SickscoreGames.ExampleScene
|
||||
{
|
||||
@@ -21,7 +19,13 @@ namespace SickscoreGames.ExampleScene
|
||||
// reset velocity
|
||||
Rigidbody rBody = other.gameObject.GetComponent<Rigidbody> ();
|
||||
if (rBody != null)
|
||||
rBody.linearVelocity = other.transform.forward * 5f;
|
||||
{
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
rBody.linearVelocity = other.transform.forward * 5f;;
|
||||
#else
|
||||
rBody.velocity = other.transform.forward * 5f;;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -15,6 +15,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 103056
|
||||
packageName: HUD Navigation System
|
||||
packageVersion: 2.2.0
|
||||
assetPath: Assets/Sickscore Games/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleResetPlayer.cs
|
||||
uploadId: 382610
|
||||
packageVersion: 3.0.0
|
||||
assetPath: Assets/OtherPlugins/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleResetPlayer.cs
|
||||
uploadId: 884440
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using SickscoreGames.HUDNavigationSystem;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SickscoreGames.ExampleScene
|
||||
@@ -9,6 +8,7 @@ namespace SickscoreGames.ExampleScene
|
||||
#region Variables
|
||||
[Range(0f, 100f)]
|
||||
public float rotationSpeed = 75f;
|
||||
public Color32 initialColor = new Color(1f, .8f, 0f, .95f);
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -20,5 +20,34 @@ namespace SickscoreGames.ExampleScene
|
||||
transform.Rotate (0f, rotationSpeed * Time.deltaTime, 0f);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
public void SetInitialPrismColor (HUDNavigationElement element)
|
||||
{
|
||||
// change radar color
|
||||
if (element.Radar != null)
|
||||
element.Radar.ChangeIconColor(initialColor);
|
||||
|
||||
// change compass bar color
|
||||
if (element.CompassBar != null)
|
||||
element.CompassBar.ChangeIconColor(initialColor);
|
||||
|
||||
// change indicator colors
|
||||
if (element.Indicator != null)
|
||||
{
|
||||
element.Indicator.ChangeIconColor(initialColor);
|
||||
element.Indicator.ChangeOffscreenIconColor(initialColor);
|
||||
}
|
||||
|
||||
// change minimap color
|
||||
if (element.Minimap != null)
|
||||
element.Minimap.ChangeIconColor(initialColor);
|
||||
|
||||
// change prism material color
|
||||
Renderer prismRenderer = this.GetComponent<Renderer>();
|
||||
if (prismRenderer != null)
|
||||
prismRenderer.material.color = initialColor;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 103056
|
||||
packageName: HUD Navigation System
|
||||
packageVersion: 2.2.0
|
||||
assetPath: Assets/Sickscore Games/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleRotatePrism.cs
|
||||
uploadId: 382610
|
||||
packageVersion: 3.0.0
|
||||
assetPath: Assets/OtherPlugins/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleRotatePrism.cs
|
||||
uploadId: 884440
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace SickscoreGames.ExampleScene
|
||||
{
|
||||
public static class ExampleUniversalInput
|
||||
{
|
||||
static Dictionary<string, float> axisState = new Dictionary<string, float>();
|
||||
|
||||
public static float GetAxis(string axis)
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
float target = GetAxisRawNew(axis);
|
||||
#else
|
||||
float target = Input.GetAxisRaw(axis);
|
||||
#endif
|
||||
float current = axisState.TryGetValue(axis, out var v) ? v : 0f;
|
||||
current = Mathf.MoveTowards(current, target, 3f * Time.deltaTime);
|
||||
axisState[axis] = current;
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
public static bool GetKey(KeyCode key)
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
return GetKeyNew(key);
|
||||
#else
|
||||
return Input.GetKey(key);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool GetKeyDown(KeyCode key)
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
return GetKeyNew(key, true);
|
||||
#else
|
||||
return Input.GetKeyDown(key);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
static bool GetKeyNew(KeyCode key, bool downOnly = false)
|
||||
{
|
||||
var kb = Keyboard.current;
|
||||
if (kb == null) return false;
|
||||
|
||||
return key switch
|
||||
{
|
||||
KeyCode.Space => downOnly ? kb.spaceKey.wasPressedThisFrame : kb.spaceKey.isPressed,
|
||||
KeyCode.LeftShift => downOnly ? kb.leftShiftKey.wasPressedThisFrame : kb.leftShiftKey.isPressed,
|
||||
KeyCode.X => downOnly ? kb.xKey.wasPressedThisFrame : kb.xKey.isPressed,
|
||||
KeyCode.C => downOnly ? kb.cKey.wasPressedThisFrame : kb.cKey.isPressed,
|
||||
KeyCode.V => downOnly ? kb.vKey.wasPressedThisFrame : kb.vKey.isPressed,
|
||||
KeyCode.B => downOnly ? kb.bKey.wasPressedThisFrame : kb.bKey.isPressed,
|
||||
KeyCode.N => downOnly ? kb.nKey.wasPressedThisFrame : kb.nKey.isPressed,
|
||||
KeyCode.M => downOnly ? kb.mKey.wasPressedThisFrame : kb.mKey.isPressed,
|
||||
KeyCode.H => downOnly ? kb.hKey.wasPressedThisFrame : kb.hKey.isPressed,
|
||||
KeyCode.Alpha1 => downOnly ? kb.digit1Key.wasPressedThisFrame : kb.digit1Key.isPressed,
|
||||
KeyCode.Alpha2 => downOnly ? kb.digit2Key.wasPressedThisFrame : kb.digit2Key.isPressed,
|
||||
KeyCode.Alpha3 => downOnly ? kb.digit3Key.wasPressedThisFrame : kb.digit3Key.isPressed,
|
||||
KeyCode.Alpha4 => downOnly ? kb.digit4Key.wasPressedThisFrame : kb.digit4Key.isPressed,
|
||||
KeyCode.Alpha5 => downOnly ? kb.digit5Key.wasPressedThisFrame : kb.digit5Key.isPressed,
|
||||
KeyCode.Alpha6 => downOnly ? kb.digit6Key.wasPressedThisFrame : kb.digit6Key.isPressed,
|
||||
KeyCode.Alpha7 => downOnly ? kb.digit7Key.wasPressedThisFrame : kb.digit7Key.isPressed,
|
||||
KeyCode.E => downOnly ? kb.eKey.wasPressedThisFrame : kb.eKey.isPressed,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
static float GetAxisRawNew(string axis)
|
||||
{
|
||||
var k = Keyboard.current;
|
||||
if (k == null) return 0f;
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case "Horizontal":
|
||||
return (k.dKey.isPressed || k.rightArrowKey.isPressed ? 1 : 0) -
|
||||
(k.aKey.isPressed || k.leftArrowKey.isPressed ? 1 : 0);
|
||||
|
||||
case "Vertical":
|
||||
return (k.wKey.isPressed || k.upArrowKey.isPressed ? 1 : 0) -
|
||||
(k.sKey.isPressed || k.downArrowKey.isPressed ? 1 : 0);
|
||||
}
|
||||
|
||||
return 0f;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4ce55fbbb024284961c3401d8551713
|
||||
timeCreated: 1773655547
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 103056
|
||||
packageName: HUD Navigation System
|
||||
packageVersion: 3.0.0
|
||||
assetPath: Assets/OtherPlugins/HUD-Navigation-System/_Examples/ExampleScene/Scripts/ExampleUniversalInput.cs
|
||||
uploadId: 884440
|
||||
Reference in New Issue
Block a user