add some extra assets FX and SFX
This commit is contained in:
@@ -11,6 +11,10 @@ using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
#if REWIRED
|
||||
using Rewired;
|
||||
#endif
|
||||
@@ -223,6 +227,16 @@ public class inputManager : MonoBehaviour
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
if (useNewInputSystem) {
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
mainKeyboard = Keyboard.current;
|
||||
|
||||
InputAxisWrapper.InitializeMove (moveActionReference.action);
|
||||
|
||||
InputAxisWrapper.InitializeLook (lookActionReference.action);
|
||||
#endif
|
||||
}
|
||||
|
||||
getComponentInstance ();
|
||||
}
|
||||
|
||||
@@ -621,6 +635,11 @@ public class inputManager : MonoBehaviour
|
||||
editInputMenu = newPlayerInputManager.getEditInputMenu ();
|
||||
}
|
||||
|
||||
public bool isUseNewInputSystemActive ()
|
||||
{
|
||||
return useNewInputSystem;
|
||||
}
|
||||
|
||||
public bool isUsingGamepad ()
|
||||
{
|
||||
return usingGamepad;
|
||||
@@ -1207,11 +1226,11 @@ public class inputManager : MonoBehaviour
|
||||
temporalAxesList.Add (temporalMultiAxesList [i].axes [j]);
|
||||
}
|
||||
|
||||
// print (temporalMultiAxesList [i].axesName + " " + temporalMultiAxesList [i].multiAxesEditPanelActive);
|
||||
// print (temporalMultiAxesList [i].axesName + " " + temporalMultiAxesList [i].multiAxesEditPanelActive);
|
||||
|
||||
multiAxes newMultiAxes = new multiAxes (temporalMultiAxesList [i]);
|
||||
|
||||
// print (newMultiAxes.axesName + " " + newMultiAxes.multiAxesEditPanelActive);
|
||||
// print (newMultiAxes.axesName + " " + newMultiAxes.multiAxesEditPanelActive);
|
||||
|
||||
newMultiAxes.axesName = temporalMultiAxesList [i].axesName;
|
||||
|
||||
@@ -1757,6 +1776,127 @@ public class inputManager : MonoBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
|
||||
Dictionary<KeyCode, Key> keyCache = new Dictionary<KeyCode, Key> ();
|
||||
|
||||
Keyboard mainKeyboard;
|
||||
|
||||
|
||||
bool getKey (Key newKey)
|
||||
{
|
||||
return mainKeyboard [newKey].isPressed;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool getKey (KeyCode keyCode)
|
||||
{
|
||||
if (keyCode == KeyCode.None) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
if (!keyCache.TryGetValue (keyCode, out var key)) {
|
||||
if (!System.Enum.TryParse<Key> (keyCode.ToString (), out key))
|
||||
return false;
|
||||
|
||||
keyCache [keyCode] = key;
|
||||
}
|
||||
|
||||
if (mainKeyboard [key].isPressed) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool getKeyDown (KeyCode keyCode)
|
||||
{
|
||||
if (keyCode == KeyCode.None) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
if (!keyCache.TryGetValue (keyCode, out var key)) {
|
||||
if (!System.Enum.TryParse<Key> (keyCode.ToString (), out key))
|
||||
return false;
|
||||
|
||||
keyCache [keyCode] = key;
|
||||
}
|
||||
|
||||
if (mainKeyboard [key].wasPressedThisFrame) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool getKeyUp (KeyCode keyCode)
|
||||
{
|
||||
if (keyCode == KeyCode.None) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
if (!keyCache.TryGetValue (keyCode, out var key)) {
|
||||
if (!System.Enum.TryParse<Key> (keyCode.ToString (), out key))
|
||||
return false;
|
||||
|
||||
keyCache [keyCode] = key;
|
||||
}
|
||||
|
||||
if (mainKeyboard [key].wasReleasedThisFrame) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public string horizontalString = "Horizontal";
|
||||
public string verticalString = "Vertical";
|
||||
|
||||
public string mouseXString = "Mouse X";
|
||||
public string mouseYString = "Mouse Y";
|
||||
|
||||
public bool useNewInputSystem;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
public InputActionReference moveActionReference;
|
||||
public InputActionReference lookActionReference;
|
||||
#endif
|
||||
|
||||
public float newInputSystemKeyboardAxisSmoothSpeed = 5;
|
||||
|
||||
public Vector2 getKeyboardAxisInputValue ()
|
||||
{
|
||||
if (useNewInputSystem) {
|
||||
return InputAxisWrapper.GetMoveAxis (newInputSystemKeyboardAxisSmoothSpeed);
|
||||
} else {
|
||||
return new Vector2 (Input.GetAxis (horizontalString), Input.GetAxis (verticalString));
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 getKeyboardRawAxisInputValue ()
|
||||
{
|
||||
if (useNewInputSystem) {
|
||||
return InputAxisWrapper.GetMoveRawAxis ();
|
||||
} else {
|
||||
return new Vector2 (Input.GetAxisRaw (horizontalString), Input.GetAxisRaw (verticalString));
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 getMouseAxisInputValue ()
|
||||
{
|
||||
if (useNewInputSystem) {
|
||||
return InputAxisWrapper.GetLookAxis ();
|
||||
} else {
|
||||
return new Vector2 (Input.GetAxis (mouseXString), Input.GetAxis (mouseYString));
|
||||
}
|
||||
}
|
||||
|
||||
//function called in the script where pressing that button will make an action in the game, for example jump, crouch, shoot, etc...
|
||||
//every button sends its action and the type of pressing
|
||||
public bool getKeyboardButtonFromMultiAxesList (int multiAxesIndex, int axesIndex, buttonType type, bool canBeUsedOnPausedGame)
|
||||
@@ -1820,49 +1960,91 @@ public class inputManager : MonoBehaviour
|
||||
switch (type) {
|
||||
//this key is for holding
|
||||
case buttonType.getKey:
|
||||
if (Input.GetKey (currentKeyCodeToCheck)) {
|
||||
if (useNewInputSystem) {
|
||||
if (getKey (currentKeyCodeToCheck)) {
|
||||
if (showKeyboardPressed) {
|
||||
print ("Get Key: " + currentKeyButtonToCheck.keyButton);
|
||||
}
|
||||
|
||||
if (showKeyboardPressed) {
|
||||
print ("Get Key: " + currentKeyButtonToCheck.keyButton);
|
||||
if (showKeyboardPressedAction) {
|
||||
print ("Action Name On Key: " + currentKeyButtonToCheck.Name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (Input.GetKey (currentKeyCodeToCheck)) {
|
||||
|
||||
if (showKeyboardPressedAction) {
|
||||
print ("Action Name On Key: " + currentKeyButtonToCheck.Name);
|
||||
if (showKeyboardPressed) {
|
||||
print ("Get Key: " + currentKeyButtonToCheck.keyButton);
|
||||
}
|
||||
|
||||
if (showKeyboardPressedAction) {
|
||||
print ("Action Name On Key: " + currentKeyButtonToCheck.Name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
//this key is for press once
|
||||
case buttonType.getKeyDown:
|
||||
if (Input.GetKeyDown (currentKeyCodeToCheck)) {
|
||||
if (useNewInputSystem) {
|
||||
if (getKeyDown (currentKeyCodeToCheck)) {
|
||||
if (showKeyboardPressed) {
|
||||
print ("Get Key Down: " + currentKeyButtonToCheck.keyButton);
|
||||
}
|
||||
|
||||
if (showKeyboardPressed) {
|
||||
print ("Get Key Down: " + currentKeyButtonToCheck.keyButton);
|
||||
if (showKeyboardPressedAction) {
|
||||
print ("Action Name On Key Down: " + currentKeyButtonToCheck.Name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (Input.GetKeyDown (currentKeyCodeToCheck)) {
|
||||
|
||||
if (showKeyboardPressedAction) {
|
||||
print ("Action Name On Key Down: " + currentKeyButtonToCheck.Name);
|
||||
if (showKeyboardPressed) {
|
||||
print ("Get Key Down: " + currentKeyButtonToCheck.keyButton);
|
||||
}
|
||||
|
||||
if (showKeyboardPressedAction) {
|
||||
print ("Action Name On Key Down: " + currentKeyButtonToCheck.Name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
//this key is for release
|
||||
case buttonType.getKeyUp:
|
||||
if (Input.GetKeyUp (currentKeyCodeToCheck)) {
|
||||
if (useNewInputSystem) {
|
||||
if (getKeyUp (currentKeyCodeToCheck)) {
|
||||
if (showKeyboardPressed) {
|
||||
print ("Get Key Up: " + currentKeyButtonToCheck.keyButton);
|
||||
}
|
||||
|
||||
if (showKeyboardPressed) {
|
||||
print ("Get Key Up: " + currentKeyButtonToCheck.keyButton);
|
||||
if (showKeyboardPressedAction) {
|
||||
print ("Action Name On Key Up: " + currentKeyButtonToCheck.Name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (Input.GetKeyUp (currentKeyCodeToCheck)) {
|
||||
|
||||
if (showKeyboardPressedAction) {
|
||||
print ("Action Name On Key Up: " + currentKeyButtonToCheck.Name);
|
||||
if (showKeyboardPressed) {
|
||||
print ("Get Key Up: " + currentKeyButtonToCheck.keyButton);
|
||||
}
|
||||
|
||||
if (showKeyboardPressedAction) {
|
||||
print ("Action Name On Key Up: " + currentKeyButtonToCheck.Name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2028,7 +2210,7 @@ public class inputManager : MonoBehaviour
|
||||
currentTouch = Input.GetTouch (currentTouchIndex);
|
||||
}
|
||||
|
||||
if (currentTouch.phase == TouchPhase.Began) {
|
||||
if (currentTouch.phase == UnityEngine.TouchPhase.Began) {
|
||||
//if the button is pressed (OnPointerDown), return true
|
||||
//print ("getKeyDown");
|
||||
return true;
|
||||
@@ -2053,7 +2235,8 @@ public class inputManager : MonoBehaviour
|
||||
currentTouch = Input.GetTouch (currentTouchIndex);
|
||||
}
|
||||
|
||||
if (currentTouch.phase == TouchPhase.Stationary || currentTouch.phase == TouchPhase.Moved) {
|
||||
if (currentTouch.phase == UnityEngine.TouchPhase.Stationary ||
|
||||
currentTouch.phase == UnityEngine.TouchPhase.Moved) {
|
||||
//if the button is pressed OnPointerDown, and is not released yet (OnPointerUp), return true
|
||||
//print ("getKey");
|
||||
return true;
|
||||
@@ -2078,7 +2261,7 @@ public class inputManager : MonoBehaviour
|
||||
currentTouch = Input.GetTouch (currentTouchIndex);
|
||||
}
|
||||
|
||||
if (currentTouch.phase == TouchPhase.Ended) {
|
||||
if (currentTouch.phase == UnityEngine.TouchPhase.Ended) {
|
||||
//if the button is released (OnPointerUp), return true
|
||||
//print ("getKeyUp");
|
||||
return true;
|
||||
@@ -3715,6 +3898,10 @@ public class inputManager : MonoBehaviour
|
||||
|
||||
public KeyCode key = KeyCode.A;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
public Key keyInput;
|
||||
#endif
|
||||
|
||||
#if REWIRED
|
||||
[ActionIdProperty(typeof(RewiredConsts.Action))]
|
||||
public int rewiredAction = -1;
|
||||
|
||||
Reference in New Issue
Block a user