From 4c61a30e31b93aee2153bae407a4639da9c7109b Mon Sep 17 00:00:00 2001
From: Rita Merkl <127492464+ritamerkl@users.noreply.github.com>
Date: Wed, 1 Nov 2023 09:21:48 -0700
Subject: [PATCH 1/7] fix for neutron CI warning (#1787)
---
.../UITKAssetEditor/Resources/InputActionsEditorStyles.uss | 7 +++++++
.../Resources/InputActionsTreeViewItem.uxml | 2 +-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Resources/InputActionsEditorStyles.uss b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Resources/InputActionsEditorStyles.uss
index a33b6d2b7d..b050e34c4c 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Resources/InputActionsEditorStyles.uss
+++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Resources/InputActionsEditorStyles.uss
@@ -80,6 +80,13 @@
padding-bottom: 7px;
}
+.tree-view-item-icon{
+ justify-content: center;
+ background-image: url("/Packages/com.unity.inputsystem/InputSystem/Editor/Icons/d_InputControl.png");
+ width: 16px;
+ height: 16px;
+}
+
.header {
height: 22px;
flex-direction: row;
diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Resources/InputActionsTreeViewItem.uxml b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Resources/InputActionsTreeViewItem.uxml
index 8948d8f9bc..bd6564b42e 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Resources/InputActionsTreeViewItem.uxml
+++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Resources/InputActionsTreeViewItem.uxml
@@ -2,7 +2,7 @@
-
+
From fa5f304ad2423aed755a539e64202a8f3d942ae4 Mon Sep 17 00:00:00 2001
From: James McGill
Date: Thu, 2 Nov 2023 10:34:52 +0100
Subject: [PATCH 2/7] FIX: UITK Listen button not working with Any control
types (#1788)
* FIX: UITK Listen button not working with Any control types
* Remove jira links for ISX project issues from changelog
---
Packages/com.unity.inputsystem/CHANGELOG.md | 7 ++++---
.../Editor/UITKAssetEditor/Commands/Commands.cs | 7 +++++--
.../Editor/UITKAssetEditor/Views/ActionPropertiesView.cs | 2 +-
.../InputSystem/Editor/UITKAssetEditor/Views/Selectors.cs | 8 ++------
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md
index 2f0a7c5b14..683c5f4b7e 100644
--- a/Packages/com.unity.inputsystem/CHANGELOG.md
+++ b/Packages/com.unity.inputsystem/CHANGELOG.md
@@ -35,10 +35,11 @@ however, it has to be formatted properly to pass verification tests.
- Fixed case [ISXB-580](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-580) (UI Submit / Cancel not working with Switch Pro controller) by adding "Submit" & "Cancel" usages to the Switch Pro controller input controls.
- Fixed an issue where undoing deletion of Action Maps did not restore Actions correctly.
- Fixed case [ISXB-628](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-628) (OnIMECompositionChange does not return an empty string on accept when using Microsoft IME) by clarifying expectations and intended usage for the IME composition change event.
-- Fixed case [ISX-1626](https://jira.unity3d.com/browse/ISX-1626) where the expanded/collapsed state of items in the input action editor was not properly saved between rebuilds of the UI.
-- Fixed case [ISX-1668] (The Profiler shows incorrect data and spams the console with "Missing Profiler.EndSample" errors when there is an Input System Component in Scene).
-- Fixed [ISX-1661](https://jira.unity3d.com/browse/ISX-1661) where undoing duplications of action maps caused console errors
+- Fixed issue where the expanded/collapsed state of items in the input action editor was not properly saved between rebuilds of the UI.
+- Fixed issue where The Profiler shows incorrect data and spams the console with "Missing Profiler.EndSample" errors when there is an Input System Component in Scene).
+- Fixed an issue where undoing duplications of action maps caused console errors.
- Fix for BindingSyntax `WithInteraction()` which was incorrectly using processors.
+- Fix for UITK Input Action Editor binding 'Listen' button which wasn't working in the case for Control Type 'Any'.
- Fixed issue of visual elements being null during editing project-wide actions in project settings which prompted console errors.
diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/Commands.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/Commands.cs
index 0278c33645..b8bd97fd2c 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/Commands.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Commands/Commands.cs
@@ -279,8 +279,11 @@ public static Command ChangeActionControlType(SerializedInputAction inputAction,
{
return (in InputActionsEditorState state) =>
{
- var controlTypes = Selectors.BuildSortedControlList(inputAction.type).ToList();
- inputAction.wrappedProperty.FindPropertyRelative(nameof(InputAction.m_ExpectedControlType)).stringValue = controlTypes[controlTypeIndex];
+ var controlTypes = Selectors.BuildControlTypeList(inputAction.type).ToList();
+
+ // ISX-1650: "Any" (in index 0) should not be put into an InputAction.expectedControlType. It's expected to be null in this case.
+ var controlType = (controlTypeIndex == 0) ? string.Empty : controlTypes[controlTypeIndex];
+ inputAction.wrappedProperty.FindPropertyRelative(nameof(InputAction.m_ExpectedControlType)).stringValue = controlType;
state.serializedObject.ApplyModifiedProperties();
return state;
};
diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionPropertiesView.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionPropertiesView.cs
index b2fa3edab8..f800b92c91 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionPropertiesView.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ActionPropertiesView.cs
@@ -25,7 +25,7 @@ public ActionPropertiesView(VisualElement root, Foldout foldout, StateContainer
{
if (!inputAction.HasValue)
return (null, new List());
- return (inputAction.Value, Selectors.BuildSortedControlList(inputAction.Value.type).ToList());
+ return (inputAction.Value, Selectors.BuildControlTypeList(inputAction.Value.type).ToList());
});
}
diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/Selectors.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/Selectors.cs
index 421bc9fcc1..f6a1472fad 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/Selectors.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/Selectors.cs
@@ -161,17 +161,13 @@ public static IEnumerable GetCompositePartOptions(string bindingName, st
return new SerializedInputAction(actions.GetArrayElementAtIndex(state.selectedActionIndex));
}
- public static IEnumerable BuildSortedControlList(InputActionType selectedActionType)
- {
- return BuildControlTypeList(selectedActionType)
- .OrderBy(typeName => typeName, StringComparer.OrdinalIgnoreCase);
- }
-
public static IEnumerable BuildControlTypeList(InputActionType selectedActionType)
{
var allLayouts = InputSystem.s_Manager.m_Layouts;
+ // "Any" is always in first position (index 0)
yield return "Any";
+
foreach (var layoutName in allLayouts.layoutTypes.Keys)
{
if (EditorInputControlLayoutCache.TryGetLayout(layoutName).hideInUI)
From e4560c2aa0261d4ba19eadcadc8f2e4aea84983e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ha=CC=8Akan=20Sidenvall?=
Date: Sat, 4 Nov 2023 16:54:50 +0100
Subject: [PATCH 3/7] NEW: Added update mode enum to OnScreenControl to allow
changing between queue-based and state-change based updates.
---
Assets/Debugging.cs | 18 +++
Assets/Debugging.cs.meta | 11 ++
.../OnScreenControlsSample.cs | 59 ++++++++++
.../OnScreenControlsSample.cs.meta | 11 ++
.../OnScreenControlsSample.unity | 109 +++++++++++++++---
...OnScreenControlsSampleActions.inputactions | 94 +++++++++++++++
...eenControlsSampleActions.inputactions.meta | 14 +++
OnScreenControlNotes.md | 2 +
.../Plugins/OnScreen/OnScreenButton.cs | 2 +
.../Plugins/OnScreen/OnScreenControl.cs | 94 ++++++++++++---
10 files changed, 383 insertions(+), 31 deletions(-)
create mode 100644 Assets/Debugging.cs
create mode 100644 Assets/Debugging.cs.meta
create mode 100644 Assets/Samples/OnScreenControls/OnScreenControlsSample.cs
create mode 100644 Assets/Samples/OnScreenControls/OnScreenControlsSample.cs.meta
create mode 100644 Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions
create mode 100644 Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions.meta
create mode 100644 OnScreenControlNotes.md
diff --git a/Assets/Debugging.cs b/Assets/Debugging.cs
new file mode 100644
index 0000000000..ec4c1b980d
--- /dev/null
+++ b/Assets/Debugging.cs
@@ -0,0 +1,18 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Debugging : MonoBehaviour
+{
+ // Start is called before the first frame update
+ void Start()
+ {
+
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+}
diff --git a/Assets/Debugging.cs.meta b/Assets/Debugging.cs.meta
new file mode 100644
index 0000000000..d2e4949049
--- /dev/null
+++ b/Assets/Debugging.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 68569583a437a42d8aa22269fb03f0b6
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OnScreenControls/OnScreenControlsSample.cs b/Assets/Samples/OnScreenControls/OnScreenControlsSample.cs
new file mode 100644
index 0000000000..8b62b38b96
--- /dev/null
+++ b/Assets/Samples/OnScreenControls/OnScreenControlsSample.cs
@@ -0,0 +1,59 @@
+// This example showcases how to use on-screen controls and showcases how to use
+// OnScreenStick and OnScreenButton which are two types of on-screen controls included with the Input System.
+// In this example, multiple OnScreenButton component instances and OnScreenStick component instances are
+// attached to a Canvas to build an on-screen gamepad.
+//
+// The OnScreenControl game objects LeftStick, RightStick, A, B, X, Y have all been configured to associated
+// with a gamepad layout. This implies that they generate input similar to a real hardware gamepad.
+// Due to this, InputActions bound to gamepad controls such as the controls mentioned above will hence be
+// triggered when the user interacts with the on-screen controls.
+// This example uses actions defined in OnScreenControlsSampleActions.inputactions which are preconfigured to
+// bind to gamepad controls. Hence this example will work the same way when using either the on-screen controls
+// or a physical gamepad.
+//
+// Note that on-screen controls 1 and 2 on the other hand are bound to a keyboard control layout and therefore
+// generates input events similar to a physical hardware keyboard.
+//
+// When actions defined for this sample are triggered, a log message is generated to show when the actions
+// are performed.
+
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.InputSystem;
+
+public sealed class OnScreenControlsSample : MonoBehaviour
+{
+ public InputActionAsset inputActions;
+
+ List m_EnabledActions;
+
+ void OnEnable()
+ {
+ // Enable all actions in associated inputActions and add an event handler to log when action is performed.
+ m_EnabledActions = new List();
+ foreach (var actionMap in inputActions.actionMaps)
+ {
+ foreach (var action in actionMap)
+ {
+ action.Enable();
+ action.performed += Log;
+ m_EnabledActions.Add(action);
+ }
+ }
+ }
+
+ void OnDisable()
+ {
+ // Revert action handler and disable the action to clean-up from what we did in OnEnable().
+ foreach (var action in m_EnabledActions)
+ {
+ action.performed -= Log;
+ action.Disable();
+ }
+ }
+
+ void Log(InputAction.CallbackContext context)
+ {
+ Debug.Log($"Performed {context.action.name} in frame:{Time.frameCount}");
+ }
+}
diff --git a/Assets/Samples/OnScreenControls/OnScreenControlsSample.cs.meta b/Assets/Samples/OnScreenControls/OnScreenControlsSample.cs.meta
new file mode 100644
index 0000000000..654acf1871
--- /dev/null
+++ b/Assets/Samples/OnScreenControls/OnScreenControlsSample.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 08d714a194a0b45898f07b750bc13dd3
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OnScreenControls/OnScreenControlsSample.unity b/Assets/Samples/OnScreenControls/OnScreenControlsSample.unity
index 0a9dde73d7..2bbe791fb5 100644
--- a/Assets/Samples/OnScreenControls/OnScreenControlsSample.unity
+++ b/Assets/Samples/OnScreenControls/OnScreenControlsSample.unity
@@ -104,7 +104,7 @@ NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
- serializedVersion: 2
+ serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
@@ -117,7 +117,7 @@ NavMeshSettings:
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
- accuratePlacement: 0
+ buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
@@ -128,13 +128,17 @@ PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
- serializedVersion: 2
+ serializedVersion: 3
m_TransformParent: {fileID: 1993296955}
m_Modifications:
- target: {fileID: 1613174875475300, guid: f77f88b14a477764bb65a49d28c02d33, type: 3}
propertyPath: m_Name
value: LeftStick
objectReference: {fileID: 0}
+ - target: {fileID: 1613174875475300, guid: f77f88b14a477764bb65a49d28c02d33, type: 3}
+ propertyPath: m_IsActive
+ value: 1
+ objectReference: {fileID: 0}
- target: {fileID: 114480945186419424, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_Behaviour
@@ -236,19 +240,25 @@ PrefabInstance:
value: -129
objectReference: {fileID: 0}
m_RemovedComponents: []
+ m_RemovedGameObjects: []
m_AddedGameObjects: []
+ m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f77f88b14a477764bb65a49d28c02d33, type: 3}
--- !u!1001 &213445084
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
- serializedVersion: 2
+ serializedVersion: 3
m_TransformParent: {fileID: 1993296955}
m_Modifications:
- target: {fileID: 1728513650105062, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
propertyPath: m_Name
- value: Button A
+ value: Button Y
+ objectReference: {fileID: 0}
+ - target: {fileID: 1728513650105062, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
+ propertyPath: m_IsActive
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 114344768413473294, guid: 05f32eddd3e41fd4597ada617b785928,
type: 3}
@@ -351,7 +361,9 @@ PrefabInstance:
value: 172
objectReference: {fileID: 0}
m_RemovedComponents: []
+ m_RemovedGameObjects: []
m_AddedGameObjects: []
+ m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
--- !u!224 &223523015 stripped
RectTransform:
@@ -364,12 +376,16 @@ PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
- serializedVersion: 2
+ serializedVersion: 3
m_TransformParent: {fileID: 1993296955}
m_Modifications:
- target: {fileID: 1728513650105062, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
propertyPath: m_Name
- value: Button D
+ value: Button A
+ objectReference: {fileID: 0}
+ - target: {fileID: 1728513650105062, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
+ propertyPath: m_IsActive
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 114344768413473294, guid: 05f32eddd3e41fd4597ada617b785928,
type: 3}
@@ -472,7 +488,9 @@ PrefabInstance:
value: 27
objectReference: {fileID: 0}
m_RemovedComponents: []
+ m_RemovedGameObjects: []
m_AddedGameObjects: []
+ m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
--- !u!224 &334844326 stripped
RectTransform:
@@ -520,9 +538,17 @@ Camera:
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
+ m_Iso: 200
+ m_ShutterSpeed: 0.005
+ m_Aperture: 16
+ m_FocusDistance: 10
+ m_FocalLength: 50
+ m_BladeCount: 5
+ m_Curvature: {x: 2, y: 11}
+ m_BarrelClipping: 0.25
+ m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
- m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
@@ -556,13 +582,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519420028}
+ serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
- m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!224 &703313166 stripped
RectTransform:
@@ -575,18 +601,27 @@ PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
- serializedVersion: 2
+ serializedVersion: 3
m_TransformParent: {fileID: 1993296955}
m_Modifications:
- target: {fileID: 1728513650105062, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
propertyPath: m_Name
- value: Button B
+ value: Button X
+ objectReference: {fileID: 0}
+ - target: {fileID: 1728513650105062, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
+ propertyPath: m_IsActive
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 114344768413473294, guid: 05f32eddd3e41fd4597ada617b785928,
type: 3}
propertyPath: m_ControlPath
value: //X
objectReference: {fileID: 0}
+ - target: {fileID: 114344768413473294, guid: 05f32eddd3e41fd4597ada617b785928,
+ type: 3}
+ propertyPath: m_UseInputChangeState
+ value: 1
+ objectReference: {fileID: 0}
- target: {fileID: 114547973042304788, guid: 05f32eddd3e41fd4597ada617b785928,
type: 3}
propertyPath: m_Text
@@ -693,7 +728,9 @@ PrefabInstance:
value: 102
objectReference: {fileID: 0}
m_RemovedComponents: []
+ m_RemovedGameObjects: []
m_AddedGameObjects: []
+ m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
--- !u!224 &827737258 stripped
RectTransform:
@@ -706,12 +743,16 @@ PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
- serializedVersion: 2
+ serializedVersion: 3
m_TransformParent: {fileID: 1993296955}
m_Modifications:
- target: {fileID: 1728513650105062, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
propertyPath: m_Name
- value: Button C
+ value: Button B
+ objectReference: {fileID: 0}
+ - target: {fileID: 1728513650105062, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
+ propertyPath: m_IsActive
+ value: 1
objectReference: {fileID: 0}
- target: {fileID: 114344768413473294, guid: 05f32eddd3e41fd4597ada617b785928,
type: 3}
@@ -814,7 +855,9 @@ PrefabInstance:
value: 102
objectReference: {fileID: 0}
m_RemovedComponents: []
+ m_RemovedGameObjects: []
m_AddedGameObjects: []
+ m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
--- !u!224 &1467932573 stripped
RectTransform:
@@ -852,6 +895,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
m_Name:
m_EditorClassIdentifier:
+ m_SendPointerHoverToParent: 1
m_MoveRepeatDelay: 0.5
m_MoveRepeatRate: 0.1
m_XRTrackingOrigin: {fileID: 0}
@@ -902,26 +946,30 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1554469708}
+ serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
- m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1763776550
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
- serializedVersion: 2
+ serializedVersion: 3
m_TransformParent: {fileID: 1993296955}
m_Modifications:
- target: {fileID: 1613174875475300, guid: f77f88b14a477764bb65a49d28c02d33, type: 3}
propertyPath: m_Name
value: RightStick
objectReference: {fileID: 0}
+ - target: {fileID: 1613174875475300, guid: f77f88b14a477764bb65a49d28c02d33, type: 3}
+ propertyPath: m_IsActive
+ value: 1
+ objectReference: {fileID: 0}
- target: {fileID: 114017654419583406, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_Text
@@ -1023,7 +1071,9 @@ PrefabInstance:
value: -129
objectReference: {fileID: 0}
m_RemovedComponents: []
+ m_RemovedGameObjects: []
m_AddedGameObjects: []
+ m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f77f88b14a477764bb65a49d28c02d33, type: 3}
--- !u!224 &1763776551 stripped
RectTransform:
@@ -1043,6 +1093,7 @@ GameObject:
- component: {fileID: 1993296954}
- component: {fileID: 1993296953}
- component: {fileID: 1993296952}
+ - component: {fileID: 1993296956}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
@@ -1107,6 +1158,7 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
+ m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 0
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
@@ -1131,13 +1183,26 @@ RectTransform:
- {fileID: 223523015}
- {fileID: 1763776551}
m_Father: {fileID: 0}
- m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
+--- !u!114 &1993296956
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1993296951}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 08d714a194a0b45898f07b750bc13dd3, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ inputActions: {fileID: -944628639613478452, guid: fb4d9a5521a4f4362ab71f15991a9d03,
+ type: 3}
--- !u!850595691 &2075976824
LightingSettings:
m_ObjectHideFlags: 0
@@ -1145,7 +1210,7 @@ LightingSettings:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Settings.lighting
- serializedVersion: 5
+ serializedVersion: 6
m_GIWorkflowMode: 1
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
@@ -1154,7 +1219,7 @@ LightingSettings:
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 1
- m_BakeBackend: 0
+ m_BakeBackend: 1
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
@@ -1201,3 +1266,11 @@ LightingSettings:
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0
m_NumRaysToShootPerTexel: -1
+ m_RespectSceneVisibilityWhenBakingGI: 0
+--- !u!1660057539 &9223372036854775807
+SceneRoots:
+ m_ObjectHideFlags: 0
+ m_Roots:
+ - {fileID: 519420032}
+ - {fileID: 1993296955}
+ - {fileID: 1554469711}
diff --git a/Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions b/Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions
new file mode 100644
index 0000000000..09e047c60b
--- /dev/null
+++ b/Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions
@@ -0,0 +1,94 @@
+{
+ "name": "OnScreenControlsSampleActions",
+ "maps": [
+ {
+ "name": "OnScreenActions",
+ "id": "772d6a2a-28b2-4410-b6a1-2ee8bdfce79b",
+ "actions": [
+ {
+ "name": "X",
+ "type": "Button",
+ "id": "8ea37b03-5395-4635-a449-d0c0eae8dba2",
+ "expectedControlType": "Button",
+ "processors": "",
+ "interactions": "",
+ "initialStateCheck": false
+ },
+ {
+ "name": "Y",
+ "type": "Button",
+ "id": "5517acaf-e9ad-4a80-85f2-e980507a9975",
+ "expectedControlType": "Button",
+ "processors": "",
+ "interactions": "",
+ "initialStateCheck": false
+ },
+ {
+ "name": "A",
+ "type": "Button",
+ "id": "f1c85ee2-6cca-4b1e-b333-5a4af63ec80b",
+ "expectedControlType": "Button",
+ "processors": "",
+ "interactions": "",
+ "initialStateCheck": false
+ },
+ {
+ "name": "B",
+ "type": "Button",
+ "id": "5c77404a-9405-474b-9ece-a9111e48946e",
+ "expectedControlType": "Button",
+ "processors": "",
+ "interactions": "",
+ "initialStateCheck": false
+ }
+ ],
+ "bindings": [
+ {
+ "name": "",
+ "id": "19fbcc4b-8514-42bb-9c55-494994a21d9b",
+ "path": "/buttonWest",
+ "interactions": "",
+ "processors": "",
+ "groups": "",
+ "action": "X",
+ "isComposite": false,
+ "isPartOfComposite": false
+ },
+ {
+ "name": "",
+ "id": "bdd36c52-990c-487f-ae68-4a9aec73a464",
+ "path": "/buttonNorth",
+ "interactions": "",
+ "processors": "",
+ "groups": "",
+ "action": "Y",
+ "isComposite": false,
+ "isPartOfComposite": false
+ },
+ {
+ "name": "",
+ "id": "88d53996-7ab7-44e7-9660-e602c73b5539",
+ "path": "",
+ "interactions": "",
+ "processors": "",
+ "groups": "",
+ "action": "A",
+ "isComposite": false,
+ "isPartOfComposite": false
+ },
+ {
+ "name": "",
+ "id": "598b01ac-d085-45e7-b027-aca3b6048f9a",
+ "path": "",
+ "interactions": "",
+ "processors": "",
+ "groups": "",
+ "action": "B",
+ "isComposite": false,
+ "isPartOfComposite": false
+ }
+ ]
+ }
+ ],
+ "controlSchemes": []
+}
\ No newline at end of file
diff --git a/Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions.meta b/Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions.meta
new file mode 100644
index 0000000000..c68f85e02b
--- /dev/null
+++ b/Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions.meta
@@ -0,0 +1,14 @@
+fileFormatVersion: 2
+guid: fb4d9a5521a4f4362ab71f15991a9d03
+ScriptedImporter:
+ internalIDToNameTable: []
+ externalObjects: {}
+ serializedVersion: 2
+ userData:
+ assetBundleName:
+ assetBundleVariant:
+ script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
+ generateWrapperCode: 0
+ wrapperCodePath:
+ wrapperClassName:
+ wrapperCodeNamespace:
diff --git a/OnScreenControlNotes.md b/OnScreenControlNotes.md
new file mode 100644
index 0000000000..7b4d6a4cd5
--- /dev/null
+++ b/OnScreenControlNotes.md
@@ -0,0 +1,2 @@
+# On-Screen Controls Notes
+
diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs
index e20bbf7256..1d78df2609 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs
@@ -17,11 +17,13 @@ public class OnScreenButton : OnScreenControl, IPointerDownHandler, IPointerUpHa
{
public void OnPointerUp(PointerEventData eventData)
{
+ Debug.Log($"OnScreenButton.OnPointerUp frame{Time.frameCount}");
SendValueToControl(0.0f);
}
public void OnPointerDown(PointerEventData eventData)
{
+ Debug.Log($"OnScreenButton.OnPointerDown frame{Time.frameCount}");
SendValueToControl(1.0f);
}
diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs
index 85f9756ef1..a90b75a287 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs
@@ -16,6 +16,36 @@
namespace UnityEngine.InputSystem.OnScreen
{
+ ///
+ /// Defines the update policy to be adapted by the OnScreenControl
.
+ ///
+ public enum OnScreenControlUpdateMode
+ {
+ ///
+ /// Using this update mode, control state updates are managed via input queue events using
+ /// .
+ /// This is similar to the operation of a custom device and implies that any control data
+ /// written during the current frame is not seen until the next update (frame buffer swap) introducing
+ /// a latency of 1 frame with respect to the input driving the OnScreenControl.
+ ///
+ ///
+ /// Prefer if the associated target control supports
+ /// it. This is the default update mode to not break backwards compability.
+ ///
+ QueueEvents,
+
+ ///
+ /// Using this update mode, control state updates are managed via
+ ///
+ /// which avoids introducing any frame latency due to control state being changed directly within the
+ /// scope of the current frame and triggering associated state monitors.
+ ///
+ ///
+ /// This is the recommended update mode to use when the associated target control supports it.
+ ///
+ ChangeState
+ }
+
///
/// Base class for on-screen controls.
///
@@ -37,6 +67,30 @@ namespace UnityEngine.InputSystem.OnScreen
///
public abstract class OnScreenControl : MonoBehaviour
{
+ ///
+ /// Specifies the to be used to update control state
+ /// associated with this OnScreenControl
.
+ ///
+ ///
+ /// Throws if the given value is outside valid range.
+ ///
+ public OnScreenControlUpdateMode updateMode
+ {
+ get => m_UpdateMode;
+ set
+ {
+ switch (value)
+ {
+ case OnScreenControlUpdateMode.ChangeState: // fall-through
+ case OnScreenControlUpdateMode.QueueEvents:
+ m_UpdateMode = value;
+ break;
+ default:
+ throw new ArgumentOutOfRangeException($"Invalid {nameof(OnScreenControlUpdateMode)}: {(int)value}");
+ }
+ }
+ }
+
///
/// The control path (see ) for the control that the on-screen
/// control will feed input into.
@@ -78,7 +132,8 @@ public string controlPath
private InputControl m_Control;
private OnScreenControl m_NextControlOnDevice;
private InputEventPtr m_InputEventPtr;
-
+ private OnScreenControlUpdateMode m_UpdateMode;
+
///
/// Accessor for the of the component. Must be implemented by subclasses.
///
@@ -184,28 +239,26 @@ private void SetupInputControl()
protected void SendValueToControl(TValue value)
where TValue : struct
{
- if (m_Control == null)
+ if (m_Control == null)
return;
- if (!(m_Control is InputControl control))
- throw new ArgumentException(
- $"The control path {controlPath} yields a control of type {m_Control.GetType().Name} which is not an InputControl with value type {typeof(TValue).Name}", nameof(value));
-
- ////FIXME: this gives us a one-frame lag (use InputState.Change instead?)
- m_InputEventPtr.internalTime = InputRuntime.s_Instance.currentTime;
- control.WriteValueIntoEvent(value, m_InputEventPtr);
- InputSystem.QueueEvent(m_InputEventPtr);
+ if (!(m_Control is InputControl inputControl))
+ throw new ArgumentException(
+ $"The control path {controlPath} yields a control of type {m_Control.GetType().Name} which is not an InputControl with value type {typeof(TValue).Name}", nameof(value));
+
+ m_InputEventPtr.internalTime = InputRuntime.s_Instance.currentTime;
+ inputControl.WriteValueIntoEvent(value, m_InputEventPtr);
+ Change(m_InputEventPtr);
}
protected void SentDefaultValueToControl()
{
if (m_Control == null)
return;
-
- ////FIXME: this gives us a one-frame lag (use InputState.Change instead?)
+
m_InputEventPtr.internalTime = InputRuntime.s_Instance.currentTime;
m_Control.ResetToDefaultStateInEvent(m_InputEventPtr);
- InputSystem.QueueEvent(m_InputEventPtr);
+ Change(m_InputEventPtr);
}
protected virtual void OnEnable()
@@ -251,6 +304,21 @@ protected virtual void OnDisable()
break;
}
}
+
+ private void Change(InputEventPtr inputEventPtr)
+ {
+ switch (m_UpdateMode)
+ {
+ case OnScreenControlUpdateMode.ChangeState:
+ InputState.Change(control.m_Device, m_InputEventPtr);
+ break;
+ case OnScreenControlUpdateMode.QueueEvents:
+ default:
+ // Note that this gives us a one-frame lag
+ InputSystem.QueueEvent(m_InputEventPtr);
+ break;
+ }
+ }
private struct OnScreenDeviceInfo
{
From 9f09313515ac8b14f929c90c4aa5c4d8eb189529 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ha=CC=8Akan=20Sidenvall?=
Date: Sun, 5 Nov 2023 08:45:21 +0100
Subject: [PATCH 4/7] Evolved OnScreen sample and OnScreenControls
---
.../OnScreenControlsSample.cs | 59 +++++++------
...OnScreenControlsSampleActions.inputactions | 84 ++++++++++++++++++-
.../Plugins/OnScreen/OnScreenButton.cs | 3 +-
.../Plugins/OnScreen/OnScreenControl.cs | 30 +++----
.../Plugins/OnScreen/OnScreenStick.cs | 1 +
5 files changed, 132 insertions(+), 45 deletions(-)
diff --git a/Assets/Samples/OnScreenControls/OnScreenControlsSample.cs b/Assets/Samples/OnScreenControls/OnScreenControlsSample.cs
index 8b62b38b96..65930d635c 100644
--- a/Assets/Samples/OnScreenControls/OnScreenControlsSample.cs
+++ b/Assets/Samples/OnScreenControls/OnScreenControlsSample.cs
@@ -12,48 +12,55 @@
// or a physical gamepad.
//
// Note that on-screen controls 1 and 2 on the other hand are bound to a keyboard control layout and therefore
-// generates input events similar to a physical hardware keyboard.
+// generates input events similar to a physical hardware keyboard.
//
// When actions defined for this sample are triggered, a log message is generated to show when the actions
// are performed.
+//
+// Note that actions for this example have been setup to allow either on-screen controls or physical gamepad/keyboard
+// controls to be used interchangeably.
-using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
+using UnityEngine.InputSystem.OnScreen;
public sealed class OnScreenControlsSample : MonoBehaviour
{
- public InputActionAsset inputActions;
+ public InputActionReference mode1, mode2, leftStick, rightStick, x, y, a, b;
+ public OnScreenControlUpdateMode updateMode;
- List m_EnabledActions;
+ void UpdateCurrentMode(OnScreenControlUpdateMode mode)
+ {
+ Debug.Log($"Switched to OnScreenControl Update Mode: {mode.ToString()}");
+ foreach (var onScreenControl in GetComponentsInChildren())
+ onScreenControl.updateMode = mode;
+ }
- void OnEnable()
+ void EnableAndLogPerformed(InputActionReference reference)
{
- // Enable all actions in associated inputActions and add an event handler to log when action is performed.
- m_EnabledActions = new List();
- foreach (var actionMap in inputActions.actionMaps)
- {
- foreach (var action in actionMap)
- {
- action.Enable();
- action.performed += Log;
- m_EnabledActions.Add(action);
- }
- }
+ reference.action.Enable();
+ reference.action.performed += Performed;
}
- void OnDisable()
+ void Start()
{
- // Revert action handler and disable the action to clean-up from what we did in OnEnable().
- foreach (var action in m_EnabledActions)
- {
- action.performed -= Log;
- action.Disable();
- }
+ UpdateCurrentMode(updateMode);
+ EnableAndLogPerformed(mode1);
+ mode1.action.performed += (_) => UpdateCurrentMode(OnScreenControlUpdateMode.QueueEvents);
+ EnableAndLogPerformed(mode2);
+ mode2.action.performed += (_) => UpdateCurrentMode(OnScreenControlUpdateMode.ChangeState);
+
+ EnableAndLogPerformed(x);
+ EnableAndLogPerformed(y);
+ EnableAndLogPerformed(a);
+ EnableAndLogPerformed(b);
+
+ EnableAndLogPerformed(leftStick);
+ EnableAndLogPerformed(rightStick);
}
-
- void Log(InputAction.CallbackContext context)
+
+ void Performed(InputAction.CallbackContext context)
{
- Debug.Log($"Performed {context.action.name} in frame:{Time.frameCount}");
+ Debug.Log($"Performed action={context.action.name}, Time.frameCount={Time.frameCount}, context.time={context.time}, Time.time={Time.time}");
}
}
diff --git a/Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions b/Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions
index 09e047c60b..483e7fb507 100644
--- a/Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions
+++ b/Assets/Samples/OnScreenControls/OnScreenControlsSampleActions.inputactions
@@ -40,6 +40,42 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
+ },
+ {
+ "name": "Left Stick",
+ "type": "Value",
+ "id": "c2fb729f-5485-4790-a82b-7741c1194155",
+ "expectedControlType": "Vector2",
+ "processors": "",
+ "interactions": "",
+ "initialStateCheck": true
+ },
+ {
+ "name": "Right Stick",
+ "type": "Value",
+ "id": "94fe337f-c56d-4cd7-b840-6ebe5110fd6d",
+ "expectedControlType": "Vector2",
+ "processors": "",
+ "interactions": "",
+ "initialStateCheck": true
+ },
+ {
+ "name": "Switch To Update Mode 1",
+ "type": "Button",
+ "id": "df032eaa-6a00-4e76-bb99-c591f6441ebb",
+ "expectedControlType": "Button",
+ "processors": "",
+ "interactions": "",
+ "initialStateCheck": false
+ },
+ {
+ "name": "Switch To Update Mode 2",
+ "type": "Button",
+ "id": "06aae2f0-1f25-4e65-b32d-3d1ad547c6ba",
+ "expectedControlType": "Button",
+ "processors": "",
+ "interactions": "",
+ "initialStateCheck": false
}
],
"bindings": [
@@ -68,7 +104,7 @@
{
"name": "",
"id": "88d53996-7ab7-44e7-9660-e602c73b5539",
- "path": "",
+ "path": "/buttonSouth",
"interactions": "",
"processors": "",
"groups": "",
@@ -79,13 +115,57 @@
{
"name": "",
"id": "598b01ac-d085-45e7-b027-aca3b6048f9a",
- "path": "",
+ "path": "/buttonEast",
"interactions": "",
"processors": "",
"groups": "",
"action": "B",
"isComposite": false,
"isPartOfComposite": false
+ },
+ {
+ "name": "",
+ "id": "99c367b7-86e9-43c5-b91f-c0dd001f1765",
+ "path": "/leftStick",
+ "interactions": "",
+ "processors": "",
+ "groups": "",
+ "action": "Left Stick",
+ "isComposite": false,
+ "isPartOfComposite": false
+ },
+ {
+ "name": "",
+ "id": "ae6d4804-0117-455b-97a1-81b224304e7a",
+ "path": "/rightStick",
+ "interactions": "",
+ "processors": "",
+ "groups": "",
+ "action": "Right Stick",
+ "isComposite": false,
+ "isPartOfComposite": false
+ },
+ {
+ "name": "",
+ "id": "37fd29c6-edf6-4773-acbe-b8371ba5b2ed",
+ "path": "/1",
+ "interactions": "",
+ "processors": "",
+ "groups": "",
+ "action": "Switch To Update Mode 1",
+ "isComposite": false,
+ "isPartOfComposite": false
+ },
+ {
+ "name": "",
+ "id": "f9ae4c0e-2342-41ba-bba4-fb281e9a36a0",
+ "path": "/2",
+ "interactions": "",
+ "processors": "",
+ "groups": "",
+ "action": "Switch To Update Mode 2",
+ "isComposite": false,
+ "isPartOfComposite": false
}
]
}
diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs
index 1d78df2609..c02eb32d29 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs
@@ -17,13 +17,12 @@ public class OnScreenButton : OnScreenControl, IPointerDownHandler, IPointerUpHa
{
public void OnPointerUp(PointerEventData eventData)
{
- Debug.Log($"OnScreenButton.OnPointerUp frame{Time.frameCount}");
SendValueToControl(0.0f);
}
public void OnPointerDown(PointerEventData eventData)
{
- Debug.Log($"OnScreenButton.OnPointerDown frame{Time.frameCount}");
+ Debug.Log($"OnScreenButton.OnPointerDown Time.frameCount={Time.frameCount}, Time.time={Time.time}"); // TODO: Remove, temporary to show frame time update
SendValueToControl(1.0f);
}
diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs
index a90b75a287..4a42e1e83a 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenControl.cs
@@ -33,7 +33,7 @@ public enum OnScreenControlUpdateMode
/// it. This is the default update mode to not break backwards compability.
///
QueueEvents,
-
+
///
/// Using this update mode, control state updates are managed via
///
@@ -42,10 +42,10 @@ public enum OnScreenControlUpdateMode
///
///
/// This is the recommended update mode to use when the associated target control supports it.
- ///
+ ///
ChangeState
}
-
+
///
/// Base class for on-screen controls.
///
@@ -90,7 +90,7 @@ public OnScreenControlUpdateMode updateMode
}
}
}
-
+
///
/// The control path (see ) for the control that the on-screen
/// control will feed input into.
@@ -133,7 +133,7 @@ public string controlPath
private OnScreenControl m_NextControlOnDevice;
private InputEventPtr m_InputEventPtr;
private OnScreenControlUpdateMode m_UpdateMode;
-
+
///
/// Accessor for the of the component. Must be implemented by subclasses.
///
@@ -239,23 +239,23 @@ private void SetupInputControl()
protected void SendValueToControl(TValue value)
where TValue : struct
{
- if (m_Control == null)
+ if (m_Control == null)
return;
- if (!(m_Control is InputControl inputControl))
- throw new ArgumentException(
- $"The control path {controlPath} yields a control of type {m_Control.GetType().Name} which is not an InputControl with value type {typeof(TValue).Name}", nameof(value));
-
- m_InputEventPtr.internalTime = InputRuntime.s_Instance.currentTime;
- inputControl.WriteValueIntoEvent(value, m_InputEventPtr);
- Change(m_InputEventPtr);
+ if (!(m_Control is InputControl inputControl))
+ throw new ArgumentException(
+ $"The control path {controlPath} yields a control of type {m_Control.GetType().Name} which is not an InputControl with value type {typeof(TValue).Name}", nameof(value));
+
+ m_InputEventPtr.internalTime = InputRuntime.s_Instance.currentTime;
+ inputControl.WriteValueIntoEvent(value, m_InputEventPtr);
+ Change(m_InputEventPtr);
}
protected void SentDefaultValueToControl()
{
if (m_Control == null)
return;
-
+
m_InputEventPtr.internalTime = InputRuntime.s_Instance.currentTime;
m_Control.ResetToDefaultStateInEvent(m_InputEventPtr);
Change(m_InputEventPtr);
@@ -304,7 +304,7 @@ protected virtual void OnDisable()
break;
}
}
-
+
private void Change(InputEventPtr inputEventPtr)
{
switch (m_UpdateMode)
diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs
index 978931a15a..f884faddb3 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenStick.cs
@@ -185,6 +185,7 @@ private void MoveStick(Vector2 pointerPosition, Camera uiCamera)
break;
}
+ Debug.Log($"OnScreenStick.OnPointerDown Time.frameCount={Time.frameCount}, Time.time={Time.time}"); // TODO: Remove, temporary to show frame time update
var newPos = new Vector2(delta.x / movementRange, delta.y / movementRange);
SendValueToControl(newPos);
}
From 40b1fdc84b9617dc84fccabc6678ca4dde6b1602 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ha=CC=8Akan=20Sidenvall?=
Date: Mon, 6 Nov 2023 09:57:06 +0100
Subject: [PATCH 5/7] Fixed formatting
---
.../InputSystem/Plugins/OnScreen/OnScreenButton.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs
index c02eb32d29..58fe8a24cc 100644
--- a/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs
+++ b/Packages/com.unity.inputsystem/InputSystem/Plugins/OnScreen/OnScreenButton.cs
@@ -23,6 +23,7 @@ public void OnPointerUp(PointerEventData eventData)
public void OnPointerDown(PointerEventData eventData)
{
Debug.Log($"OnScreenButton.OnPointerDown Time.frameCount={Time.frameCount}, Time.time={Time.time}"); // TODO: Remove, temporary to show frame time update
+
SendValueToControl(1.0f);
}
From 9e546c4db627308e799bc1f949bf0af67ac41c65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ha=CC=8Akan=20Sidenvall?=
Date: Mon, 6 Nov 2023 22:33:23 +0100
Subject: [PATCH 6/7] Removed redundant files
---
Assets/Debugging.cs | 18 ------------------
Assets/Debugging.cs.meta | 11 -----------
2 files changed, 29 deletions(-)
delete mode 100644 Assets/Debugging.cs
delete mode 100644 Assets/Debugging.cs.meta
diff --git a/Assets/Debugging.cs b/Assets/Debugging.cs
deleted file mode 100644
index ec4c1b980d..0000000000
--- a/Assets/Debugging.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-public class Debugging : MonoBehaviour
-{
- // Start is called before the first frame update
- void Start()
- {
-
- }
-
- // Update is called once per frame
- void Update()
- {
-
- }
-}
diff --git a/Assets/Debugging.cs.meta b/Assets/Debugging.cs.meta
deleted file mode 100644
index d2e4949049..0000000000
--- a/Assets/Debugging.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 68569583a437a42d8aa22269fb03f0b6
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
From 33a18f33f92359873a7f18acbc6c21a2f43bb2bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ha=CC=8Akan=20Sidenvall?=
Date: Mon, 6 Nov 2023 22:34:15 +0100
Subject: [PATCH 7/7] Removed redundant file
---
OnScreenControlNotes.md | 2 --
1 file changed, 2 deletions(-)
delete mode 100644 OnScreenControlNotes.md
diff --git a/OnScreenControlNotes.md b/OnScreenControlNotes.md
deleted file mode 100644
index 7b4d6a4cd5..0000000000
--- a/OnScreenControlNotes.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# On-Screen Controls Notes
-