CHANGE: Latest manual QA test scenes (#327).
This commit is contained in:
Родитель
51a33a82ef
Коммит
cefdf9a2df
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e22de6374d3589a48a68aadf9321a46c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,53 @@
|
|||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[InitializeOnLoad]
|
||||
public class ImportInputManagerAsset {
|
||||
|
||||
static private string m_inputTestAssetFile = "InputTest_InputManager.asset.backup";
|
||||
static private string m_defaultAssetFile = "default_InputManager.asset.backup";
|
||||
static private string m_inputAssetFile = "InputManager.asset";
|
||||
|
||||
// Import the Input Manager asset for Input Test and back up the current one for backup
|
||||
[MenuItem("QA Tools/Input Test/Import for Input Test")]
|
||||
static void ImportInputAssetForTest()
|
||||
{
|
||||
File.Copy(m_inputAssetFile, m_defaultAssetFile);
|
||||
File.Copy(m_inputTestAssetFile, m_inputAssetFile, true);
|
||||
//FileUtil.ReplaceFile("ProjectSettings/InputManager.asset", "Assets/QA/Input_Test/Editor/default_InputManager.asset");
|
||||
//FileUtil.ReplaceFile("Assets/QA/Input_Test/Editor/InputTest_InputManager.asset", "ProjectSettings/InputManager.asset");
|
||||
}
|
||||
|
||||
//[MenuItem("QA Tools/Input Test/Import for Input Test", true)]
|
||||
//static bool CheckIfCanImportInputAsset()
|
||||
//{
|
||||
// return !File.Exists(m_defaultAssetFile);
|
||||
//}
|
||||
|
||||
// Revert the Input Manager asset to the default one for the project
|
||||
[MenuItem("QA Tools/Input Test/Revert to Default")]
|
||||
static void RevertToDefaultInputAsset()
|
||||
{
|
||||
File.Copy(m_defaultAssetFile, m_inputAssetFile, true);
|
||||
File.Delete(m_defaultAssetFile);
|
||||
//FileUtil.ReplaceFile("Assets/QA/Input_Test/Editor/default_InputManager.asset", "ProjectSettings/InputManager.asset");
|
||||
//FileUtil.DeleteFileOrDirectory("Assets/QA/Input_Test/Editor/default_InputManager.asset");
|
||||
}
|
||||
|
||||
//[MenuItem("QA Tools/Input Test/Revert to Default", false)]
|
||||
//static bool CheckIfCanRevertInputAsset()
|
||||
//{
|
||||
// return File.Exists(m_defaultAssetFile);
|
||||
//}
|
||||
|
||||
// Use this for initialization
|
||||
static ImportInputManagerAsset()
|
||||
{
|
||||
m_inputTestAssetFile = Path.GetFullPath(Application.dataPath + "/QA/Input_Test/Editor/" + m_inputTestAssetFile);
|
||||
m_defaultAssetFile = Path.GetFullPath(Application.dataPath + "/QA/Input_Test/Editor/" + m_defaultAssetFile);
|
||||
m_inputAssetFile = Path.GetFullPath(Directory.GetCurrentDirectory() + "/ProjectSettings/" + m_inputAssetFile);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4c1b98378bc56504481e7c46fac65192
|
||||
guid: 6f12e38577396fc46ab2207c86987c80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -0,0 +1,455 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!13 &1
|
||||
InputManager:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Axes:
|
||||
- serializedVersion: 3
|
||||
m_Name: Mouse X
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0.1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 1
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Mouse Y
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0.1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 1
|
||||
axis: 1
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Mouse ScrollWheel
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0.1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 1
|
||||
axis: 2
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 1
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 2
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 1
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 3
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 2
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 4
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 3
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 5
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 4
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 6
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 5
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 7
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 6
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 8
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 7
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 9
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 8
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 10
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 9
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 11
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 10
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 12
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 11
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 13
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 12
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 14
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 13
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 15
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 14
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 16
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 15
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 17
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 16
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 18
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 17
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 19
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 18
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Axis 20
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 19
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Horizontal
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton: a
|
||||
positiveButton: d
|
||||
altNegativeButton: left
|
||||
altPositiveButton: right
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0.1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Vertical
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton: s
|
||||
positiveButton: w
|
||||
altNegativeButton: down
|
||||
altPositiveButton: up
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0.1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 1
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Shoot
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: space
|
||||
altNegativeButton:
|
||||
altPositiveButton: mouse 0
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0.1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 3
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Submit
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: space
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0.1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 3
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Cancel
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: escape
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0.1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 3
|
||||
joyNum: 0
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b5adb4371874bdd4aaa9c29d1e3cba7e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -14,6 +14,7 @@ public class ArrowHighlight : MonoBehaviour
|
|||
private bool isMouseMove = false;
|
||||
private bool isPlaying = false;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
sp_render = GetComponent<SpriteRenderer>();
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class ControllerDiagramForInputManager : GamepadForInputManager
|
||||
{
|
||||
void Update()
|
||||
{
|
||||
UpdateAllButtons();
|
||||
|
||||
// Only support the first 10 axles. Axles from 11th won't be able to show in this project
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
string axisName = "Axis " + i;
|
||||
UpdateAxisValue(axisName);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAxisValue(string axisName)
|
||||
{
|
||||
float value = Input.GetAxis(axisName);
|
||||
Transform axis = m_buttonContainer.Find(axisName);
|
||||
axis.GetComponent<TextMesh>().text = value.ToString("F2");
|
||||
}
|
||||
}
|
|
@ -2,15 +2,16 @@ using UnityEngine;
|
|||
using UnityEngine.Experimental.Input;
|
||||
using UnityEngine.Experimental.Input.Controls;
|
||||
|
||||
public class ControllerDiagramForInputSystem : GamepadForInputSystem
|
||||
public class ControllerDiagramISX : GamepadISX
|
||||
{
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
m_buttonAction = new InputAction(name: "ButtonPressAction", binding: "*/<button>");
|
||||
m_buttonAction.performed += callbackContext => OnButtonPress(callbackContext.control as ButtonControl);
|
||||
m_buttonAction.Enable();
|
||||
|
||||
m_dPadAction = new InputAction(name: "dpadpressaction", binding: "*/<dpad>");
|
||||
m_dPadAction = new InputAction(name: "Dpadpressaction", binding: "*/<dpad>");
|
||||
m_dPadAction.performed += callbackContext => OnDpadPress(callbackContext.control as DpadControl);
|
||||
m_dPadAction.Enable();
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class ControllerDiagramOldInput : GamepadOldInput
|
||||
{
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
UpdateAllButtons();
|
||||
|
||||
// Only support the first 10 axles. Axles from 11th won't be able to show in this project
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
string axisName = "Axis " + i;
|
||||
UpdateAxisValue(axisName);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void StartHighlightButton(string buttonName)
|
||||
{
|
||||
Transform button = m_buttonContainer.Find(buttonName);
|
||||
if (button == null)
|
||||
ShowMessage(buttonName);
|
||||
else
|
||||
{
|
||||
RemoveTransparency(button);
|
||||
ParticleSystem ps = button.GetComponentInChildren<ParticleSystem>();
|
||||
if (ps == null)
|
||||
Instantiate(m_buttonHighlight, button.position - new Vector3(0f, 0f, 0.1f), button.rotation, button);
|
||||
else
|
||||
ps.Play();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAxisValue(string axisName)
|
||||
{
|
||||
float value = Input.GetAxis(axisName);
|
||||
Transform axis = m_buttonContainer.Find(axisName);
|
||||
axis.GetComponent<TextMesh>().text = value.ToString("F2");
|
||||
|
||||
if (value != 0f)
|
||||
RemoveTransparency(axis);
|
||||
|
||||
}
|
||||
|
||||
private void RemoveTransparency(Transform controlTrans)
|
||||
{
|
||||
// Remove transparency from all the Sprite Renderers
|
||||
foreach (SpriteRenderer sr in controlTrans.GetComponentsInChildren<SpriteRenderer>())
|
||||
sr.color = RemoveColorTranparency(sr.color);
|
||||
|
||||
// Remove transparency from the text mesh and change text to the transform's name
|
||||
foreach (TextMesh tm in controlTrans.GetComponentsInChildren<TextMesh>())
|
||||
tm.color = RemoveColorTranparency(tm.color);
|
||||
}
|
||||
|
||||
private Color RemoveColorTranparency(Color color)
|
||||
{
|
||||
color.a = 1f;
|
||||
return color;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ using UnityEngine.Experimental.Input.Controls;
|
|||
// Parent Class for All Gamepad/Controller Input from New Input System.
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
public class GamepadForInputSystem : MonoBehaviour
|
||||
public class GamepadISX : MonoBehaviour
|
||||
{
|
||||
[Tooltip("The GameObject that is the parent for all the buttons.")]
|
||||
public Transform m_buttonContainer;
|
|
@ -10,7 +10,7 @@ using UnityEngine.UI;
|
|||
// Alternatively, ingore the requirement and change the code
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
public class GamepadForInputManager : MonoBehaviour
|
||||
public class GamepadOldInput : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Highlight Prefab")]
|
||||
public ParticleSystem m_buttonHighlight;
|
|
@ -0,0 +1,36 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Experimental.Input;
|
||||
using UnityEngine.Experimental.Input.Controls;
|
||||
|
||||
public class JoystickISX : MonoBehaviour {
|
||||
|
||||
|
||||
|
||||
[Tooltip("Where all the messages go")]
|
||||
public InputField m_MessageWindow;
|
||||
|
||||
private InputAction m_stickAction;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
m_stickAction = new InputAction(name: "StickAction", binding: "<joystick>/<stick>");
|
||||
m_stickAction.performed += callbackContext => OnStickMove(callbackContext.control as StickControl);
|
||||
m_stickAction.Enable();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
private void OnStickMove(StickControl control)
|
||||
{
|
||||
Debug.Log("Stick Moved");
|
||||
}
|
||||
|
||||
private void ShowMessage(string msg)
|
||||
{
|
||||
m_MessageWindow.text += "<color=red>" + msg + "</color>\n";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 65cf337ad1d7598409fa5f00501e0a30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,10 +1,11 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Experimental.Input;
|
||||
using UnityEngine.Experimental.Input.Controls;
|
||||
|
||||
public class KeyboardMouseForInputSystem : MonoBehaviour
|
||||
public class KeyboardMouseISX : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Highlight Prefab")]
|
||||
public SpriteRenderer m_keyHighlight;
|
||||
|
@ -19,19 +20,19 @@ public class KeyboardMouseForInputSystem : MonoBehaviour
|
|||
private InputAction m_keyboardAction;
|
||||
private InputAction m_mouseAction;
|
||||
|
||||
private Action<char> m_RecordKeyAction;
|
||||
private Keyboard m_registeredKeyboard;
|
||||
|
||||
private const int MOUSE_MOVE_DEADZONE = 0;
|
||||
|
||||
public void Start()
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
m_keyboardAction = new InputAction(name: "KeyboardPressAction", binding: "<keyboard>/<key>");
|
||||
m_keyboardAction.performed += callbackContext => KeyboardKeyPress(callbackContext.control as KeyControl);
|
||||
m_keyboardAction.Enable();
|
||||
|
||||
m_mouseAction = new InputAction(name: "MousePressAction", binding: "<mouse>/<button>");
|
||||
m_mouseAction = new InputAction(name: "MousePressAction", binding: "<mouse>/<button>");
|
||||
m_mouseAction.performed += callbackContext => MouseKeyPress();
|
||||
m_mouseAction.performed += callbackContext => MouseKeyPress(callbackContext.control.device as Mouse);
|
||||
m_mouseAction.Enable();
|
||||
}
|
||||
|
||||
|
@ -40,15 +41,7 @@ public class KeyboardMouseForInputSystem : MonoBehaviour
|
|||
if (m_keyboardAction != null) m_keyboardAction.Enable();
|
||||
if (m_mouseAction != null) m_mouseAction.Enable();
|
||||
|
||||
if (m_RecordKeyAction == null)
|
||||
{
|
||||
Keyboard keyboard = InputSystem.GetDevice<Keyboard>();
|
||||
if (keyboard != null)
|
||||
{
|
||||
m_RecordKeyAction = new Action<char>(RecordKey);
|
||||
keyboard.onTextInput += m_RecordKeyAction;
|
||||
}
|
||||
}
|
||||
StartCoroutine("EnableTrackKeyboardInput");
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
|
@ -56,100 +49,92 @@ public class KeyboardMouseForInputSystem : MonoBehaviour
|
|||
m_keyboardAction.Disable();
|
||||
m_mouseAction.Disable();
|
||||
|
||||
if (m_RecordKeyAction != null)
|
||||
{
|
||||
Keyboard keyboard = InputSystem.GetDevice<Keyboard>();
|
||||
if (keyboard != null)
|
||||
{
|
||||
keyboard.onTextInput -= m_RecordKeyAction;
|
||||
m_RecordKeyAction = null;
|
||||
}
|
||||
}
|
||||
InputSystem.GetDevice<Keyboard>().onTextInput -= new Action<char>(RecordKey);
|
||||
if (m_registeredKeyboard != null)
|
||||
m_registeredKeyboard.onTextInput -= new Action<char>(RecordKey);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
void Update()
|
||||
{
|
||||
if (m_RecordKeyAction == null)
|
||||
{
|
||||
Keyboard keyboard = InputSystem.GetDevice<Keyboard>();
|
||||
if (keyboard != null)
|
||||
{
|
||||
m_RecordKeyAction = new Action<char>(RecordKey);
|
||||
keyboard.onTextInput += m_RecordKeyAction;
|
||||
}
|
||||
}
|
||||
|
||||
// Show mouse actions
|
||||
var mouse = InputSystem.GetDevice<Mouse>();
|
||||
if (mouse == null)
|
||||
return;
|
||||
|
||||
var move = mouse.delta.ReadValue();
|
||||
var scroll = mouse.scroll.ReadValue();
|
||||
|
||||
// Mouse move horizontally
|
||||
if (Mathf.Abs(move.x) > MOUSE_MOVE_DEADZONE)
|
||||
Mouse mouse = InputSystem.GetDevice<Mouse>();
|
||||
if (mouse != null)
|
||||
{
|
||||
if (move.x > 0)
|
||||
Vector2 move = mouse.delta.ReadValue();
|
||||
Vector2 scroll = mouse.scroll.ReadValue();
|
||||
|
||||
// Mouse move horizontally
|
||||
if (Mathf.Abs(move.x) > MOUSE_MOVE_DEADZONE)
|
||||
{
|
||||
StartMouseHighlight("Move Right");
|
||||
if (move.x > 0)
|
||||
{
|
||||
StartMouseHighlight("Move Right");
|
||||
StopMouseHighlight("Move Left");
|
||||
}
|
||||
else
|
||||
{
|
||||
StartMouseHighlight("Move Left");
|
||||
StopMouseHighlight("Move Right");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StopMouseHighlight("Move Right");
|
||||
StopMouseHighlight("Move Left");
|
||||
}
|
||||
|
||||
// Mouse move vertically
|
||||
if (Mathf.Abs(move.y) > MOUSE_MOVE_DEADZONE)
|
||||
{
|
||||
if (move.y > 0)
|
||||
{
|
||||
StartMouseHighlight("Move Up");
|
||||
StopMouseHighlight("Move Down");
|
||||
}
|
||||
else
|
||||
{
|
||||
StartMouseHighlight("Move Down");
|
||||
StopMouseHighlight("Move Up");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StartMouseHighlight("Move Left");
|
||||
StopMouseHighlight("Move Right");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StopMouseHighlight("Move Right");
|
||||
StopMouseHighlight("Move Left");
|
||||
}
|
||||
|
||||
// Mouse move vertically
|
||||
if (Mathf.Abs(move.y) > MOUSE_MOVE_DEADZONE)
|
||||
{
|
||||
if (move.y > 0)
|
||||
{
|
||||
StartMouseHighlight("Move Up");
|
||||
StopMouseHighlight("Move Up");
|
||||
StopMouseHighlight("Move Down");
|
||||
}
|
||||
|
||||
// Mouse Wheel scroll
|
||||
// Only horizontal scroll has UI. Vertical scroll is shown in text box.
|
||||
if (scroll.y > 0)
|
||||
{
|
||||
StartMouseHighlight("Wheel Up");
|
||||
StopMouseHighlight("Wheel Down");
|
||||
}
|
||||
else if (scroll.y < 0)
|
||||
{
|
||||
StartMouseHighlight("Wheel Down");
|
||||
StopMouseHighlight("Wheel Up");
|
||||
}
|
||||
else
|
||||
{
|
||||
StartMouseHighlight("Move Down");
|
||||
StopMouseHighlight("Move Up");
|
||||
StopMouseHighlight("Wheel Up");
|
||||
StopMouseHighlight("Wheel Down");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StopMouseHighlight("Move Up");
|
||||
StopMouseHighlight("Move Down");
|
||||
}
|
||||
|
||||
// Mouse Wheel scroll
|
||||
// Only horizontal scroll has UI. Vertical scroll is shown in text box.
|
||||
if (scroll.y > 0)
|
||||
{
|
||||
StartMouseHighlight("Wheel Up");
|
||||
StopMouseHighlight("Wheel Down");
|
||||
}
|
||||
else if (scroll.y < 0)
|
||||
{
|
||||
StartMouseHighlight("Wheel Down");
|
||||
StopMouseHighlight("Wheel Up");
|
||||
}
|
||||
else
|
||||
{
|
||||
StopMouseHighlight("Wheel Up");
|
||||
StopMouseHighlight("Wheel Down");
|
||||
// Update mouse position
|
||||
m_mouseInfoText.text = mouse.position.ReadValue().ToString("F0") + "\n"
|
||||
+ scroll.ToString() + "\n"
|
||||
+ move.ToString("F3");
|
||||
}
|
||||
}
|
||||
|
||||
// Update mouse position
|
||||
m_mouseInfoText.text = mouse.position.ReadValue().ToString("F0") + "\n"
|
||||
+ scroll.ToString() + "\n"
|
||||
+ move.ToString("F3");
|
||||
// There is a delay in getting current keyboard. For OnEnable to assign event
|
||||
private IEnumerator EnableTrackKeyboardInput()
|
||||
{
|
||||
yield return new WaitUntil(() => InputSystem.GetDevice<Keyboard>() != null);
|
||||
|
||||
m_registeredKeyboard = InputSystem.GetDevice<Keyboard>();
|
||||
m_registeredKeyboard.onTextInput -= new Action<char>(RecordKey);
|
||||
m_registeredKeyboard.onTextInput += new Action<char>(RecordKey);
|
||||
}
|
||||
|
||||
private void RecordKey(char c)
|
||||
|
@ -172,9 +157,9 @@ public class KeyboardMouseForInputSystem : MonoBehaviour
|
|||
}
|
||||
|
||||
// callback function when a button is pressed on Mouse
|
||||
private void MouseKeyPress()
|
||||
private void MouseKeyPress(Mouse mouse)
|
||||
{
|
||||
var mouse = InputSystem.GetDevice<Mouse>();
|
||||
// Mouse mouse = InputSystem.GetDevice<Mouse>();
|
||||
if (mouse.leftButton.ReadValue() == 0)
|
||||
StopKeyHighlight("Mouse0");
|
||||
else
|
||||
|
@ -194,7 +179,7 @@ public class KeyboardMouseForInputSystem : MonoBehaviour
|
|||
// Generate the red square over the key or mouse button
|
||||
private void StartKeyHightlight(string keyName)
|
||||
{
|
||||
var key = transform.Find("Keys/" + keyName);
|
||||
Transform key = transform.Find("Keys/" + keyName);
|
||||
if (key == null)
|
||||
ShowMessage(keyName);
|
||||
else
|
||||
|
@ -209,28 +194,28 @@ public class KeyboardMouseForInputSystem : MonoBehaviour
|
|||
|
||||
private void StopKeyHighlight(string keyName)
|
||||
{
|
||||
var key = transform.Find("Keys/" + keyName);
|
||||
if (key == null)
|
||||
return;
|
||||
|
||||
var sr = key.GetComponentsInChildren<SpriteRenderer>();
|
||||
if (sr.Length > 0)
|
||||
Transform key = transform.Find("Keys/" + keyName);
|
||||
if (key != null)
|
||||
{
|
||||
foreach (var s in sr)
|
||||
Destroy(s.gameObject);
|
||||
SpriteRenderer[] sr = key.GetComponentsInChildren<SpriteRenderer>();
|
||||
if (sr.Length > 0)
|
||||
{
|
||||
foreach (SpriteRenderer s in sr)
|
||||
Destroy(s.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void StartMouseHighlight(string mouseAction)
|
||||
{
|
||||
var mAction = transform.Find("Mouse/" + mouseAction + "/Highlight_Arrow_Input_System");
|
||||
Transform mAction = transform.Find("Mouse/" + mouseAction + "/Highlight_Arrow_Input_System");
|
||||
if (mAction != null)
|
||||
mAction.GetComponent<ArrowHighlight>().Play();
|
||||
}
|
||||
|
||||
private void StopMouseHighlight(string mouseAction)
|
||||
{
|
||||
var mAction = transform.Find("Mouse/" + mouseAction + "/Highlight_Arrow_Input_System");
|
||||
Transform mAction = transform.Find("Mouse/" + mouseAction + "/Highlight_Arrow_Input_System");
|
||||
if (mAction != null)
|
||||
mAction.GetComponent<ArrowHighlight>().Stop();
|
||||
}
|
||||
|
@ -239,10 +224,10 @@ public class KeyboardMouseForInputSystem : MonoBehaviour
|
|||
private void ShowMessage(string msg)
|
||||
{
|
||||
m_MessageWindow.text += "<color=red>" + msg + "</color>\n";
|
||||
}
|
||||
}
|
||||
|
||||
// From "KeyboardLastKey" by @Rene
|
||||
private static string StringForNonPrintable(char ascii)
|
||||
private String StringForNonPrintable(char ascii)
|
||||
{
|
||||
switch ((int)ascii)
|
||||
{
|
|
@ -2,7 +2,7 @@ using System;
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class KeyboardMouseForInputManager : MonoBehaviour
|
||||
public class KeyboardMouseOldInput : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Highlight Prefab")]
|
||||
public ParticleSystem m_keyHighlight;
|
|
@ -5,13 +5,19 @@ using UnityEngine.UI;
|
|||
using UnityEngine.Experimental.Input;
|
||||
using UnityEngine.Experimental.Input.Controls;
|
||||
|
||||
public class PenForInputSystem : MonoBehaviour
|
||||
public class PenISX : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Highlight for Pen Input")] public ParticleSystem m_highlightPS;
|
||||
[Tooltip("Highlight for Pen Input")]
|
||||
public ParticleSystem m_highlightPS;
|
||||
|
||||
[Tooltip("Where all the messages go")] public InputField m_MessageWindow;
|
||||
[Tooltip("Sign for Out of Range")]
|
||||
public GameObject m_outOfRangeSign;
|
||||
|
||||
[Header("UI Elements for Debug Info")] public TextMesh m_pressureText;
|
||||
[Tooltip("Where all the messages go")]
|
||||
public InputField m_MessageWindow;
|
||||
|
||||
[Header("UI Elements for Debug Info")]
|
||||
public TextMesh m_pressureText;
|
||||
public Text m_penInfoText;
|
||||
|
||||
private InputAction m_penAction;
|
||||
|
@ -26,7 +32,8 @@ public class PenForInputSystem : MonoBehaviour
|
|||
|
||||
private bool is_pen_rotating = false;
|
||||
|
||||
public void Start()
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
pen_holder = transform.Find("Pen");
|
||||
if (pen_holder == null)
|
||||
|
@ -53,23 +60,23 @@ public class PenForInputSystem : MonoBehaviour
|
|||
m_penAction.Disable();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
var pen = InputSystem.GetDevice<Pen>();
|
||||
if (pen == null)
|
||||
return;
|
||||
Pen pen = InputSystem.GetDevice<Pen>();
|
||||
if (pen == null) return;
|
||||
|
||||
// Update position
|
||||
var pos = pen.position.ReadValue();
|
||||
Vector2 pos = pen.position.ReadValue();
|
||||
pen_holder.position = original_pos + new Vector3(pos.x * HORIZONTAL_RANGE / Screen.width,
|
||||
pos.y * VERTICAL_RANGE / Screen.height, 0);
|
||||
pos.y * VERTICAL_RANGE / Screen.height, 0);
|
||||
|
||||
// Update tilt
|
||||
var tilt = pen.tilt.ReadValue();
|
||||
Vector2 tilt = pen.tilt.ReadValue();
|
||||
pen_rotation.localEulerAngles = new Vector3(tilt.y, 0, tilt.x) * -90;
|
||||
|
||||
// Update twist if available
|
||||
var twist = pen.twist.ReadValue();
|
||||
float twist = pen.twist.ReadValue();
|
||||
pen_rotation.GetChild(0).localEulerAngles = rotation_adjust + new Vector3(0, twist * -360, 0);
|
||||
|
||||
// Update ISX information text UI
|
||||
|
@ -79,16 +86,19 @@ public class PenForInputSystem : MonoBehaviour
|
|||
+ twist.ToString("F2");
|
||||
|
||||
// Update pressure indicator
|
||||
var pressure = pen.pressure.ReadValue();
|
||||
var newColor = Color.red;
|
||||
float pressure = pen.pressure.ReadValue();
|
||||
Color newColor = Color.red;
|
||||
newColor.a = pressure;
|
||||
m_pressureText.color = newColor;
|
||||
m_pressureText.text = "Pressure: " + pressure.ToString("F2");
|
||||
|
||||
// Update inRange state/indicator
|
||||
m_outOfRangeSign.SetActive(!pen.inRange.isPressed);
|
||||
}
|
||||
|
||||
private void ButtonPress(ButtonControl control)
|
||||
{
|
||||
var buttonName = control.name;
|
||||
string buttonName = control.name;
|
||||
if (buttonName == "tip" || buttonName == "eraser")
|
||||
{
|
||||
if (control.ReadValue() > 0)
|
||||
|
@ -108,9 +118,9 @@ public class PenForInputSystem : MonoBehaviour
|
|||
}
|
||||
}
|
||||
// Any other button is listed in the Input Name list
|
||||
else
|
||||
else if (buttonName != "inRange")
|
||||
{
|
||||
var str = buttonName + ((control.ReadValue() == 0) ? " released" : " pressed");
|
||||
string str = buttonName + ((control.ReadValue() == 0) ? " released" : " pressed");
|
||||
ShowMessage(str);
|
||||
}
|
||||
}
|
||||
|
@ -128,23 +138,23 @@ public class PenForInputSystem : MonoBehaviour
|
|||
private IEnumerator RotatePen(int target_angel)
|
||||
{
|
||||
is_pen_rotating = true;
|
||||
var step = (target_angel - rotation_adjust.z) * 0.2f;
|
||||
float step = (target_angel - rotation_adjust.z) * 0.2f;
|
||||
while (Mathf.Abs(rotation_adjust.z - target_angel) > 1)
|
||||
{
|
||||
rotation_adjust.z += step;
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
|
||||
is_pen_rotating = false;
|
||||
}
|
||||
|
||||
private string FirstLetterToUpper(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
if (String.IsNullOrEmpty(str))
|
||||
return null;
|
||||
if (str.Length == 1)
|
||||
else if (str.Length == 1)
|
||||
return str.ToUpper();
|
||||
return char.ToUpper(str[0]) + str.Substring(1);
|
||||
else
|
||||
return char.ToUpper(str[0]) + str.Substring(1);
|
||||
}
|
||||
|
||||
private void ShowMessage(string msg)
|
|
@ -3,7 +3,7 @@ using UnityEngine.UI;
|
|||
using UnityEngine.Experimental.Input;
|
||||
using UnityEngine.Experimental.Input.Controls;
|
||||
|
||||
public class TouchForInputSystem : MonoBehaviour
|
||||
public class TouchISX : MonoBehaviour
|
||||
{
|
||||
[Tooltip("The Gameobject holds all the highlight objects for Input System")]
|
||||
public Transform m_HighlightPool;
|
||||
|
@ -13,6 +13,7 @@ public class TouchForInputSystem : MonoBehaviour
|
|||
|
||||
private InputAction m_touchAction;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
m_touchAction = new InputAction(name: "TouchAction", binding: "<touchscreen>/<touch>");
|
|
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TouchForInputManager : MonoBehaviour
|
||||
public class TouchOldInput : MonoBehaviour
|
||||
{
|
||||
// This is the object contains all the highlight for touch inputs
|
||||
// There should be 10 highlight gameobjects in the pool for 10 touches at the same time
|
||||
|
@ -17,6 +17,7 @@ public class TouchForInputManager : MonoBehaviour
|
|||
|
||||
// The old input manager does not support touch input for Standalone build, even when the device does.
|
||||
#if !UNITY_STANDALONE
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
if (!Input.touchSupported)
|
||||
|
@ -26,6 +27,7 @@ public class TouchForInputManager : MonoBehaviour
|
|||
ShowMessage("Touch Pressue is not supported.");
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.touchCount > 0)
|
|
@ -3,12 +3,13 @@ using UnityEngine.UI;
|
|||
using UnityEngine.Experimental.Input;
|
||||
using UnityEngine.Experimental.Input.Controls;
|
||||
|
||||
public class XboxForInputSystem : GamepadForInputSystem
|
||||
public class XboxISX : GamepadISX
|
||||
{
|
||||
[Header("UI Element for Other Information")]
|
||||
public Text m_leftStickText;
|
||||
public Text m_rightStickText;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
//m_stickMaxMove = 0.25f;
|
|
@ -9,7 +9,7 @@ using UnityEngine.UI;
|
|||
// Alternatively, ingore the requirement and change the code
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
public class XboxForInputManager : GamepadForInputManager
|
||||
public class XboxOldInput : GamepadOldInput
|
||||
{
|
||||
[Header("UI Element for Other Information")]
|
||||
public Text m_leftStickText;
|
||||
|
@ -18,6 +18,7 @@ public class XboxForInputManager : GamepadForInputManager
|
|||
private List<XboxTrigger> xbox_triggers = new List<XboxTrigger>();
|
||||
private Color m_stickButtonColor = new Color(0.4f, 0.4f, 0.55f, 1f); // The default color for Stick when it is NOT pressed.
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
// Button map is different for each platform
|
||||
|
@ -61,9 +62,34 @@ public class XboxForInputManager : GamepadForInputManager
|
|||
analog_sticks.Add(new AnalogStick(m_buttonContainer.Find("RightStick/Stick - Input Manager"), "Axis 3", "Axis 4", posText: m_rightStickText, isYReversed: true));
|
||||
xbox_triggers.Add(new XboxTrigger(m_buttonContainer.Find("LeftTrigger"), "Axis 5"));
|
||||
xbox_triggers.Add(new XboxTrigger(m_buttonContainer.Find("RightTrigger"), "Axis 6"));
|
||||
#elif UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX || UNITY_STANDALONE_LINUX_API
|
||||
button_map.Add("Button0", "A");
|
||||
button_map.Add("Button1", "B");
|
||||
button_map.Add("Button2", "X");
|
||||
button_map.Add("Button3", "Y");
|
||||
button_map.Add("Button4", "LeftShoulder");
|
||||
button_map.Add("Button5", "RightShoulder");
|
||||
button_map.Add("Button6", "Select");
|
||||
button_map.Add("Button7", "Start");
|
||||
button_map.Add("Button9", "LeftStick/Stick - Input Manager");
|
||||
button_map.Add("Button10", "RightStick/Stick - Input Manager");
|
||||
button_map.Add("Button11", "Dpad/Left");
|
||||
button_map.Add("Button12", "Dpad/Right");
|
||||
button_map.Add("Button13", "Dpad/Up");
|
||||
button_map.Add("Button14", "Dpad/Down");
|
||||
button_map.Add("Button8", "Xbox");
|
||||
analog_sticks.Add(new AnalogStick(m_buttonContainer.Find("LeftStick/Stick - Input Manager"), "Axis 1", "Axis 2", posText: m_leftStickText, isYReversed: true));
|
||||
analog_sticks.Add(new AnalogStick(m_buttonContainer.Find("RightStick/Stick - Input Manager"), "Axis 4", "Axis 5", posText: m_rightStickText, isYReversed: true));
|
||||
analog_buttons.Add(new AnalogButton(m_buttonContainer.Find("LeftTrigger"), "Axis 3", 0f, 1f));
|
||||
analog_buttons.Add(new AnalogButton(m_buttonContainer.Find("RightTrigger"), "Axis 6", 0f, 1f));
|
||||
analog_buttons.Add(new AnalogButton(m_buttonContainer.Find("Dpad/Left"), "Axis 7", -1f, 0f, isDpad: true));
|
||||
analog_buttons.Add(new AnalogButton(m_buttonContainer.Find("Dpad/Right"), "Axis 7", 0f, 1f, isDpad: true));
|
||||
analog_buttons.Add(new AnalogButton(m_buttonContainer.Find("Dpad/Up"), "Axis 8", -1f, 0f, isDpad: true));
|
||||
analog_buttons.Add(new AnalogButton(m_buttonContainer.Find("Dpad/Down"), "Axis 8", 0f, 1f, isDpad: true));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
UpdateAllButtons();
|
|
@ -3,7 +3,7 @@ using System.Collections;
|
|||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Input;
|
||||
|
||||
public class DebugInfo : MonoBehaviour
|
||||
public class InputDebugInfo : MonoBehaviour
|
||||
{
|
||||
private bool m_isShowing = false;
|
||||
private bool m_isPlaying = false; // if the menu is in the process of sliding in/out
|
||||
|
@ -17,9 +17,33 @@ public class DebugInfo : MonoBehaviour
|
|||
private float m_startMouseY;
|
||||
private float m_startY;
|
||||
|
||||
public void Update()
|
||||
private InputAction m_toggleAction;
|
||||
|
||||
void Start()
|
||||
{
|
||||
var currentKeyboard = InputSystem.GetDevice<Keyboard>();
|
||||
//m_toggleAction = new InputAction(name: "ToggleInfoDisplay");
|
||||
//m_toggleAction.AddBinding("<keyboard>/leftCtrl");
|
||||
|
||||
//m_toggleAction.performed += _ => OnToggleDebugInfo();
|
||||
//m_toggleAction.Enable();
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
//if (m_toggleAction != null)
|
||||
// m_toggleAction.Enable();
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
//m_toggleAction.Disable();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (InputSystem.GetDevice<Keyboard>() == null) return;
|
||||
|
||||
Keyboard currentKeyboard = InputSystem.GetDevice<Keyboard>();
|
||||
if (currentKeyboard.leftCtrlKey.isPressed || currentKeyboard.rightCtrlKey.isPressed)
|
||||
{
|
||||
if (currentKeyboard.iKey.isPressed)
|
||||
|
@ -29,8 +53,7 @@ public class DebugInfo : MonoBehaviour
|
|||
|
||||
public void OnToggleDebugInfo()
|
||||
{
|
||||
if (m_isPlaying || m_isDragging)
|
||||
return;
|
||||
if (m_isPlaying || m_isDragging) return;
|
||||
|
||||
m_isShowing = !m_isShowing;
|
||||
StartCoroutine("SlideToPositionX");
|
||||
|
@ -49,8 +72,8 @@ public class DebugInfo : MonoBehaviour
|
|||
{
|
||||
if (m_isPlaying) return;
|
||||
|
||||
var delta = Input.mousePosition.y - m_startMouseY;
|
||||
var pos = transform.position;
|
||||
float delta = Input.mousePosition.y - m_startMouseY;
|
||||
Vector3 pos = transform.position;
|
||||
pos.y = Mathf.Min(Mathf.Max(m_startY + delta, m_info.rect.height * GetComponentInParent<Canvas>().scaleFactor), Screen.height);
|
||||
transform.position = pos;
|
||||
}
|
||||
|
@ -61,14 +84,14 @@ public class DebugInfo : MonoBehaviour
|
|||
}
|
||||
|
||||
// Slide the debug info menu window in/out from view
|
||||
// Rotate the arrow UI 180 degrees
|
||||
// Ratote the arrow UI 180 degrees
|
||||
private IEnumerator SlideToPositionX()
|
||||
{
|
||||
m_isPlaying = true;
|
||||
|
||||
var posDifference = m_isShowing ? -1f * CalculateInfoContainerWidth() : CalculateInfoContainerWidth();
|
||||
var currentX = transform.position.x;
|
||||
var targetX = currentX + posDifference;
|
||||
float posDifference = m_isShowing ? -1f * CalculateInfoContainerWidth() : CalculateInfoContainerWidth();
|
||||
float currentX = transform.position.x;
|
||||
float targetX = currentX + posDifference;
|
||||
|
||||
Quaternion targetAngle = m_arrowUI.rotation * Quaternion.Euler(0f, 0f, 180f);
|
||||
|
||||
|
@ -93,12 +116,13 @@ public class DebugInfo : MonoBehaviour
|
|||
{
|
||||
if (m_info != null)
|
||||
return m_info.rect.width * GetComponentInParent<Canvas>().scaleFactor;
|
||||
throw new Exception("Need assign \"info\" Transform Rect.");
|
||||
else
|
||||
throw new Exception("Need assign \"info\" Transform Rect.");
|
||||
}
|
||||
|
||||
private void SetPositionByX(float posX)
|
||||
{
|
||||
var pos = transform.position;
|
||||
Vector3 pos = transform.position;
|
||||
pos.x = posX;
|
||||
transform.position = pos;
|
||||
}
|
|
@ -5,33 +5,41 @@ using UnityEngine.Experimental.Input;
|
|||
|
||||
public class InputUIPicker : MonoBehaviour
|
||||
{
|
||||
// Input Gameobjects
|
||||
public Dropdown m_inputPickerDropdown;
|
||||
|
||||
[Header("Input Gameobject")]
|
||||
public GameObject m_windowsKeyboardMouse;
|
||||
public GameObject m_macKeyboardMouse;
|
||||
public GameObject m_controllerDiagram;
|
||||
public GameObject m_xboxController;
|
||||
public GameObject m_joystick;
|
||||
public GameObject m_pen;
|
||||
public GameObject m_touch;
|
||||
|
||||
[Header("Input Action")]
|
||||
public InputAction m_switchToKeyboardMouseAction;
|
||||
public InputAction m_switchToXboxAction;
|
||||
public InputAction m_switchToGamepadDiagramAction;
|
||||
public InputAction m_switchToJoystickAction;
|
||||
public InputAction m_switchToPenAction;
|
||||
public InputAction m_switchToTouchAction;
|
||||
|
||||
// Current displayed diagram
|
||||
private GameObject m_currentDisplay;
|
||||
private Keyboard m_currentKeyboard;
|
||||
|
||||
public void Start()
|
||||
void Start()
|
||||
{
|
||||
SwitchToKeyMouse();
|
||||
m_currentKeyboard = InputSystem.GetDevice<Keyboard>();
|
||||
|
||||
m_inputPickerDropdown.onValueChanged.RemoveAllListeners();
|
||||
m_inputPickerDropdown.onValueChanged.AddListener(delegate { SwitchToInputMethod(m_inputPickerDropdown); });
|
||||
|
||||
//m_switchToKeyboardMouseAction.performed += _ => SwitchToInputMethod(0);
|
||||
//m_switchToXboxAction.performed += _ => SwitchToInputMethod(1);
|
||||
//m_switchToGamepadDiagramAction.performed += _ => SwitchToInputMethod(2);
|
||||
//m_switchToPenAction.performed += _ => SwitchToInputMethod(3);
|
||||
//m_switchToTouchAction.performed += _ => SwitchToInputMethod(4);
|
||||
//m_switchToJoystickAction.performed += _ => SwitchToInputMethod(3);
|
||||
//m_switchToPenAction.performed += _ => SwitchToInputMethod(4);
|
||||
//m_switchToTouchAction.performed += _ => SwitchToInputMethod(5);
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
|
@ -39,6 +47,7 @@ public class InputUIPicker : MonoBehaviour
|
|||
//m_switchToKeyboardMouseAction.Enable();
|
||||
//m_switchToXboxAction.Enable();
|
||||
//m_switchToGamepadDiagramAction.Enable();
|
||||
//m_switchToJoystickAction.Enable();
|
||||
//m_switchToPenAction.Enable();
|
||||
//m_switchToTouchAction.Enable();
|
||||
}
|
||||
|
@ -48,6 +57,7 @@ public class InputUIPicker : MonoBehaviour
|
|||
m_switchToKeyboardMouseAction.Disable();
|
||||
m_switchToXboxAction.Disable();
|
||||
m_switchToGamepadDiagramAction.Disable();
|
||||
m_switchToJoystickAction.Disable();
|
||||
m_switchToPenAction.Disable();
|
||||
m_switchToTouchAction.Disable();
|
||||
}
|
||||
|
@ -55,35 +65,32 @@ public class InputUIPicker : MonoBehaviour
|
|||
// !!!!!TEMPORARY: Before composite input is implemented
|
||||
void Update()
|
||||
{
|
||||
if (m_currentKeyboard == null)
|
||||
m_currentKeyboard = InputSystem.GetDevice<Keyboard>();
|
||||
if (InputSystem.GetDevice<Keyboard>() == null) return;
|
||||
|
||||
if (m_currentKeyboard != null)
|
||||
Keyboard currentKeyboard = InputSystem.GetDevice<Keyboard>();
|
||||
if (currentKeyboard.leftCtrlKey.isPressed || currentKeyboard.rightCtrlKey.isPressed)
|
||||
{
|
||||
if (m_currentKeyboard.leftCtrlKey.isPressed || m_currentKeyboard.rightCtrlKey.isPressed)
|
||||
{
|
||||
if (m_currentKeyboard.digit1Key.isPressed)
|
||||
SwitchToInputMethod(0);
|
||||
else if (m_currentKeyboard.digit2Key.isPressed)
|
||||
SwitchToInputMethod(1);
|
||||
else if (m_currentKeyboard.digit3Key.isPressed)
|
||||
SwitchToInputMethod(2);
|
||||
else if (m_currentKeyboard.digit4Key.isPressed)
|
||||
SwitchToInputMethod(3);
|
||||
else if (m_currentKeyboard.digit5Key.isPressed)
|
||||
SwitchToInputMethod(4);
|
||||
}
|
||||
if (currentKeyboard.digit1Key.isPressed)
|
||||
m_inputPickerDropdown.value = 0;
|
||||
else if (currentKeyboard.digit2Key.isPressed)
|
||||
m_inputPickerDropdown.value = 1;
|
||||
else if (currentKeyboard.digit3Key.isPressed)
|
||||
m_inputPickerDropdown.value = 2;
|
||||
else if (currentKeyboard.digit4Key.isPressed)
|
||||
m_inputPickerDropdown.value = 3;
|
||||
else if (currentKeyboard.digit5Key.isPressed)
|
||||
m_inputPickerDropdown.value = 4;
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchToInputMethod(Dropdown picker)
|
||||
private void SwitchToInputMethod(Dropdown picker)
|
||||
{
|
||||
SwitchToInputMethod(Convert.ToByte(picker.value));
|
||||
}
|
||||
|
||||
private void SwitchToInputMethod(byte inputValue)
|
||||
{
|
||||
Debug.Log("Switch to Input: " + inputValue);
|
||||
// Debug.Log("Switch to Input: " + inputValue);
|
||||
switch (inputValue)
|
||||
{
|
||||
case 1:
|
||||
|
@ -93,9 +100,12 @@ public class InputUIPicker : MonoBehaviour
|
|||
SwitchToDiagram(m_controllerDiagram);
|
||||
break;
|
||||
case 3:
|
||||
SwitchToDiagram(m_pen);
|
||||
SwitchToDiagram(m_joystick);
|
||||
break;
|
||||
case 4:
|
||||
SwitchToDiagram(m_pen);
|
||||
break;
|
||||
case 5:
|
||||
SwitchToDiagram(m_touch);
|
||||
break;
|
||||
case 0:
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
using UnityEngine;
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
using UnityEngine.Experimental.Input;
|
||||
#endif
|
||||
|
||||
public class RunInBackgroundToggle : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private bool m_ShouldRunInBackground;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
InputSystem.runInBackground = m_ShouldRunInBackground;
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ public class TextHighlight : MonoBehaviour
|
|||
|
||||
private byte fade_speed = 10;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
text_mesh = GetComponent<TextMesh>();
|
||||
|
|
|
@ -1 +1 @@
|
|||
m_EditorVersion: 2018.2.5f1
|
||||
m_EditorVersion: 2018.2.18f1
|
||||
|
|
Загрузка…
Ссылка в новой задаче