plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent ed7b223c04
commit fd87a6ffd5
14441 changed files with 13711084 additions and 20 deletions

View File

@@ -0,0 +1,85 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public static class JoystickData{
//Enum with values representing either the Horizontal or Vertical axis on the different sticks available
public enum AxisTypes
{
LEFT_HORIZONTAL,
LEFT_VERTICAL,
RIGHT_HORIZONTAL,
RIGHT_VERTICAL,
D_HORIZONTAL,
D_VERTICAL
}
// Enum representing the different buttons on the joystick, using the Xbox 360 controller as its base. In other words, the
// "A" button is the bottom face button, which is the "X" button one the Play Station Joystick.
public enum ButtonTypes
{
A = 0,
B = 1,
X = 2,
Y = 3,
LeftBumper = 4,
RightBumper = 5,
Back = 6,
Start = 7,
LeftStickClick = 8,
RightStickClick = 9,
LeftDPadX = 10,
RightDPadX = 11,
TopDPadY = 12,
BottomDPadY = 13,
LeftTrigger = 14,
RightTrigger = 15
}
//The default joystick configuration for the default register
public static Dictionary<ButtonTypes, int> joystick_default = new Dictionary<ButtonTypes, int>()
{
{ ButtonTypes.A, 0 },
{ ButtonTypes.B, 1 },
{ ButtonTypes.X, 2 },
{ ButtonTypes.Y, 3 },
{ ButtonTypes.LeftBumper, 4 },
{ ButtonTypes.RightBumper, 5 },
{ ButtonTypes.Back, 6 },
{ ButtonTypes.Start, 7 },
{ ButtonTypes.LeftStickClick, 8 },
{ ButtonTypes.RightStickClick, 9 },
{ ButtonTypes.LeftDPadX, 10 },
{ ButtonTypes.RightDPadX, 11 },
{ ButtonTypes.TopDPadY, 12 },
{ ButtonTypes.BottomDPadY, 13 },
{ ButtonTypes.LeftTrigger, 14 },
{ ButtonTypes.RightTrigger, 15 }
};
// The register for the "default" platform. If a joystick name or button type cannot be found in a platform specific register, this register will be used instead.
public static Dictionary<string, Dictionary<ButtonTypes, int>> register_default = new Dictionary<string, Dictionary<ButtonTypes, int>>()
{
{ "default", JoystickData.joystick_default }
};
// The register used on Windows platforms.
public static Dictionary<string, Dictionary<ButtonTypes, int>> register_windows = new Dictionary<string, Dictionary<ButtonTypes, int>>()
{
{ "default", JoystickData.joystick_default }
};
// The register used on OSX platforms
public static Dictionary<string, Dictionary<ButtonTypes, int>> register_osx = new Dictionary<string, Dictionary<ButtonTypes, int>>()
{
};
// The register used on Linux platforms
public static Dictionary<string, Dictionary<ButtonTypes, int>> register_linux = new Dictionary<string, Dictionary<ButtonTypes, int>>()
{
};
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8c5a1fef2b594704d8a121bee1750566
timeCreated: 1511982485
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/JoystickData.cs
uploadId: 814740

View File

@@ -0,0 +1,93 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class actionInputDelaySystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool checkInputEnabled = true;
public float actionDelay;
public bool useLowerDelay;
public pressType pressTypeCheck;
[Space]
[Header ("Debug")]
[Space]
public bool pressedDown;
public bool previousPressedDown;
public bool eventTriggered;
[Space]
[Header ("Event Settings")]
[Space]
public UnityEvent actionEvent;
public enum pressType
{
hold,
up
}
float lastTimePressedDown;
public void inputSetPressedDownState ()
{
if (!checkInputEnabled) {
return;
}
pressedDown = true;
if (previousPressedDown != pressedDown) {
previousPressedDown = pressedDown;
lastTimePressedDown = Time.time;
eventTriggered = false;
}
if (!eventTriggered && pressTypeCheck == pressType.hold && Time.time > lastTimePressedDown + actionDelay) {
actionEvent.Invoke ();
eventTriggered = true;
}
}
public void inpuSetPressedUpState ()
{
if (!checkInputEnabled) {
return;
}
pressedDown = false;
if (previousPressedDown != pressedDown) {
previousPressedDown = pressedDown;
eventTriggered = false;
}
if (!eventTriggered && pressTypeCheck == pressType.up) {
if (useLowerDelay) {
if (Time.time < lastTimePressedDown + actionDelay) {
actionEvent.Invoke ();
eventTriggered = true;
}
} else {
if (Time.time > lastTimePressedDown + actionDelay) {
actionEvent.Invoke ();
eventTriggered = true;
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d998dda041ce0bf46a01d891e5444941
timeCreated: 1551153951
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/actionInputDelaySystem.cs
uploadId: 814740

View File

@@ -0,0 +1,24 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class editButtonInput : MonoBehaviour
{
[Header ("Main Components")]
[Space]
public Text actionNameText;
public Text actionKeyText;
public string currentActionKeyString;
public string keyboardActionKey;
public string gamepadActionKey;
public int multiAxesIndex;
public int axesIndex;
public GameObject editButtonGameObject;
public bool editButtonInputActive;
}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 4489997f2ab4d664eb98b5e463279771
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/editButtonInput.cs
uploadId: 814740

View File

@@ -0,0 +1,406 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System;
using UnityEngine.Events;
using UnityEngine.EventSystems;
[System.Serializable]
//this script allows to edit the touch buttons to set their positions in run time with the mouse or finger in a touch screen, save those positions in a file,
//and reload in the next execution, in case you want to load it
public class editControlPosition : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool loadButtonsPositionEnabled = false;
public bool initializeTouchButtonsPositionEnabled = false;
[Space]
[Header ("Debug")]
[Space]
public List<RectTransform> buttons = new List<RectTransform> ();
public bool mainGameManagerLocated;
[Space]
[Header ("Button Info Debug")]
[Space]
public List<Vector2> buttonsPos = new List<Vector2> ();
public List<Vector2> buttonPosDefault = new List<Vector2> ();
public List<touchButtonListener> touchButtonList = new List<touchButtonListener> ();
[Space]
[Header ("Components")]
[Space]
public inputManager input;
public gameManager mainGameManager;
RectTransform buttonToMove;
bool enableButtonEdit = false;
bool touching;
bool grab;
int i = 0;
readonly List<RaycastResult> captureRaycastResults = new List<RaycastResult> ();
Touch currentTouch;
bool touchPlatform;
string currentSaveDataPath;
bool checkSettingsInitialized;
bool useRelativePath;
string touchControlsPositionFolderName;
string touchControlsPositionFileName;
Coroutine mainUpdateCoroutine;
void Start ()
{
touchPlatform = touchJoystick.checkTouchPlatform ();
checkMainManager ();
if (mainGameManagerLocated) {
touchControlsPositionFolderName = mainGameManager.getTouchControlsPositionFolderName ();
touchControlsPositionFileName = mainGameManager.getTouchControlsPositionFileName ();
}
}
void checkMainManager ()
{
mainGameManagerLocated = mainGameManager != null;
if (!mainGameManagerLocated) {
mainGameManager = gameManager.Instance;
mainGameManagerLocated = mainGameManager != null;
}
if (!mainGameManagerLocated) {
mainGameManager = FindObjectOfType<gameManager> ();
mainGameManager.getComponentInstanceOnApplicationPlaying ();
mainGameManagerLocated = mainGameManager != null;
}
}
public void stopUpdateCoroutine ()
{
if (mainUpdateCoroutine != null) {
StopCoroutine (mainUpdateCoroutine);
}
}
IEnumerator updateCoroutine ()
{
var waitTime = new WaitForSecondsRealtime (0.00001f);
while (true) {
if (enableButtonEdit) {
//check the mouse position in the screen if we are in the editor, or the finger position in a touch device
int touchCount = Input.touchCount;
if (!touchPlatform) {
touchCount++;
}
for (int i = 0; i < touchCount; i++) {
if (!touchPlatform) {
currentTouch = touchJoystick.convertMouseIntoFinger ();
} else {
currentTouch = Input.GetTouch (i);
}
if (currentTouch.phase == TouchPhase.Began) {
//if the finger/mouse position is above a button, it is selected to translate
captureRaycastResults.Clear ();
PointerEventData p = new PointerEventData (EventSystem.current);
p.position = currentTouch.position;
p.clickCount = i;
p.dragging = false;
EventSystem.current.RaycastAll (p, captureRaycastResults);
foreach (RaycastResult r in captureRaycastResults) {
if (buttons.Contains (r.gameObject.GetComponent<RectTransform> ())) {
grab = true;
buttonToMove = r.gameObject.GetComponent<RectTransform> ();
touching = true;
}
}
}
//the button follows the mouse/finger position
if ((currentTouch.phase == TouchPhase.Stationary || currentTouch.phase == TouchPhase.Moved) && grab) {
if (grab && buttonToMove != null) {
buttonToMove.position = new Vector2 (currentTouch.position.x, currentTouch.position.y);
}
}
//release the button
if (currentTouch.phase == TouchPhase.Ended && touching) {
touching = false;
if (grab) {
grab = false;
buttonToMove = null;
}
}
}
}
yield return waitTime;
}
}
public void checkSettings ()
{
checkMainManager ();
if (!checkSettingsInitialized && mainGameManagerLocated) {
useRelativePath = mainGameManager.useRelativePath;
currentSaveDataPath = getDataPath ();
checkSettingsInitialized = true;
}
}
public string getDataPath ()
{
string dataPath = "";
if (useRelativePath) {
dataPath = touchControlsPositionFolderName;
} else {
dataPath = Application.persistentDataPath + "/" + touchControlsPositionFolderName;
}
if (!Directory.Exists (dataPath)) {
Directory.CreateDirectory (dataPath);
}
dataPath += "/";
return dataPath;
}
public void getTouchButtons ()
{
checkMainManager ();
if (mainGameManagerLocated) {
//load or not the previous positions of the buttons, saved in another execution
if (mainGameManager.loadEnabled) {
if (loadButtonsPositionEnabled) {
Load ();
loadButtonsPositionEnabled = false;
}
if (initializeTouchButtonsPositionEnabled) {
for (i = 0; i < buttons.Count; i++) {
if (buttons [i] != null) {
buttonsPos.Add (buttons [i].position);
}
}
}
}
}
}
public void getTouchButtonsComponents ()
{
buttons.Clear ();
buttonPosDefault.Clear ();
touchButtonList.Clear ();
bool inputManagerLocated = input != null;
if (!inputManagerLocated) {
input = inputManager.Instance;
inputManagerLocated = input != null;
}
if (!inputManagerLocated) {
input = FindObjectOfType<inputManager> ();
input.getComponentInstanceOnApplicationPlaying ();
inputManagerLocated = input != null;
}
if (!inputManagerLocated) {
return;
}
//save all touch buttons in a list and their positions
for (i = 0; i < input.touchButtonList.Count; i++) {
if (input.touchButtonList [i] != null) {
RectTransform currentRectTransform = input.touchButtonList [i].GetComponent<RectTransform> ();
if (currentRectTransform != null) {
buttons.Add (currentRectTransform);
buttonPosDefault.Add (currentRectTransform.anchoredPosition);
touchButtonList.Add (input.touchButtonList [i]);
}
}
}
print ("Touch Buttons Components stored");
updateComponent ();
}
//after edit the buttons, their positions are saved
public void activateEdit ()
{
enableButtonEdit = !enableButtonEdit;
stopUpdateCoroutine ();
if (enableButtonEdit) {
changeButtonsState (false);
mainUpdateCoroutine = StartCoroutine (updateCoroutine ());
} else {
buttonsPos.Clear ();
for (i = 0; i < buttons.Count; i++) {
if (buttons [i] != null) {
buttonsPos.Add (buttons [i].anchoredPosition);
}
}
Save ();
}
}
//if we cancel the edition, the buttons back to their previous position, if any of them has been moved
public void disableEdit ()
{
if (enableButtonEdit) {
enableButtonEdit = false;
for (i = 0; i < buttons.Count; i++) {
if (buttons [i] != null) {
buttons [i].anchoredPosition = buttonsPos [i];
}
}
}
}
//set the buttons with their default position
public void changeToDefault ()
{
for (i = 0; i < buttons.Count; i++) {
if (buttons [i] != null) {
buttons [i].anchoredPosition = buttonPosDefault [i];
}
}
Save ();
}
//disable and enable the pointer click components in the buttons, to avoid activate them while the game is paused
public void changeButtonsState (bool state)
{
for (i = 0; i < touchButtonList.Count; i++) {
if (touchButtonList [i] != null && touchButtonList [i].enabled != state) {
touchButtonList [i].enabled = state;
}
}
}
//save in a file the positions of the button, vector2 are not serializable if I am not wrong, so every axis is save in a list of float
public void Save ()
{
checkSettings ();
savedButtons sB = new savedButtons ();
for (i = 0; i < buttons.Count; i++) {
if (buttons [i] != null) {
sB.saveButtonsPosX.Add (buttons [i].position.x);
sB.saveButtonsPosY.Add (buttons [i].position.y);
}
}
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Create (currentSaveDataPath + touchControlsPositionFileName + ".txt");
bf.Serialize (file, sB.saveButtonsPosX);
bf.Serialize (file, sB.saveButtonsPosY);
file.Close ();
buttonsPos.Clear ();
for (i = 0; i < buttons.Count; i++) {
buttonsPos.Add (new Vector2 (sB.saveButtonsPosX [i], sB.saveButtonsPosY [i]));
}
}
//load the positions of the buttons reading the file if it exists
public void Load ()
{
checkSettings ();
savedButtons sB = new savedButtons ();
if (File.Exists (currentSaveDataPath + touchControlsPositionFileName + ".txt")) {
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Open (currentSaveDataPath + touchControlsPositionFileName + ".txt", FileMode.Open);
sB.saveButtonsPosX = (List<float>)bf.Deserialize (file);
sB.saveButtonsPosY = (List<float>)bf.Deserialize (file);
file.Close ();
}
//also check the lenght are equal in both list, to avoid exceptions
if (sB.saveButtonsPosX.Count == buttons.Count) {
for (i = 0; i < buttons.Count; i++) {
if (buttons [i] != null) {
buttons [i].position = new Vector2 (sB.saveButtonsPosX [i], sB.saveButtonsPosY [i]);
}
}
}
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Touch Control Positions", gameObject);
}
}
//the positions of the buttons need to be serializable to save them in a file
[Serializable]
class savedButtons
{
public List<float> saveButtonsPosX = new List<float> ();
public List<float> saveButtonsPosY = new List<float> ();
}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: ad1bc5194bc7f2f479646a7c8b17affb
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/editControlPosition.cs
uploadId: 814740

View File

@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class editInputPanelInfo : MonoBehaviour
{
public GameObject editInputPanelGameObject;
public GameObject editButtonInputGameObject;
public GameObject bottomGameObject;
public Transform buttonsParent;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 710aef08fc6d1a948bbbf27aa05dd86d
timeCreated: 1535687165
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/editInputPanelInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,790 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Events;
public class inputActionManager : MonoBehaviour
{
public List<multiAxes> multiAxesList = new List<multiAxes> ();
public bool inputActivated;
public inputManager input;
public bool showDebugActions;
public bool inputCurrentlyActive = true;
public bool inputPaused;
public bool manualControlActive;
[Range (-1, 1)] public float manualHorizontalInput;
[Range (-1, 1)] public float manualVerticalInput;
[Range (-1, 1)] public float manualMouseHorizontalInput;
[Range (-1, 1)] public float manualMouseVerticalInput;
public bool setAutomaticValuesOnHorizontalInput = true;
public bool setAutomaticValuesOnVerticalInput = true;
public bool setAutomaticValuesOnMouseHorizontalInput = true;
public bool setAutomaticValuesOnVerticalVerticalInput = true;
[Tooltip ("Use the touch joystick for control in preference to keys.")]
public bool usingTouchMovementJoystick = true;
public bool enableTouchJoysticks = true;
public bool overrideInputValuesActive;
public Vector2 overrideInputAxisValue;
Vector2 manualControlAxisValues;
GameObject currentDriver;
playerInputManager playerInput;
multiAxes currentMultiAxes;
Axes curentAxes;
float footBrake;
float handBrake;
public Vector2 movementAxis;
public Vector2 mouseAxis;
public Vector2 rawMovementAxis;
public bool useAxisAsHorizontalMovementInput = true;
public bool useAxisAsVerticalMovementInput = true;
public float horizontalMovementInputLerpSpeed = 10;
public float verticalMovementInputLerpSpeed = 5;
public bool useExternalVehicleTouchControlsEnabled;
public bool disableTouchJoysticksOnExternalVehicleEnabled;
public UnityEvent eventToActivateTouchControlsOnExternalVehicle;
public UnityEvent eventToDeactivateTouchControlsOnExternalVehicle;
float currentVerticalMovementAxisValue;
float currentHorizontalMovementAxisValue;
bool isUsingTouchControls;
Vector2 temporalMovementAxis;
bool positiveVerticalPressed;
bool negativeVerticalPressed;
bool positiveHorizontalPressed;
bool negativeHorizontalPressed;
int currentMultiAxesCount;
int currentAxesCount;
int MAIndex;
int AIndex;
bool inputManagerLocated;
Coroutine updateCoroutine;
public void stopUpdateCoroutine ()
{
if (updateCoroutine != null) {
StopCoroutine (updateCoroutine);
}
}
IEnumerator updateSystemCoroutine ()
{
var waitTime = new WaitForSecondsRealtime (0.0001f);
while (true) {
updateSystem ();
yield return waitTime;
}
}
void updateSystem ()
{
if (inputActivated) {
inputPaused = playerInput.isInputPausedForExternalComponents ();
if (inputPaused) {
return;
}
inputCurrentlyActive = !playerInput.isUsingPlayerMenu ();
for (MAIndex = 0; MAIndex < currentMultiAxesCount; MAIndex++) {
currentMultiAxes = multiAxesList [MAIndex];
if (currentMultiAxes.currentlyActive) {
currentAxesCount = currentMultiAxes.axes.Count;
for (AIndex = 0; AIndex < currentAxesCount; AIndex++) {
curentAxes = currentMultiAxes.axes [AIndex];
if (curentAxes.actionEnabled) {
if (inputCurrentlyActive || curentAxes.canBeUsedOnPausedGame) {
if (playerInput.checkPlayerInputButtonFromMultiAxesList (currentMultiAxes.multiAxesStringIndex, curentAxes.axesStringIndex,
curentAxes.buttonPressType, curentAxes.canBeUsedOnPausedGame)) {
if (showDebugActions) {
print (curentAxes.Name);
}
curentAxes.buttonEvent.Invoke ();
}
}
}
}
}
}
isUsingTouchControls = playerInput.isUsingTouchControls ();
temporalMovementAxis = playerInput.getPlayerMovementAxis ();
rawMovementAxis = playerInput.getPlayerRawMovementAxis ();
if (!useAxisAsHorizontalMovementInput && !isUsingTouchControls) {
movementAxis.x = Mathf.MoveTowards (movementAxis.x, currentHorizontalMovementAxisValue, Time.deltaTime * horizontalMovementInputLerpSpeed);
if (movementAxis.x > 0.01f) {
rawMovementAxis.x = 1;
} else if (movementAxis.x < -0.01f) {
rawMovementAxis.x = -1;
} else {
rawMovementAxis.x = 0;
}
} else {
currentHorizontalMovementAxisValue = 0;
movementAxis.x = temporalMovementAxis.x;
}
if (!useAxisAsVerticalMovementInput && !isUsingTouchControls) {
movementAxis.y = Mathf.MoveTowards (movementAxis.y, currentVerticalMovementAxisValue, Time.deltaTime * verticalMovementInputLerpSpeed);
if (movementAxis.y > 0.01f) {
rawMovementAxis.y = 1;
} else if (movementAxis.y < -0.01f) {
rawMovementAxis.y = -1;
} else {
rawMovementAxis.y = 0;
}
} else {
currentVerticalMovementAxisValue = 0;
movementAxis.y = temporalMovementAxis.y;
}
mouseAxis = playerInput.getPlayerMouseAxis ();
}
}
public void setPositiveVerticalMovementAxisValue (int newValue)
{
positiveVerticalPressed = (newValue != 0);
if (currentVerticalMovementAxisValue == -1 && newValue == 0) {
return;
}
currentVerticalMovementAxisValue = newValue;
if (newValue == 0) {
if (negativeVerticalPressed) {
currentVerticalMovementAxisValue = -1;
}
}
}
public void setNegativeVerticalMovementAxisValue (int newValue)
{
negativeVerticalPressed = (newValue != 0);
if (currentVerticalMovementAxisValue == 1 && newValue == 0) {
return;
}
currentVerticalMovementAxisValue = newValue;
if (newValue == 0) {
if (positiveVerticalPressed) {
currentVerticalMovementAxisValue = 1;
}
}
}
public void setPositiveHorizontalMovementAxisValue (int newValue)
{
positiveHorizontalPressed = (newValue != 0);
if (currentHorizontalMovementAxisValue == -1 && newValue == 0) {
return;
}
currentHorizontalMovementAxisValue = newValue;
if (newValue == 0) {
if (negativeHorizontalPressed) {
currentHorizontalMovementAxisValue = -1;
}
}
}
public void setNegativeHorizontalMovementAxisValue (int newValue)
{
negativeHorizontalPressed = (newValue != 0);
if (currentHorizontalMovementAxisValue == 1 && newValue == 0) {
return;
}
currentHorizontalMovementAxisValue = newValue;
if (newValue == 0) {
if (positiveHorizontalPressed) {
currentHorizontalMovementAxisValue = 1;
}
}
}
public Vector2 getPlayerMovementAxis ()
{
if (inputPaused) {
return Vector2.zero;
}
if (!inputActivated && !manualControlActive && !overrideInputValuesActive) {
return Vector2.zero;
}
if (!inputCurrentlyActive) {
return Vector2.zero;
}
if (manualControlActive) {
if (setAutomaticValuesOnHorizontalInput && setAutomaticValuesOnVerticalInput) {
return new Vector2 (manualHorizontalInput, manualVerticalInput);
} else if (setAutomaticValuesOnHorizontalInput && !setAutomaticValuesOnVerticalInput) {
return new Vector2 (manualHorizontalInput, movementAxis.y);
} else if (!setAutomaticValuesOnHorizontalInput && setAutomaticValuesOnVerticalInput) {
return new Vector2 (movementAxis.x, manualVerticalInput);
} else {
return movementAxis;
}
} else if (overrideInputValuesActive) {
return overrideInputAxisValue;
} else {
return movementAxis;
}
}
public Vector2 getPlayerMouseAxis ()
{
if (inputPaused) {
return Vector2.zero;
}
if (!inputActivated && !manualControlActive && !overrideInputValuesActive) {
return Vector2.zero;
}
if (!inputCurrentlyActive) {
return Vector2.zero;
}
if (manualControlActive) {
if (setAutomaticValuesOnMouseHorizontalInput && setAutomaticValuesOnVerticalVerticalInput) {
return new Vector2 (manualMouseHorizontalInput, manualMouseVerticalInput);
} else if (setAutomaticValuesOnMouseHorizontalInput && !setAutomaticValuesOnVerticalVerticalInput) {
return new Vector2 (manualMouseHorizontalInput, mouseAxis.y);
} else if (!setAutomaticValuesOnMouseHorizontalInput && setAutomaticValuesOnVerticalVerticalInput) {
return new Vector2 (mouseAxis.x, manualMouseVerticalInput);
} else {
return mouseAxis;
}
} else {
return mouseAxis;
}
}
public Vector2 getPlayerRawMovementAxis ()
{
if (inputPaused) {
return Vector2.zero;
}
if (!inputActivated && !manualControlActive && !overrideInputValuesActive) {
return Vector2.zero;
}
if (!inputCurrentlyActive) {
return Vector2.zero;
}
if (manualControlActive) {
if (setAutomaticValuesOnHorizontalInput) {
if (manualHorizontalInput > 0) {
manualControlAxisValues.x = 1;
} else if (manualHorizontalInput < 0) {
manualControlAxisValues.x = -1;
} else {
manualControlAxisValues.x = 0;
}
} else {
manualControlAxisValues.x = rawMovementAxis.x;
}
if (setAutomaticValuesOnVerticalInput) {
if (manualVerticalInput > 0) {
manualControlAxisValues.y = 1;
} else if (manualVerticalInput < 0) {
manualControlAxisValues.y = -1;
} else {
manualControlAxisValues.y = 0;
}
} else {
manualControlAxisValues.y = rawMovementAxis.y;
}
return manualControlAxisValues;
} else if (overrideInputValuesActive) {
if (overrideInputAxisValue.x > 0) {
manualControlAxisValues.x = 1;
} else if (overrideInputAxisValue.x < 0) {
manualControlAxisValues.x = -1;
} else {
manualControlAxisValues.x = 0;
}
if (overrideInputAxisValue.y > 0) {
manualControlAxisValues.y = 1;
} else if (overrideInputAxisValue.y < 0) {
manualControlAxisValues.y = -1;
} else {
manualControlAxisValues.y = 0;
}
return overrideInputAxisValue;
} else {
return rawMovementAxis;
}
}
public void resetMovementValues ()
{
rawMovementAxis = Vector2.zero;
movementAxis = Vector2.zero;
mouseAxis = Vector2.zero;
}
public void enableOrDisableInput (bool state, GameObject driver)
{
inputActivated = state;
stopUpdateCoroutine ();
currentDriver = driver;
setInputManager ();
playerInput = currentDriver.GetComponent<playerInputManager> ();
if (playerInput.isUsingTouchControls ()) {
if (state) {
if (enableTouchJoysticks) {
playerInput.setUsingTouchMovementJoystickState (usingTouchMovementJoystick);
playerInput.enableOrDisableTouchMovementJoystickForButtons (true);
} else {
playerInput.enableOrDisableTouchMovementJoystickForButtons (false);
}
} else {
playerInput.setOriginalTouchMovementInputState ();
}
if (useExternalVehicleTouchControlsEnabled) {
if (state) {
eventToActivateTouchControlsOnExternalVehicle.Invoke ();
} else {
eventToDeactivateTouchControlsOnExternalVehicle.Invoke ();
}
if (disableTouchJoysticksOnExternalVehicleEnabled) {
playerInput.enableOrDisableTouchMovementControl (!state);
playerInput.enableOrDisableTouchCameraControl (!state);
}
}
}
if (inputActivated) {
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
} else {
resetMovementValues ();
if (playerInput != null) {
playerInput.setPressingTouchHorizontalRightInputState (false);
playerInput.setPressingTouchHorizontalLeftInputState (false);
playerInput.setPressingTouchVerticalUpInputState (false);
playerInput.setPressingTouchVerticalDownInputState (false);
}
}
}
public void pauseOrResumeInput (bool state)
{
inputPaused = state;
}
public void setInputCurrentlyActiveState (bool state)
{
inputCurrentlyActive = state;
}
public void overrideInputValues (Vector2 newInputValues, float newFootBrakeValue, float newHandBrakeValue, bool overrideState)
{
overrideInputAxisValue = newInputValues;
overrideInputValuesActive = overrideState;
footBrake = newFootBrakeValue;
handBrake = newHandBrakeValue;
}
public float getFootBrakeValue ()
{
return footBrake;
}
public float getHandBrakeValue ()
{
return handBrake;
}
public void setInputManager ()
{
inputManagerLocated = input != null;
if (!inputManagerLocated) {
input = inputManager.Instance;
inputManagerLocated = input != null;
}
if (!inputManagerLocated) {
input = FindObjectOfType<inputManager> ();
inputManagerLocated = input != null;
if (inputManagerLocated) {
input.getComponentInstanceOnApplicationPlaying ();
}
}
currentMultiAxesCount = multiAxesList.Count;
}
public bool isGameManagerPaused ()
{
if (inputManagerLocated) {
return input.isGameManagerPaused ();
}
return false;
}
public bool getIsUsingTouchControlsValue ()
{
if (inputManagerLocated) {
return input.isUsingTouchControls ();
}
return false;
}
//EDITOR FUNCTIONS
public void setInputManagerOnEditor ()
{
if (input == null) {
input = FindObjectOfType<inputManager> ();
updateComponent ();
}
}
public void addNewAxes ()
{
setInputManager ();
if (input != null) {
multiAxes newMultiAxes = new multiAxes ();
newMultiAxes.multiAxesStringList = new string [input.multiAxesList.Count];
for (int i = 0; i < input.multiAxesList.Count; i++) {
string axesName = input.multiAxesList [i].axesName;
newMultiAxes.multiAxesStringList [i] = axesName;
}
multiAxesList.Add (newMultiAxes);
updateComponent ();
}
}
public void addNewAction (int multiAxesIndex)
{
setInputManager ();
if (input != null) {
multiAxes currentMultiAxesList = multiAxesList [multiAxesIndex];
int multiAxesStringIndex = currentMultiAxesList.multiAxesStringIndex;
List<inputManager.Axes> currentTemporalAxes = input.multiAxesList [multiAxesStringIndex].axes;
Axes newAxes = new Axes ();
newAxes.axesStringList = new string [currentTemporalAxes.Count];
for (int i = 0; i < currentTemporalAxes.Count; i++) {
string actionName = currentTemporalAxes [i].Name;
newAxes.axesStringList [i] = actionName;
}
newAxes.multiAxesStringIndex = multiAxesIndex;
currentMultiAxesList.axes.Add (newAxes);
updateComponent ();
}
}
public void updateMultiAxesList ()
{
setInputManager ();
if (input != null) {
for (int i = 0; i < multiAxesList.Count; i++) {
multiAxes currentMultiAxes = multiAxesList [i];
List<inputManager.multiAxes> currentTemporalMultiAxes = input.multiAxesList;
currentMultiAxes.multiAxesStringList = new string [currentTemporalMultiAxes.Count];
int currentMultiAxesIndex = -1;
string currentMultiAxesName = currentMultiAxes.axesName;
for (int j = 0; j < currentTemporalMultiAxes.Count; j++) {
string axesName = currentTemporalMultiAxes [j].axesName;
currentMultiAxes.multiAxesStringList [j] = axesName;
if (currentMultiAxesName.Equals (axesName)) {
currentMultiAxesIndex = j;
}
}
if (currentMultiAxesIndex > -1) {
if (currentMultiAxesIndex != currentMultiAxes.multiAxesStringIndex) {
currentMultiAxes.multiAxesStringIndex = currentMultiAxesIndex;
print (currentMultiAxesName.ToUpper () + " updated with index " + currentMultiAxesIndex);
} else {
print (currentMultiAxesName.ToUpper () + " keeps the same index " + currentMultiAxesIndex);
}
} else {
print ("WARNING: Multi axes called " + currentMultiAxesName.ToUpper () + " hasn't been found, make sure to configure a multi axes " +
"with that name in the main input manager");
currentMultiAxes.multiAxesStringIndex = -1;
}
}
updateComponent ();
}
}
public void updateAxesList (int multiAxesListIndex)
{
setInputManager ();
if (input != null) {
multiAxes currentMultiAxesList = multiAxesList [multiAxesListIndex];
for (int i = 0; i < currentMultiAxesList.axes.Count; i++) {
Axes currentAxes = currentMultiAxesList.axes [i];
int multiAxesStringIndex = currentMultiAxesList.multiAxesStringIndex;
List<inputManager.Axes> currentTemporalAxes = input.multiAxesList [multiAxesStringIndex].axes;
currentAxes.axesStringList = new string [currentTemporalAxes.Count];
int currentAxesIndex = -1;
string currentAxesName = currentAxes.Name;
for (int j = 0; j < currentTemporalAxes.Count; j++) {
string actionName = currentTemporalAxes [j].Name;
currentAxes.axesStringList [j] = actionName;
if (currentAxesName.Equals (actionName)) {
currentAxesIndex = j;
}
}
if (currentAxesIndex > -1) {
if (currentAxesIndex != currentAxes.axesStringIndex) {
currentAxes.axesStringIndex = currentAxesIndex;
print (currentAxes.actionName.ToUpper () + " updated with index " + currentAxesIndex);
} else {
print (currentAxes.actionName.ToUpper () + " keeps the same index " + currentAxesIndex);
}
currentAxes.keyButton = currentTemporalAxes [currentAxes.axesStringIndex].key.ToString ();
} else {
print ("WARNING: Action called " + currentAxesName.ToUpper () + " hasn't been found, make sure to configure an action " +
"with that name in the main input manager");
currentAxes.axesStringIndex = -1;
}
}
updateComponent ();
}
}
public void setAllAxesList (int multiAxesListIndex)
{
setInputManager ();
if (input != null) {
multiAxes currentMultiAxesList = multiAxesList [multiAxesListIndex];
currentMultiAxesList.axes.Clear ();
int multiAxesStringIndex = currentMultiAxesList.multiAxesStringIndex;
List<inputManager.Axes> currentTemporalAxes = input.multiAxesList [multiAxesStringIndex].axes;
for (int i = 0; i < currentTemporalAxes.Count; i++) {
Axes newAxes = new Axes ();
newAxes.axesStringList = new string [currentTemporalAxes.Count];
for (int j = 0; j < currentTemporalAxes.Count; j++) {
string actionName = currentTemporalAxes [j].Name;
newAxes.axesStringList [j] = actionName;
}
newAxes.multiAxesStringIndex = multiAxesListIndex;
newAxes.axesStringIndex = i;
newAxes.Name = currentTemporalAxes [i].Name;
newAxes.actionName = newAxes.Name;
currentMultiAxesList.axes.Add (newAxes);
}
updateComponent ();
}
}
public void setMultiAxesEnabledState (bool state)
{
for (int i = 0; i < multiAxesList.Count; i++) {
multiAxesList [i].currentlyActive = state;
}
updateComponent ();
}
public void setAllActionsEnabledState (int multiAxesListIndex, bool state)
{
for (int j = 0; j < multiAxesList [multiAxesListIndex].axes.Count; j++) {
multiAxesList [multiAxesListIndex].axes [j].actionEnabled = state;
}
updateComponent ();
}
public void setAxesActionName (int multiAxesIndex, int axesIndex)
{
if (multiAxesList.Count > multiAxesIndex && multiAxesList [multiAxesIndex].axes.Count > axesIndex) {
Axes currentAxes = multiAxesList [multiAxesIndex].axes [axesIndex];
int currentAxesStringIndex = currentAxes.axesStringIndex;
print (currentAxesStringIndex);
if (currentAxesStringIndex > -1) {
currentAxes.actionName = currentAxes.axesStringList [currentAxesStringIndex];
updateComponent ();
} else {
print ("WARNING: Action no properly configured, make sure the Multi Axes exist on the Input Manager and inside of it," +
"there is an action configured for this current element");
}
}
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Input Action Manager Values", gameObject);
}
[System.Serializable]
public class multiAxes
{
public string axesName;
public List<Axes> axes = new List<Axes> ();
public GameObject screenActionsGameObject;
public bool currentlyActive = true;
public int multiAxesStringIndex;
public string [] multiAxesStringList;
}
[System.Serializable]
public class Axes
{
public string actionName = "New Action";
public string Name;
public bool actionEnabled = true;
public bool canBeUsedOnPausedGame;
public inputManager.buttonType buttonPressType;
public UnityEvent buttonEvent;
public int axesStringIndex;
public string [] axesStringList;
public int multiAxesStringIndex;
public bool showInControlsMenu;
public string keyButton;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 71bda270592482b46b1333dcb852f081
timeCreated: 1477329623
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/inputActionManager.cs
uploadId: 814740

View File

@@ -0,0 +1,100 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class inputDoubleClickEventSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool checkDoubleClickEnabled = true;
public float maxTimeBetweenClicks = 0.4f;
public bool useMaxTimeDuringAllClicks;
public float maxTimeForAllClicks;
public int numberOfClicksToActivateInput;
[Space]
[Header ("Debug")]
[Space]
public int currentNumberOfClicks;
[Space]
[Header ("Event Settings")]
[Space]
public UnityEvent eventOnActivateInput;
float lastTimeClickUsed;
bool pressedInTime;
public void checkClickInput ()
{
if (!checkDoubleClickEnabled) {
return;
}
if (useMaxTimeDuringAllClicks) {
if (lastTimeClickUsed == 0) {
lastTimeClickUsed = Time.time;
}
currentNumberOfClicks++;
pressedInTime = Time.time - lastTimeClickUsed < maxTimeForAllClicks;
if (currentNumberOfClicks >= numberOfClicksToActivateInput) {
if (pressedInTime) {
eventOnActivateInput.Invoke ();
print ("pressed in time");
} else {
print ("amount pressed, but too much wait");
}
lastTimeClickUsed = 0;
currentNumberOfClicks = 0;
} else {
if (Time.time - lastTimeClickUsed > maxTimeForAllClicks) {
lastTimeClickUsed = 0;
currentNumberOfClicks = 0;
print ("too much wait");
}
}
} else {
pressedInTime = Time.time < lastTimeClickUsed + maxTimeBetweenClicks;
if (!pressedInTime) {
currentNumberOfClicks = 0;
}
if (pressedInTime || currentNumberOfClicks == 0) {
currentNumberOfClicks++;
if (currentNumberOfClicks >= numberOfClicksToActivateInput) {
eventOnActivateInput.Invoke ();
currentNumberOfClicks = 0;
}
} else {
currentNumberOfClicks = 0;
}
lastTimeClickUsed = Time.time;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 43216198c9000b94291d7513594c5fd4
timeCreated: 1612091548
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/inputDoubleClickEventSystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: d0c44f0dce85e4649bc53449e03d37e8
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/inputManager.cs
uploadId: 814740

View File

@@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class inputPanelUISystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public playerInputPanelSystem mainPlayerInputPanelSystem;
public GameObject inputPanelGameObject;
public GameObject screenActionParent;
[Header ("Screen Action Panel Settings")]
[Space]
public List<screenActionInfo> screenActionInfoList = new List<screenActionInfo> ();
public void setInputPanelGameObjectActiveState (bool state)
{
inputPanelGameObject.SetActive (state);
}
public void setMainPlayerInputPanelSystem (playerInputPanelSystem newplayerInputPanelSystem)
{
mainPlayerInputPanelSystem = newplayerInputPanelSystem;
updateComponent ();
}
public void searchPlayerInputPanelSystem (playerInputPanelSystem newPlayerInputPanelSystem)
{
mainPlayerInputPanelSystem = newPlayerInputPanelSystem;
if (mainPlayerInputPanelSystem == null) {
mainPlayerInputPanelSystem = FindObjectOfType<playerInputPanelSystem> ();
}
if (mainPlayerInputPanelSystem != null) {
mainPlayerInputPanelSystem.setInputPanelUISystem (this);
}
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 15bbec04792ace8428d867035c100655
timeCreated: 1619777245
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/inputPanelUISystem.cs
uploadId: 814740

View File

@@ -0,0 +1,604 @@
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
using System;
public class mouseCursorController : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool useMouseCursorEnabled = true;
public bool useSmoothCursorSpeedOnGame = true;
public float cursorSpeedOnGame = 400;
public float cursorSpeedOnPauseMenu = 7;
public float cursorLerpSpeed = 10;
public bool enableGamepadCursorOnPause = true;
public float timeToResetCursorAfterDisable = 1;
public bool useMouseLimits = true;
public bool activateCursorOnStart;
public bool useFixedTimeEnabled;
[Space]
[Header ("Input Settings")]
[Space]
public string horizontalXString = "Horizontal X";
public string verticalYString = "Vertical Y";
public string mouseXString = "Mouse X";
public string mouseYString = "Mouse Y";
public int buttonIndex = 0;
public int joystickNumber = 1;
public bool useRightJoystickAxis = true;
public bool useBothJoysticks;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool ignoreMouseCursorUpdateActive;
public bool useTryCatchOnUpdateCursorActive;
[Space]
public float currentMouseSpeed;
public Vector2 currentResolution;
[Space]
[Space]
public Vector2 cursorPosition;
float newX, newY;
Point cursorPos = new Point ();
[Space]
[Space]
public bool usingActualMouse;
public bool screenFocused;
[Space]
[Space]
public bool cursorCurrentlyActive;
public bool cursorPreviouslyActive;
public Vector2 mouseLimits;
public bool horizontalLimitConfigured;
public bool verticalLimitConfigured;
public Vector2 realMouseAxisInput;
public Vector2 axisInput;
public bool ignoreSetSelectedGameObjectOnUIByGamepad;
[Space]
[Space]
public bool playerInputLocated;
public bool inputLocated;
[Space]
[Header ("Components")]
[Space]
public playerInputManager playerInput;
public inputManager input;
[DllImport ("user32.dll")]
static extern bool SetCursorPos (int X, int Y);
[DllImport ("user32.dll")]
static extern bool GetCursorPos (out Point pos);
float lastTimeCursorEnabled;
float lastTimeCursorDisabled;
bool mouseLimitsAssigned;
float lastTimeRealMouseUsed;
float inputDifference;
string joystickString;
bool canUseGamepad;
string mouseXPlayerIDString;
string mouseYPlayerIDString;
string horizontalXPlayerIDString;
string vertircalYPlayerIDString;
float originalCursorSpeedOnGame = -1;
private static mouseCursorController _mouseCursorControllerInstance;
public static mouseCursorController Instance { get { return _mouseCursorControllerInstance; } }
bool instanceInitialized;
float currentUnscaledTime;
public void getComponentInstance ()
{
if (instanceInitialized) {
return;
}
if (_mouseCursorControllerInstance != null && _mouseCursorControllerInstance != this) {
Destroy (this.gameObject);
return;
}
_mouseCursorControllerInstance = this;
instanceInitialized = true;
}
public void getComponentInstanceOnApplicationPlaying ()
{
if (Application.isPlaying) {
getComponentInstance ();
}
}
void Awake ()
{
getComponentInstance ();
}
void Start ()
{
updateJoystickString ();
if (!playerInputLocated) {
playerInputLocated = playerInput != null;
}
if (!inputLocated) {
inputLocated = input != null;
}
mouseXPlayerIDString = mouseXString + joystickNumber;
mouseYPlayerIDString = mouseYString + joystickNumber;
horizontalXPlayerIDString = horizontalXString + joystickNumber;
vertircalYPlayerIDString = verticalYString + joystickNumber;
if (activateCursorOnStart) {
menuPause.setCursorVisibleState (true);
menuPause.setCursorLockState (false);
showOrHideMouseController (playerInput, true, joystickNumber, false);
}
}
void updateJoystickString ()
{
joystickString = "joystick " + joystickNumber + " button " + buttonIndex;
}
void Update ()
{
if (cursorCurrentlyActive) {
canUseGamepad = false;
if (inputLocated) {
if (!input.isUsingTouchControls () && input.isUsingGamepad ()) {
canUseGamepad = true;
}
} else {
canUseGamepad = true;
}
if (canUseGamepad) {
if (inputLocated) {
if (input.checkJoystickButton (joystickString, inputManager.buttonType.getKeyDown)) {
MouseOperations.MouseEvent (MouseOperations.MouseEventFlags.LeftDown);
}
if (input.checkJoystickButton (joystickString, inputManager.buttonType.getKeyUp)) {
MouseOperations.MouseEvent (MouseOperations.MouseEventFlags.LeftUp);
}
} else {
if (Input.GetKeyDown (joystickString)) {
MouseOperations.MouseEvent (MouseOperations.MouseEventFlags.LeftDown);
}
if (Input.GetKeyUp (joystickString)) {
MouseOperations.MouseEvent (MouseOperations.MouseEventFlags.LeftUp);
}
}
//Check if the actual mouse is being used
screenFocused = Application.isFocused;
if (playerInputLocated) {
realMouseAxisInput = playerInput.getRealMouseAxisInput ();
} else {
realMouseAxisInput = new Vector2 (Input.GetAxis (mouseXString), Input.GetAxis (mouseYString));
}
inputDifference = Mathf.Abs (realMouseAxisInput.sqrMagnitude);
if (useFixedTimeEnabled) {
currentUnscaledTime = Time.fixedUnscaledTime;
} else {
currentUnscaledTime = Time.unscaledTime;
}
if (inputDifference > 0.01f) {
lastTimeRealMouseUsed = currentUnscaledTime;
axisInput = realMouseAxisInput;
}
if (currentUnscaledTime > lastTimeRealMouseUsed + 1 && screenFocused) {
if (usingActualMouse) {
cursorPosition.x = cursorPos.X;
cursorPosition.y = cursorPos.Y;
newX = cursorPosition.x;
newY = cursorPosition.y;
usingActualMouse = false;
}
} else {
usingActualMouse = true;
}
//Assign the input values according to if the gamepad or the actual mouse is being used
if (!usingActualMouse) {
if (playerInputLocated) {
if (playerInput.isInputPaused () || playerInput.isPlayerDead ()) {
if (useBothJoysticks) {
axisInput = playerInput.getRealMouseGamepadAxisInput () + playerInput.getRealMovementGamepadAxisInput ();
} else {
if (useRightJoystickAxis) {
axisInput = playerInput.getRealMouseGamepadAxisInput ();
} else {
axisInput = playerInput.getRealMovementGamepadAxisInput ();
}
}
} else {
if (useBothJoysticks) {
axisInput = playerInput.getPlayerMouseAxis () + playerInput.getPlayerMovementAxis ();
} else {
if (useRightJoystickAxis) {
axisInput = playerInput.getPlayerMouseAxis ();
} else {
axisInput = playerInput.getPlayerMovementAxis ();
}
}
}
} else {
if (useBothJoysticks) {
axisInput = new Vector2 (Input.GetAxis (mouseXPlayerIDString), Input.GetAxis (mouseYPlayerIDString)) +
new Vector2 (Input.GetAxis (horizontalXPlayerIDString), Input.GetAxis (vertircalYPlayerIDString));
} else {
if (useRightJoystickAxis) {
axisInput = new Vector2 (Input.GetAxis (mouseXPlayerIDString), Input.GetAxis (mouseYPlayerIDString));
} else {
axisInput = new Vector2 (Input.GetAxis (horizontalXPlayerIDString), Input.GetAxis (vertircalYPlayerIDString));
}
}
}
}
if (!ignoreMouseCursorUpdateActive) {
updateGetCursorPos ();
}
if (Time.deltaTime > 0) {
if (useSmoothCursorSpeedOnGame) {
currentMouseSpeed = currentUnscaledTime * cursorSpeedOnGame;
} else {
currentMouseSpeed = cursorSpeedOnPauseMenu;
}
} else {
currentMouseSpeed = cursorSpeedOnPauseMenu;
if (!enableGamepadCursorOnPause) {
return;
}
}
if (!usingActualMouse) {
if (axisInput.x > 0) {
cursorPosition.x += currentMouseSpeed;
} else if (axisInput.x < 0) {
cursorPosition.x -= currentMouseSpeed;
}
if (axisInput.y > 0) {
cursorPosition.y -= currentMouseSpeed;
} else if (axisInput.y < 0) {
cursorPosition.y += currentMouseSpeed;
}
}
if (useMouseLimits) {
cursorPosition.x = Mathf.Clamp (cursorPosition.x, 0, mouseLimits.x);
cursorPosition.y = Mathf.Clamp (cursorPosition.y, 0, mouseLimits.y);
}
if (Time.deltaTime > 0 && !usingActualMouse) {
newX = Mathf.Lerp (newX, cursorPosition.x, currentUnscaledTime * cursorLerpSpeed);
newY = Mathf.Lerp (newY, cursorPosition.y, currentUnscaledTime * cursorLerpSpeed);
} else {
newX = cursorPosition.x;
newY = cursorPosition.y;
}
if (!usingActualMouse) {
if (!ignoreMouseCursorUpdateActive) {
updateSetCursorPos ((int)newX, (int)newY);
}
}
getScreenClampValues ();
}
}
}
public void showOrHideMouseController (playerInputManager newInput, bool state, int newJoystickNumber, bool pausingGame)
{
if (newInput == null || !newInput.useOnlyKeyboard) {
playerInput = newInput;
joystickNumber = newJoystickNumber;
updateJoystickString ();
showOrHideMouseController (state, pausingGame);
}
}
public void setIgnoreSetSelectedGameObjectOnUIByGamepadState (bool state)
{
ignoreSetSelectedGameObjectOnUIByGamepad = state;
}
void getScreenClampValues ()
{
if (useMouseLimits && (!horizontalLimitConfigured || !verticalLimitConfigured)) {
if (Time.deltaTime == 0 || Time.time > lastTimeCursorEnabled + 0.4f) {
if (!horizontalLimitConfigured) {
if (cursorPos.X > 0 && newX > (cursorPos.X + 50)) {
if (cursorPos.X > currentResolution.x / 1.5f) {
mouseLimits.x = cursorPos.X;
horizontalLimitConfigured = true;
// print ("max X");
}
}
}
if (!verticalLimitConfigured) {
if (cursorPos.Y > 0 && newY > (cursorPos.Y + 50)) {
if (cursorPos.Y > currentResolution.y / 1.5f) {
mouseLimits.y = cursorPos.Y;
verticalLimitConfigured = true;
// print ("max Y");
}
}
}
}
}
}
public void showOrHideMouseController (bool state, bool pausingGame)
{
if (input != null && !input.isUsingGamepad ()) {
return;
}
if (!useMouseCursorEnabled) {
return;
}
if (pausingGame) {
cursorPreviouslyActive = false;
} else {
if (!state) {
if (cursorCurrentlyActive) {
cursorPreviouslyActive = true;
}
}
}
if (state) {
if (Time.time > lastTimeCursorDisabled + timeToResetCursorAfterDisable) {
cursorPreviouslyActive = false;
}
}
if (state && (pausingGame || !cursorPreviouslyActive)) {
resetCursorPosition ();
}
cursorCurrentlyActive = state;
if (showDebugPrint) {
print ("Setting cursor active state as " + cursorCurrentlyActive);
}
if (!pausingGame && state) {
if (!cursorCurrentlyActive) {
cursorPreviouslyActive = false;
}
}
if (!ignoreSetSelectedGameObjectOnUIByGamepad) {
if (state) {
StartCoroutine (FocusButton ());
}
}
ignoreSetSelectedGameObjectOnUIByGamepad = false;
if (state) {
lastTimeCursorEnabled = Time.time;
} else {
lastTimeCursorDisabled = Time.time;
}
}
IEnumerator FocusButton ()
{
yield return null;
GKC_Utils.setSelectedGameObjectOnUI (true, false, null, showDebugPrint);
}
public void resetCursorPosition ()
{
if (!ignoreMouseCursorUpdateActive) {
updateGetCursorPos ();
}
cursorPosition.x = cursorPos.X;
cursorPosition.y = cursorPos.Y;
if (!mouseLimitsAssigned) {
currentResolution = new Vector2 (Screen.currentResolution.width, Screen.currentResolution.height);
mouseLimits = currentResolution;
mouseLimitsAssigned = true;
}
newX = cursorPosition.x;
newY = cursorPosition.y;
if (!ignoreMouseCursorUpdateActive) {
updateSetCursorPos ((int)cursorPosition.x, (int)cursorPosition.y);
updateGetCursorPos ();
}
}
void updateSetCursorPos (int cursorPositionX, int cursorPositionY)
{
if (useTryCatchOnUpdateCursorActive) {
try {
SetCursorPos (cursorPositionX, cursorPositionY);
}
catch (Exception e) {
print (e + " updateSetCursorPos error");
throw;
}
} else {
SetCursorPos (cursorPositionX, cursorPositionY);
}
}
void updateGetCursorPos ()
{
if (useTryCatchOnUpdateCursorActive) {
try {
GetCursorPos (out cursorPos);
}
catch (Exception e) {
print (e + " updateGetCursorPos error");
throw;
}
} else {
GetCursorPos (out cursorPos);
}
}
public Point getCursorPos ()
{
return cursorPos;
}
public void setUseRightOrLeftJoysticsAxis (bool state)
{
useRightJoystickAxis = state;
}
public int getCurrentJoystickNumber ()
{
return joystickNumber;
}
public void setMouseCursorControllerSpeedOnGameValue (float newValue)
{
if (originalCursorSpeedOnGame == -1) {
originalCursorSpeedOnGame = cursorSpeedOnGame;
}
cursorSpeedOnGame = newValue;
}
public void setOriginalMouseCursorControllerSpeedOnGameValue ()
{
if (originalCursorSpeedOnGame != -1) {
setMouseCursorControllerSpeedOnGameValue (originalCursorSpeedOnGame);
}
}
[System.Serializable]
public struct Point
{
public int X;
public int Y;
public Point (int x, int y)
{
this.X = x;
this.Y = y;
}
}
public Vector2 getMouseAxis ()
{
if (playerInputLocated) {
if (cursorCurrentlyActive) {
return playerInput.getRealMouseGamepadAxisInput ();
} else {
return playerInput.getRealMouseAxisInput ();
}
} else {
return new Vector2 (Input.GetAxis (mouseXPlayerIDString), Input.GetAxis (mouseYPlayerIDString)) +
new Vector2 (Input.GetAxis (mouseXString), Input.GetAxis (mouseYString));
}
}
public Vector2 getMovementAxis ()
{
if (playerInputLocated) {
if (cursorCurrentlyActive) {
return playerInput.getRealMovementGamepadAxisInput ();
} else {
return playerInput.getRealMovementAxisInput ();
}
} else {
return new Vector2 (Input.GetAxis (horizontalXPlayerIDString), Input.GetAxis (vertircalYPlayerIDString)) +
new Vector2 (Input.GetAxis (horizontalXString), Input.GetAxis (verticalYString));
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 810916f09b7a0fe458d82da92d0445cc
timeCreated: 1482847805
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/mouseCursorController.cs
uploadId: 814740

View File

@@ -0,0 +1,69 @@
using System;
using System.Runtime.InteropServices;
public class MouseOperations
{
[Flags]
public enum MouseEventFlags
{
LeftDown = 0x00000002,
LeftUp = 0x00000004,
MiddleDown = 0x00000020,
MiddleUp = 0x00000040,
Move = 0x00000001,
Absolute = 0x00008000,
RightDown = 0x00000008,
RightUp = 0x00000010
}
[DllImport ("user32.dll", EntryPoint = "SetCursorPos")]
[return: MarshalAs (UnmanagedType.Bool)]
private static extern bool SetCursorPos (int X, int Y);
[DllImport ("user32.dll")]
[return: MarshalAs (UnmanagedType.Bool)]
private static extern bool GetCursorPos (out MousePoint lpMousePoint);
[DllImport ("user32.dll")]
private static extern void mouse_event (int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
public static void SetCursorPosition (int X, int Y)
{
SetCursorPos (X, Y);
}
public static void SetCursorPosition (MousePoint point)
{
SetCursorPos (point.X, point.Y);
}
public static MousePoint GetCursorPosition ()
{
MousePoint currentMousePoint;
var gotPoint = GetCursorPos (out currentMousePoint);
if (!gotPoint) {
currentMousePoint = new MousePoint (0, 0);
}
return currentMousePoint;
}
public static void MouseEvent (MouseEventFlags value)
{
MousePoint position = GetCursorPosition ();
mouse_event
((int)value, position.X, position.Y, 0, 0);
}
[StructLayout (LayoutKind.Sequential)]
public struct MousePoint
{
public int X;
public int Y;
public MousePoint (int x, int y)
{
X = x;
Y = y;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 6d43275b36dc3ca44ac5978349471945
timeCreated: 1473441081
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/mouseOperations.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 214a6fdb62fb2de4d885c7dc8e6838b9
timeCreated: 1580456495
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: f58cd3506fd5a9c4cae4a5bf9cfd6e57, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/playerInputManager.cs
uploadId: 814740

View File

@@ -0,0 +1,814 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class playerInputPanelSystem : MonoBehaviour
{
public bool screenActionPanelsEnabled = true;
public bool screenActionPanelsActive = true;
public List<screenActionInfo> screenActionInfoList = new List<screenActionInfo> ();
public List<touchPanelsInfo> touchPanelsInfoList = new List<touchPanelsInfo> ();
public List<touchPanelsSchemesInfo> touchPanelsSchemesInfoList = new List<touchPanelsSchemesInfo> ();
public GameObject screenActionParent;
public playerInputManager playerInput;
public GameObject inputPanelPrefab;
public inputPanelUISystem mainInputPanelUISystem;
public bool instantiateInputPanelUIIfNotFound = true;
public menuPause pauseManager;
touchPanelsSchemesInfo currentTouchPanelsSchemesInfo;
touchPanelsSchemesInfo previousTouchPanelsSchemesInfo;
screenActionInfo currentScreenActionInfo;
screenActionInfo previousScreenActionInfo;
bool mainInputPanelUISystemFound;
bool panelParentActivePreviously;
void getInputPanelUISystem ()
{
if (mainInputPanelUISystem != null) {
mainInputPanelUISystemFound = true;
} else {
if (mainInputPanelUISystem == null) {
mainInputPanelUISystem = FindObjectOfType<inputPanelUISystem> ();
}
if (mainInputPanelUISystem != null) {
mainInputPanelUISystemFound = true;
}
}
if (mainInputPanelUISystemFound) {
screenActionInfoList = mainInputPanelUISystem.screenActionInfoList;
}
}
void checkInputPanelUISystem ()
{
if (!mainInputPanelUISystemFound) {
bool tutorialFound = false;
if (instantiateInputPanelUIIfNotFound) {
instantiateInputPanelPrefab ();
getInputPanelUISystem ();
if (mainInputPanelUISystemFound) {
tutorialFound = true;
}
}
if (!tutorialFound) {
print ("WARNING: No Input Panel UI system found, make sure to drop it on the scene");
return;
}
}
}
public void setInputPanelGameObjectActiveState (bool state)
{
if (mainInputPanelUISystemFound) {
mainInputPanelUISystem.setInputPanelGameObjectActiveState (state);
}
}
//Touch panels functions
public List<touchPanelsInfo> getTouchPanelsList ()
{
return touchPanelsInfoList;
}
public void enableTouchPanelByName (string panelName)
{
enableOrDisableTouchPanelByName (panelName, true);
}
public void disableTouchPanelByName (string panelName)
{
enableOrDisableTouchPanelByName (panelName, false);
}
public void enableOrDisableTouchPanelByName (string panelName, bool state)
{
for (int i = 0; i < touchPanelsInfoList.Count; i++) {
if (touchPanelsInfoList [i].Name.Equals (panelName) && touchPanelsInfoList [i].touchPanel.activeSelf != state) {
touchPanelsInfoList [i].touchPanel.SetActive (state);
}
}
playerInput.resetButtonStateOnTouchButtonList ();
}
public void enableTouchPanelSchemeByName (string panelName)
{
bool isMainGameTouchPanel = false;
for (int i = 0; i < touchPanelsSchemesInfoList.Count; i++) {
if (touchPanelsSchemesInfoList [i].Name.Equals (panelName)) {
if (previousTouchPanelsSchemesInfo != currentTouchPanelsSchemesInfo) {
previousTouchPanelsSchemesInfo = currentTouchPanelsSchemesInfo;
}
currentTouchPanelsSchemesInfo = touchPanelsSchemesInfoList [i];
currentTouchPanelsSchemesInfo.currentTouchPanelScheme = true;
for (int j = 0; j < touchPanelsInfoList.Count; j++) {
if (currentTouchPanelsSchemesInfo.enabledPanels.Contains (touchPanelsInfoList [j].touchPanel)) {
if (!touchPanelsInfoList [j].touchPanel.activeSelf) {
touchPanelsInfoList [j].touchPanel.SetActive (true);
}
} else {
if (touchPanelsInfoList [j].touchPanel.activeSelf) {
touchPanelsInfoList [j].touchPanel.SetActive (false);
}
}
}
if (currentTouchPanelsSchemesInfo.isMainGameTouchPanel) {
currentTouchPanelsSchemesInfo.mainGameTouchPanelActive = true;
isMainGameTouchPanel = true;
}
} else {
touchPanelsSchemesInfoList [i].currentTouchPanelScheme = false;
}
}
if (isMainGameTouchPanel) {
for (int i = 0; i < touchPanelsSchemesInfoList.Count; i++) {
if (touchPanelsSchemesInfoList [i].Name != panelName) {
if (touchPanelsSchemesInfoList [i].isMainGameTouchPanel) {
touchPanelsSchemesInfoList [i].mainGameTouchPanelActive = false;
}
}
}
}
playerInput.resetButtonStateOnTouchButtonList ();
}
public void enableCurrentMainTouchPanelScheme ()
{
for (int i = 0; i < touchPanelsSchemesInfoList.Count; i++) {
if (touchPanelsSchemesInfoList [i].isMainGameTouchPanel && touchPanelsSchemesInfoList [i].mainGameTouchPanelActive) {
enableTouchPanelSchemeByName (touchPanelsSchemesInfoList [i].Name);
return;
}
}
}
public void enablePreviousTouchPanelScheme ()
{
if (previousTouchPanelsSchemesInfo != null) {
enableTouchPanelSchemeByName (previousTouchPanelsSchemesInfo.Name);
}
}
//Action Screen Panels Functions
public void enableOrDisableActionScreen (string actionScreenName)
{
if (canUseActionPanel ()) {
checkInputPanelUISystem ();
int screenActionInfoListCount = screenActionInfoList.Count;
if (screenActionInfoListCount == 0) {
return;
}
for (int i = 0; i < screenActionInfoListCount; i++) {
if (screenActionInfoList [i].screenActionName.Equals (actionScreenName)) {
if (previousScreenActionInfo != currentScreenActionInfo) {
previousScreenActionInfo = currentScreenActionInfo;
}
currentScreenActionInfo = screenActionInfoList [i];
if (currentScreenActionInfo.screenActionsGameObject != null) {
if (currentScreenActionInfo.screenActionsGameObject.activeSelf != (!currentScreenActionInfo.screenActionsGameObject.activeSelf)) {
currentScreenActionInfo.screenActionsGameObject.SetActive (!currentScreenActionInfo.screenActionsGameObject.activeSelf);
}
}
if (playerInput.isUsingGamepad ()) {
if (currentScreenActionInfo.screenActionsGamepadGameObject != null) {
if (currentScreenActionInfo.screenActionsGamepadGameObject.activeSelf != (!currentScreenActionInfo.screenActionsGamepadGameObject.activeSelf)) {
currentScreenActionInfo.screenActionsGamepadGameObject.SetActive (!currentScreenActionInfo.screenActionsGamepadGameObject.activeSelf);
}
}
if (currentScreenActionInfo.mainScreenActionGameObject != null && currentScreenActionInfo.mainScreenActionGameObject.activeSelf) {
currentScreenActionInfo.mainScreenActionGameObject.SetActive (false);
}
} else {
if (currentScreenActionInfo.mainScreenActionGameObject != null) {
if (currentScreenActionInfo.mainScreenActionGameObject.activeSelf != (!currentScreenActionInfo.mainScreenActionGameObject.activeSelf)) {
currentScreenActionInfo.mainScreenActionGameObject.SetActive (!currentScreenActionInfo.mainScreenActionGameObject.activeSelf);
}
}
if (currentScreenActionInfo.screenActionsGamepadGameObject != null && currentScreenActionInfo.screenActionsGamepadGameObject.activeSelf) {
currentScreenActionInfo.screenActionsGamepadGameObject.SetActive (false);
}
}
return;
}
}
}
}
public void enableOrDisableActionScreenTemporally (string actionScreenName)
{
if (canUseActionPanel ()) {
checkInputPanelUISystem ();
int screenActionInfoListCount = screenActionInfoList.Count;
if (screenActionInfoListCount == 0) {
return;
}
for (int i = 0; i < screenActionInfoListCount; i++) {
if (screenActionInfoList [i].screenActionName.Equals (actionScreenName)) {
if (screenActionInfoList [i].screenActionsGameObject != null) {
if (screenActionInfoList [i].screenActionsGameObject.activeSelf != (!screenActionInfoList [i].screenActionsGameObject.activeSelf)) {
screenActionInfoList [i].screenActionsGameObject.SetActive (!screenActionInfoList [i].screenActionsGameObject.activeSelf);
}
}
if (playerInput.isUsingGamepad ()) {
if (screenActionInfoList [i].screenActionsGamepadGameObject != null) {
if (screenActionInfoList [i].screenActionsGamepadGameObject.activeSelf != (!screenActionInfoList [i].screenActionsGamepadGameObject.activeSelf)) {
screenActionInfoList [i].screenActionsGamepadGameObject.SetActive (!screenActionInfoList [i].screenActionsGamepadGameObject.activeSelf);
}
}
if (screenActionInfoList [i].mainScreenActionGameObject != null && screenActionInfoList [i].mainScreenActionGameObject.activeSelf) {
screenActionInfoList [i].mainScreenActionGameObject.SetActive (false);
}
} else {
if (screenActionInfoList [i].mainScreenActionGameObject != null) {
if (screenActionInfoList [i].mainScreenActionGameObject.activeSelf != (!screenActionInfoList [i].mainScreenActionGameObject.activeSelf)) {
screenActionInfoList [i].mainScreenActionGameObject.SetActive (!screenActionInfoList [i].mainScreenActionGameObject.activeSelf);
}
}
if (screenActionInfoList [i].screenActionsGamepadGameObject != null && screenActionInfoList [i].screenActionsGamepadGameObject.activeSelf) {
screenActionInfoList [i].screenActionsGamepadGameObject.SetActive (false);
}
}
return;
}
}
}
}
public void enableOrDisableActionScreen (string actionScreenName, bool state)
{
if (canUseActionPanel ()) {
checkInputPanelUISystem ();
int screenActionInfoListCount = screenActionInfoList.Count;
if (screenActionInfoListCount == 0) {
return;
}
for (int i = 0; i < screenActionInfoListCount; i++) {
if (screenActionInfoList [i].screenActionName.Equals (actionScreenName)) {
if (previousScreenActionInfo != currentScreenActionInfo) {
previousScreenActionInfo = currentScreenActionInfo;
}
currentScreenActionInfo = screenActionInfoList [i];
if (currentScreenActionInfo.screenActionsGameObject != null && currentScreenActionInfo.screenActionsGameObject.activeSelf != state) {
currentScreenActionInfo.screenActionsGameObject.SetActive (state);
}
if (playerInput.isUsingGamepad ()) {
if (currentScreenActionInfo.screenActionsGamepadGameObject != null && currentScreenActionInfo.screenActionsGamepadGameObject != state) {
currentScreenActionInfo.screenActionsGamepadGameObject.SetActive (state);
}
if (currentScreenActionInfo.mainScreenActionGameObject != null && currentScreenActionInfo.mainScreenActionGameObject.activeSelf) {
currentScreenActionInfo.mainScreenActionGameObject.SetActive (false);
}
} else {
if (currentScreenActionInfo.mainScreenActionGameObject != null && currentScreenActionInfo.mainScreenActionGameObject.activeSelf != state) {
currentScreenActionInfo.mainScreenActionGameObject.SetActive (state);
}
if (currentScreenActionInfo.screenActionsGamepadGameObject != null && currentScreenActionInfo.screenActionsGamepadGameObject.activeSelf) {
currentScreenActionInfo.screenActionsGamepadGameObject.SetActive (false);
}
}
if (state) {
if (!screenActionParent.activeSelf) {
if (screenActionPanelsActive) {
screenActionParent.SetActive (true);
}
}
}
if (state) {
checkDisableMainGameScreenActionPanel ();
} else {
checkEnableMainGameScreenActionPanel ();
}
return;
}
}
}
}
public void enableActionScreen (string actionScreenName)
{
if (canUseActionPanel ()) {
checkInputPanelUISystem ();
int screenActionInfoListCount = screenActionInfoList.Count;
if (screenActionInfoListCount == 0) {
return;
}
for (int i = 0; i < screenActionInfoListCount; i++) {
if (screenActionInfoList [i].screenActionName.Equals (actionScreenName)) {
if (previousScreenActionInfo != currentScreenActionInfo) {
previousScreenActionInfo = currentScreenActionInfo;
}
currentScreenActionInfo = screenActionInfoList [i];
if (currentScreenActionInfo.screenActionsGameObject != null && !currentScreenActionInfo.screenActionsGameObject.activeSelf) {
currentScreenActionInfo.screenActionsGameObject.SetActive (true);
}
if (playerInput.isUsingGamepad ()) {
if (currentScreenActionInfo.screenActionsGamepadGameObject != null && !currentScreenActionInfo.screenActionsGamepadGameObject.activeSelf) {
currentScreenActionInfo.screenActionsGamepadGameObject.SetActive (true);
}
if (currentScreenActionInfo.mainScreenActionGameObject != null && currentScreenActionInfo.mainScreenActionGameObject.activeSelf) {
currentScreenActionInfo.mainScreenActionGameObject.SetActive (false);
}
} else {
if (currentScreenActionInfo.mainScreenActionGameObject != null && !currentScreenActionInfo.mainScreenActionGameObject.activeSelf) {
currentScreenActionInfo.mainScreenActionGameObject.SetActive (true);
}
if (currentScreenActionInfo.screenActionsGamepadGameObject != null && currentScreenActionInfo.screenActionsGamepadGameObject.activeSelf) {
currentScreenActionInfo.screenActionsGamepadGameObject.SetActive (false);
}
}
return;
}
}
}
}
public void disableActionScreen (string actionScreenName)
{
if (canUseActionPanel ()) {
checkInputPanelUISystem ();
int screenActionInfoListCount = screenActionInfoList.Count;
if (screenActionInfoListCount == 0) {
return;
}
for (int i = 0; i < screenActionInfoListCount; i++) {
if (screenActionInfoList [i].screenActionName.Equals (actionScreenName)) {
if (previousScreenActionInfo != currentScreenActionInfo) {
previousScreenActionInfo = currentScreenActionInfo;
}
currentScreenActionInfo = screenActionInfoList [i];
if (currentScreenActionInfo.screenActionsGameObject != null && currentScreenActionInfo.screenActionsGameObject.activeSelf) {
currentScreenActionInfo.screenActionsGameObject.SetActive (false);
}
if (currentScreenActionInfo.mainScreenActionGameObject != null && currentScreenActionInfo.mainScreenActionGameObject.activeSelf) {
currentScreenActionInfo.mainScreenActionGameObject.SetActive (false);
}
if (currentScreenActionInfo.screenActionsGamepadGameObject != null && currentScreenActionInfo.screenActionsGamepadGameObject.activeSelf) {
currentScreenActionInfo.screenActionsGamepadGameObject.SetActive (false);
}
if (currentScreenActionInfo.isMainGameScreenActionPanel) {
currentScreenActionInfo.mainGameScreenActionPanelActive = false;
}
return;
}
}
}
}
public void enablePreviousActionScreen ()
{
if (canUseActionPanel ()) {
if (previousScreenActionInfo != null && currentScreenActionInfo != null) {
if (currentScreenActionInfo != previousScreenActionInfo) {
enableSingleActionScreen (previousScreenActionInfo.screenActionName);
}
} else {
if (currentScreenActionInfo != null) {
disableActionScreen (currentScreenActionInfo.screenActionName);
}
currentScreenActionInfo = null;
previousScreenActionInfo = null;
}
}
}
public void enableSingleActionScreen (string actionScreenName)
{
if (canUseActionPanel ()) {
checkInputPanelUISystem ();
int screenActionInfoListCount = screenActionInfoList.Count;
if (screenActionInfoListCount == 0) {
return;
}
for (int i = 0; i < screenActionInfoListCount; i++) {
if (screenActionInfoList [i].screenActionName.Equals (actionScreenName)) {
if (previousScreenActionInfo != currentScreenActionInfo) {
previousScreenActionInfo = currentScreenActionInfo;
}
currentScreenActionInfo = screenActionInfoList [i];
if (currentScreenActionInfo.screenActionsGameObject != null && !currentScreenActionInfo.screenActionsGameObject.activeSelf) {
currentScreenActionInfo.screenActionsGameObject.SetActive (true);
}
if (playerInput.isUsingGamepad ()) {
if (currentScreenActionInfo.screenActionsGamepadGameObject != null && !currentScreenActionInfo.screenActionsGamepadGameObject.activeSelf) {
currentScreenActionInfo.screenActionsGamepadGameObject.SetActive (true);
}
if (currentScreenActionInfo.mainScreenActionGameObject != null && currentScreenActionInfo.mainScreenActionGameObject.activeSelf) {
currentScreenActionInfo.mainScreenActionGameObject.SetActive (false);
}
} else {
if (currentScreenActionInfo.mainScreenActionGameObject != null && !currentScreenActionInfo.mainScreenActionGameObject.activeSelf) {
currentScreenActionInfo.mainScreenActionGameObject.SetActive (true);
}
if (currentScreenActionInfo.screenActionsGamepadGameObject != null && currentScreenActionInfo.screenActionsGamepadGameObject.activeSelf) {
currentScreenActionInfo.screenActionsGamepadGameObject.SetActive (false);
}
}
if (currentScreenActionInfo.isMainGameScreenActionPanel) {
currentScreenActionInfo.mainGameScreenActionPanelActive = true;
}
} else {
if (screenActionInfoList [i].screenActionsGameObject != null && screenActionInfoList [i].screenActionsGameObject.activeSelf) {
screenActionInfoList [i].screenActionsGameObject.SetActive (false);
}
if (screenActionInfoList [i].mainScreenActionGameObject != null && screenActionInfoList [i].mainScreenActionGameObject.activeSelf) {
screenActionInfoList [i].mainScreenActionGameObject.SetActive (false);
}
if (screenActionInfoList [i].screenActionsGamepadGameObject != null && screenActionInfoList [i].screenActionsGamepadGameObject.activeSelf) {
screenActionInfoList [i].screenActionsGamepadGameObject.SetActive (false);
}
}
}
}
}
public void checkEnableMainGameScreenActionPanel ()
{
if (!screenActionPanelsEnabled) {
return;
}
checkInputPanelUISystem ();
int screenActionInfoListCount = screenActionInfoList.Count;
if (screenActionInfoListCount == 0) {
return;
}
for (int i = 0; i < screenActionInfoListCount; i++) {
if (screenActionInfoList [i].isMainGameScreenActionPanel && screenActionInfoList [i].mainGameScreenActionPanelActive) {
enableSingleActionScreen (screenActionInfoList [i].screenActionName);
return;
}
}
}
public void enableSecondaryActionPanel (string actionScreenName)
{
enableOrDisableSecondaryActionPanel (actionScreenName, true);
}
public void disableSecondaryActionPanel (string actionScreenName)
{
enableOrDisableSecondaryActionPanel (actionScreenName, false);
}
public void enableOrDisableSecondaryActionPanel (string actionScreenName, bool state)
{
checkInputPanelUISystem ();
int screenActionInfoListCount = screenActionInfoList.Count;
if (screenActionInfoListCount == 0) {
return;
}
for (int i = 0; i < screenActionInfoListCount; i++) {
if (screenActionInfoList [i].screenActionName.Equals (actionScreenName)) {
if (playerInput.isUsingGamepad ()) {
if (screenActionInfoList [i].secondaryActionPanelGamepadGameObject != null && screenActionInfoList [i].secondaryActionPanelGamepadGameObject.activeSelf != state) {
screenActionInfoList [i].secondaryActionPanelGamepadGameObject.SetActive (state);
}
if (screenActionInfoList [i].secondaryActionPanelGameObject != null && screenActionInfoList [i].secondaryActionPanelGameObject.activeSelf) {
screenActionInfoList [i].secondaryActionPanelGameObject.SetActive (false);
}
} else {
if (screenActionInfoList [i].secondaryActionPanelGameObject != null && screenActionInfoList [i].secondaryActionPanelGameObject.activeSelf != state) {
screenActionInfoList [i].secondaryActionPanelGameObject.SetActive (state);
}
if (screenActionInfoList [i].secondaryActionPanelGamepadGameObject != null && screenActionInfoList [i].secondaryActionPanelGamepadGameObject.activeSelf) {
screenActionInfoList [i].secondaryActionPanelGamepadGameObject.SetActive (false);
}
}
return;
}
}
}
public void checkDisableMainGameScreenActionPanel ()
{
if (!screenActionPanelsEnabled) {
return;
}
checkInputPanelUISystem ();
int screenActionInfoListCount = screenActionInfoList.Count;
if (screenActionInfoListCount == 0) {
return;
}
for (int i = 0; i < screenActionInfoListCount; i++) {
if (screenActionInfoList [i].isMainGameScreenActionPanel && screenActionInfoList [i].mainGameScreenActionPanelActive) {
if (screenActionInfoList [i].screenActionsGameObject != null && screenActionInfoList [i].screenActionsGameObject.activeSelf) {
screenActionInfoList [i].screenActionsGameObject.SetActive (false);
}
if (screenActionInfoList [i].mainScreenActionGameObject != null && screenActionInfoList [i].mainScreenActionGameObject.activeSelf) {
screenActionInfoList [i].mainScreenActionGameObject.SetActive (false);
}
if (screenActionInfoList [i].screenActionsGamepadGameObject != null && screenActionInfoList [i].screenActionsGamepadGameObject.activeSelf) {
screenActionInfoList [i].screenActionsGamepadGameObject.SetActive (false);
}
return;
}
}
}
public void checkPanelsActiveOnGamepadOrKeyboard (bool checkKeyboard)
{
if (!screenActionPanelsEnabled) {
return;
}
checkInputPanelUISystem ();
int screenActionInfoListCount = screenActionInfoList.Count;
if (screenActionInfoListCount == 0) {
return;
}
for (int i = 0; i < screenActionInfoListCount; i++) {
if (checkKeyboard) {
if (screenActionInfoList [i].screenActionsGameObject != null) {
if (screenActionInfoList [i].screenActionsGameObject.activeSelf) {
if (screenActionInfoList [i].mainScreenActionGameObject != null &&
!screenActionInfoList [i].mainScreenActionGameObject.activeSelf) {
screenActionInfoList [i].mainScreenActionGameObject.SetActive (true);
}
if (screenActionInfoList [i].hasSecondaryActionPanel &&
screenActionInfoList [i].secondaryActionPanelGameObject != null &&
!screenActionInfoList [i].secondaryActionPanelGameObject.activeSelf) {
screenActionInfoList [i].secondaryActionPanelGameObject.SetActive (true);
}
if (screenActionInfoList [i].screenActionsGamepadGameObject != null &&
screenActionInfoList [i].screenActionsGamepadGameObject.activeSelf) {
screenActionInfoList [i].screenActionsGamepadGameObject.SetActive (false);
}
if (screenActionInfoList [i].secondaryActionPanelGamepadGameObject != null &&
screenActionInfoList [i].secondaryActionPanelGamepadGameObject.activeSelf) {
screenActionInfoList [i].secondaryActionPanelGamepadGameObject.SetActive (false);
}
}
}
} else {
if (screenActionInfoList [i].screenActionsGameObject != null) {
if (screenActionInfoList [i].screenActionsGameObject.activeSelf) {
if (screenActionInfoList [i].secondaryActionPanelGameObject != null &&
screenActionInfoList [i].secondaryActionPanelGameObject.activeSelf) {
screenActionInfoList [i].secondaryActionPanelGameObject.SetActive (false);
}
if (screenActionInfoList [i].mainScreenActionGameObject != null &&
screenActionInfoList [i].mainScreenActionGameObject.activeSelf) {
screenActionInfoList [i].mainScreenActionGameObject.SetActive (false);
}
if (screenActionInfoList [i].screenActionsGamepadGameObject != null &&
!screenActionInfoList [i].screenActionsGamepadGameObject.activeSelf) {
screenActionInfoList [i].screenActionsGamepadGameObject.SetActive (true);
}
if (screenActionInfoList [i].hasSecondaryActionPanel &&
screenActionInfoList [i].secondaryActionPanelGamepadGameObject != null &&
!screenActionInfoList [i].secondaryActionPanelGamepadGameObject.activeSelf) {
screenActionInfoList [i].secondaryActionPanelGamepadGameObject.SetActive (true);
}
}
}
}
}
}
public void enableOrDisableScreenActionParent (bool state)
{
if (!screenActionPanelsActive) {
return;
}
if (state && playerInput.isUsingTouchControlsOnGameManager ()) {
return;
}
if (screenActionParent != null && screenActionParent.activeSelf != state) {
screenActionParent.SetActive (state);
}
}
public bool canUseActionPanel ()
{
if (!screenActionPanelsEnabled) {
return false;
}
if (!screenActionPanelsActive) {
return false;
}
if (playerInput.isUsingTouchControls ()) {
return false;
}
return true;
}
public void setScreenActionPanelsActiveState (bool state)
{
if (screenActionParent == null) {
return;
}
if (screenActionPanelsActive) {
panelParentActivePreviously = screenActionParent.activeSelf;
}
screenActionPanelsActive = state;
if (screenActionPanelsActive) {
if (panelParentActivePreviously) {
if (playerInput.isUsingTouchControlsOnGameManager ()) {
return;
}
if (!screenActionParent.activeSelf) {
screenActionParent.SetActive (true);
}
}
} else {
if (screenActionParent.activeSelf) {
screenActionParent.SetActive (false);
}
}
}
public void setScreenActionPanelsActiveStateFromEditor (bool state)
{
setScreenActionPanelsActiveState (state);
updateComponent ();
}
public void setScreenActionPanelsEnabledState (bool state)
{
screenActionPanelsEnabled = state;
updateComponent ();
}
public void instantiateInputPanelPrefab ()
{
if (mainInputPanelUISystem == null && inputPanelPrefab != null) {
GameObject newInputPanel = (GameObject)Instantiate (inputPanelPrefab, Vector3.zero, Quaternion.identity);
newInputPanel.name = inputPanelPrefab.name;
inputPanelUISystem currentInputPanelUISystem = newInputPanel.GetComponentInChildren<inputPanelUISystem> ();
if (currentInputPanelUISystem != null) {
currentInputPanelUISystem.searchPlayerInputPanelSystem (this);
// pauseManager.addNewCanvasToList (newInputPanel.GetComponent<Canvas> ());
GKC_Utils.updateCanvasValuesByPlayer (null, pauseManager.gameObject, newInputPanel);
}
} else {
print ("Player Input Panel is already on the scene");
}
}
public void setInputPanelUISystem (inputPanelUISystem newInputPanelUISystem)
{
mainInputPanelUISystem = newInputPanelUISystem;
screenActionParent = mainInputPanelUISystem.screenActionParent;
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Player Input Panel System", gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: beecf30d914e11540be28b0eb10ef74a
timeCreated: 1580992795
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/playerInputPanelSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,73 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerInputPauseSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool pauseInputListDuringActionActiveAlways = true;
[Space]
[Header ("Input Category Info List Settings")]
[Space]
public List<inputCategoryInfo> inputCategoryInfoList = new List<inputCategoryInfo> ();
[Space]
[Header ("Components")]
[Space]
public playerInputManager mainPlayerInputManager;
inputInfo currentInputInfo;
public void pauseInputByCategory (string categoryName)
{
for (int i = 0; i < inputCategoryInfoList.Count; i++) {
if (inputCategoryInfoList [i].Name.Equals (categoryName)) {
for (int j = 0; j < inputCategoryInfoList [i].inputInfoList.Count; j++) {
currentInputInfo = inputCategoryInfoList [i].inputInfoList [j];
currentInputInfo.previousActiveState =
mainPlayerInputManager.setPlayerInputMultiAxesStateAndGetPreviousState (false, currentInputInfo.inputName);
}
}
}
}
public void resumeInputByCategory (string categoryName)
{
for (int i = 0; i < inputCategoryInfoList.Count; i++) {
if (inputCategoryInfoList [i].Name.Equals (categoryName)) {
for (int j = 0; j < inputCategoryInfoList [i].inputInfoList.Count; j++) {
currentInputInfo = inputCategoryInfoList [i].inputInfoList [j];
if (currentInputInfo.previousActiveState) {
mainPlayerInputManager.setPlayerInputMultiAxesState (currentInputInfo.previousActiveState, currentInputInfo.inputName);
}
}
}
}
}
[System.Serializable]
public class inputCategoryInfo
{
public string Name;
public List<inputInfo> inputInfoList = new List<inputInfo> ();
}
[System.Serializable]
public class inputInfo
{
public string inputName;
public bool previousActiveState;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8a8dc3fddeae5334e97434051d513b46
timeCreated: 1588696973
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/playerInputPauseSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,158 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class pressMultipleKeysActionInputSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool checkPressKeysEnabled = true;
public int numberOfKeysToPress;
public bool resetNumberOfKeysPressedAtEnd;
public bool pressKeysInOrder;
[Space]
[Header ("Reset Keys Settings")]
[Space]
public bool resetNumberOfKeysPressedIfNotCorrectOrder;
public bool resetNumberOfKeysAfterDelay;
public float maxDelayToPressKeys;
public bool cancelActionIfMaxDelayReached;
[Space]
[Header ("Debug")]
[Space]
public int currentNumberOfKeysPressed;
public bool showDebugPrint;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventToUseOnKeysPressed;
float lastTimeKeyPressed;
public void setPressedKeyState (bool state)
{
if (!checkPressKeysEnabled) {
return;
}
if (checkIfDelayComplete ()) {
if (cancelActionIfMaxDelayReached) {
if (showDebugPrint) {
print ("cancelling action");
}
return;
}
}
if (state) {
currentNumberOfKeysPressed++;
if (showDebugPrint) {
print ("increasing counter");
}
} else {
currentNumberOfKeysPressed--;
if (showDebugPrint) {
print ("decreasing counter");
}
}
if (currentNumberOfKeysPressed >= numberOfKeysToPress) {
eventToUseOnKeysPressed.Invoke ();
if (resetNumberOfKeysPressedAtEnd) {
currentNumberOfKeysPressed = 0;
}
if (showDebugPrint) {
print ("Action activated, reseting");
}
}
lastTimeKeyPressed = Time.time;
}
public void setPressedKeyStateInOrder (int pressedKeyID)
{
if (!checkPressKeysEnabled) {
return;
}
if (checkIfDelayComplete ()) {
if (cancelActionIfMaxDelayReached) {
if (showDebugPrint) {
print ("cancelling action");
}
return;
}
}
if (currentNumberOfKeysPressed == pressedKeyID) {
currentNumberOfKeysPressed++;
if (showDebugPrint) {
print ("increasing counter");
}
} else {
if (resetNumberOfKeysPressedIfNotCorrectOrder) {
currentNumberOfKeysPressed = 0;
}
}
if (currentNumberOfKeysPressed >= numberOfKeysToPress) {
eventToUseOnKeysPressed.Invoke ();
if (resetNumberOfKeysPressedAtEnd) {
currentNumberOfKeysPressed = 0;
}
if (showDebugPrint) {
print ("Action activated, reseting");
}
}
lastTimeKeyPressed = Time.time;
}
public void setCheckPressKeysEnabledState (bool state)
{
checkPressKeysEnabled = state;
}
bool checkIfDelayComplete ()
{
if (resetNumberOfKeysAfterDelay) {
if (lastTimeKeyPressed > 0 && Time.time > lastTimeKeyPressed + maxDelayToPressKeys) {
currentNumberOfKeysPressed = 0;
lastTimeKeyPressed = 0;
if (showDebugPrint) {
print ("Pressed out of time, cancelling action");
}
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: b9eb0c452082bab4abe93fd83bfd2315
timeCreated: 1612170341
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/pressMultipleKeysActionInputSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,43 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class screenActionInfo
{
public string screenActionName;
public GameObject screenActionsGameObject;
public bool isMainGameScreenActionPanel;
public bool mainGameScreenActionPanelActive;
[Space]
public GameObject mainScreenActionGameObject;
[Space]
public bool hasSecondaryActionPanel;
public GameObject secondaryActionPanelGameObject;
[Space]
public GameObject screenActionsGamepadGameObject;
public GameObject secondaryActionPanelGamepadGameObject;
}
[System.Serializable]
public class touchPanelsInfo
{
public string Name;
public GameObject touchPanel;
}
[System.Serializable]
public class touchPanelsSchemesInfo
{
public string Name;
public bool currentTouchPanelScheme;
public List<GameObject> enabledPanels = new List<GameObject> ();
public bool isMainGameTouchPanel;
public bool mainGameTouchPanelActive;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: fdb3a8141592aeb4ebae54dc0af1c510
timeCreated: 1580994029
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/screenActionInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class showPlayerInputValues : MonoBehaviour
{
public Text inputText;
public playerInputManager playerInput;
void Update ()
{
inputText.text = playerInput.getPlayerMovementAxis ().ToString();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: c843e98ed4cfeb646aab8835a79e37f7
timeCreated: 1575358733
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/showPlayerInputValues.cs
uploadId: 814740

View File

@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class touchButtonColorChangeSystem : MonoBehaviour
{
public RawImage mainImage;
public Color regularColor;
public Color pressedColor;
public void setRegularColor ()
{
mainImage.color = regularColor;
}
public void setPressedColor ()
{
mainImage.color = pressedColor;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 088a308bc797c574caa5162942633171
timeCreated: 1561086124
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/touchButtonColorChangeSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,71 @@
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using System.Collections;
using UnityEngine.UI;
using System;
[System.Serializable]
//System to use touch buttons to check if the button is being pressing or released
public class touchButtonEventSystem : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
[Header ("Main Settings")]
[Space]
public bool eventEnabled;
[Space]
[Header ("Debug")]
[Space]
public bool buttonPressed;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnPressDown;
public UnityEvent eventOnPressUp;
//if you press the button
public void OnPointerDown (PointerEventData eventData)
{
if (eventEnabled) {
eventOnPressDown.Invoke ();
buttonPressed = true;
}
}
//if you release the button
public void OnPointerUp (PointerEventData eventData)
{
if (eventEnabled) {
eventOnPressUp.Invoke ();
buttonPressed = false;
}
}
public void setEventEnabledState (bool state)
{
eventEnabled = state;
if (buttonPressed) {
eventOnPressUp.Invoke ();
buttonPressed = false;
}
}
//if the button is disabled, reset the button
void OnDisable ()
{
if (eventEnabled && buttonPressed) {
eventOnPressUp.Invoke ();
buttonPressed = false;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 59c5928a7d7eb1949ba498be9f492cc9
timeCreated: 1588698396
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/touchButtonEventSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,164 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class touchScreenPinchSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool pinchEnabled = true;
public float minDistanceToUpdatePinch = 5;
[Space]
[Header ("Debug")]
[Space]
public bool firstMouseTouchActive;
public bool secondaryMouseTouchActive;
public int currentNumberOfTouchButtonsPressed;
public float initialDistance;
public float currentDistance;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnPinchIn;
public UnityEvent eventOnPinchOut;
[Space]
[Header ("Components")]
[Space]
public inputManager input;
public playerInputManager playerInput;
Touch secondaryMouseTouch;
bool touchPlatform;
Touch firstTouch;
Touch secondTouch;
float distanceDifference;
bool inputManagerLocated;
void Start ()
{
touchPlatform = touchJoystick.checkTouchPlatform ();
inputManagerLocated = input != null;
if (!inputManagerLocated) {
input = inputManager.Instance;
inputManagerLocated = input != null;
}
if (!inputManagerLocated) {
input = FindObjectOfType<inputManager> ();
input.getComponentInstanceOnApplicationPlaying ();
inputManagerLocated = input != null;
}
}
void Update ()
{
if (pinchEnabled && inputManagerLocated && input.isUsingTouchControls ()) {
updateTouchPinchScreen ();
}
}
void updateTouchPinchScreen ()
{
currentNumberOfTouchButtonsPressed = input.getCurrentNumberOfTouchButtonsPressed ();
int touchCount = Input.touchCount;
if (!touchPlatform) {
touchCount++;
if (Input.GetMouseButtonDown (1)) {
secondaryMouseTouchActive = !secondaryMouseTouchActive;
if (secondaryMouseTouchActive) {
secondTouch = touchJoystick.convertMouseIntoFinger ();
} else {
firstMouseTouchActive = false;
}
return;
}
if (secondaryMouseTouchActive) {
touchCount++;
}
}
if (touchCount >= 2) {
if (!touchPlatform) {
if (Input.GetMouseButtonDown (0)) {
firstMouseTouchActive = true;
}
if (Input.GetMouseButtonUp (0)) {
firstMouseTouchActive = false;
}
if (firstMouseTouchActive) {
firstTouch = touchJoystick.convertMouseIntoFinger ();
}
} else {
firstTouch = Input.GetTouch (0);
secondTouch = Input.GetTouch (1);
}
if (firstTouch.phase == TouchPhase.Began) {
if (initialDistance == 0) {
initialDistance = GKC_Utils.distance (firstTouch.position, secondTouch.position);
distanceDifference = 0;
}
}
if (currentNumberOfTouchButtonsPressed == 0 && !playerInput.areTouchJoysticksPressed ()) {
if ((touchPlatform || (firstMouseTouchActive && secondaryMouseTouchActive)) &&
(firstTouch.phase == TouchPhase.Moved || secondTouch.phase == TouchPhase.Moved)) {
currentDistance = GKC_Utils.distance (firstTouch.position, secondTouch.position);
distanceDifference = currentDistance - initialDistance;
if (Mathf.Abs (distanceDifference) > minDistanceToUpdatePinch) {
initialDistance = currentDistance;
if (distanceDifference < 0) {
eventOnPinchIn.Invoke ();
} else {
eventOnPinchOut.Invoke ();
}
}
}
}
} else {
if (initialDistance != 0) {
initialDistance = 0;
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a17950dd45ab8784db1cc5946f756138
timeCreated: 1611970022
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Input/touchScreenPinchSystem.cs
uploadId: 814740