From 33a915f40f4042fabca2da21060d9708246e6c46 Mon Sep 17 00:00:00 2001 From: Varneon Date: Sat, 28 Oct 2023 13:13:50 -0700 Subject: [PATCH 1/4] Add automatic VR scrolling --- .../Runtime/Udon Programs/QuickMenu.asset | 209 +++++++++++++++--- .../Runtime/Udon Programs/QuickMenu.cs | 112 +++++++++- 2 files changed, 282 insertions(+), 39 deletions(-) diff --git a/Packages/com.varneon.vudon.quick-menu/Runtime/Udon Programs/QuickMenu.asset b/Packages/com.varneon.vudon.quick-menu/Runtime/Udon Programs/QuickMenu.asset index 5ce0b56..c71fd25 100644 --- a/Packages/com.varneon.vudon.quick-menu/Runtime/Udon Programs/QuickMenu.asset +++ b/Packages/com.varneon.vudon.quick-menu/Runtime/Udon Programs/QuickMenu.asset @@ -44,7 +44,7 @@ MonoBehaviour: Data: - Name: Entry: 12 - Data: 59 + Data: 62 - Name: Entry: 7 Data: @@ -2846,13 +2846,13 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: linearInputIncrement + Data: verticalBuildup - Name: $v Entry: 7 Data: 163|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 - Data: linearInputIncrement + Data: verticalBuildup - Name: k__BackingField Entry: 9 Data: 139 @@ -2895,16 +2895,163 @@ MonoBehaviour: Data: - Name: $k Entry: 1 - Data: dominantPickupHand + Data: verticalDesktopNavigation - Name: $v Entry: 7 Data: 165|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: k__BackingField + Entry: 1 + Data: verticalDesktopNavigation + - Name: k__BackingField + Entry: 9 + Data: 3 + - Name: k__BackingField + Entry: 9 + Data: 3 + - Name: k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 166|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: holdingVerticalNavigation + - Name: $v + Entry: 7 + Data: 167|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: k__BackingField + Entry: 1 + Data: holdingVerticalNavigation + - Name: k__BackingField + Entry: 9 + Data: 121 + - Name: k__BackingField + Entry: 9 + Data: 121 + - Name: k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 168|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: linearInputIncrement + - Name: $v + Entry: 7 + Data: 169|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + - Name: k__BackingField + Entry: 1 + Data: linearInputIncrement + - Name: k__BackingField + Entry: 9 + Data: 139 + - Name: k__BackingField + Entry: 9 + Data: 139 + - Name: k__BackingField + Entry: 7 + Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib + - Name: + Entry: 6 + Data: + - Name: + Entry: 8 + Data: + - Name: k__BackingField + Entry: 5 + Data: false + - Name: _fieldAttributes + Entry: 7 + Data: 170|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + mscorlib + - Name: + Entry: 12 + Data: 0 + - Name: + Entry: 13 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 8 + Data: + - Name: + Entry: 7 + Data: + - Name: $k + Entry: 1 + Data: dominantPickupHand + - Name: $v + Entry: 7 + Data: 171|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: dominantPickupHand - Name: k__BackingField Entry: 7 - Data: 166|System.RuntimeType, mscorlib + Data: 172|System.RuntimeType, mscorlib - Name: Entry: 1 Data: VRC.SDKBase.VRC_Pickup+PickupHand, VRCSDKBase @@ -2913,7 +3060,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 166 + Data: 172 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2928,7 +3075,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 167|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 173|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -2953,13 +3100,13 @@ MonoBehaviour: Data: dominantHandType - Name: $v Entry: 7 - Data: 168|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 174|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: dominantHandType - Name: k__BackingField Entry: 7 - Data: 169|System.RuntimeType, mscorlib + Data: 175|System.RuntimeType, mscorlib - Name: Entry: 1 Data: VRC.Udon.Common.HandType, VRC.Udon.Common @@ -2968,7 +3115,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 169 + Data: 175 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -2983,7 +3130,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 170|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 176|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -3008,13 +3155,13 @@ MonoBehaviour: Data: dominantTrackingDataType - Name: $v Entry: 7 - Data: 171|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 177|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: dominantTrackingDataType - Name: k__BackingField Entry: 7 - Data: 172|System.RuntimeType, mscorlib + Data: 178|System.RuntimeType, mscorlib - Name: Entry: 1 Data: VRC.SDKBase.VRCPlayerApi+TrackingDataType, VRCSDKBase @@ -3023,7 +3170,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 172 + Data: 178 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -3038,7 +3185,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 173|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 179|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -3063,7 +3210,7 @@ MonoBehaviour: Data: dominantRightHand - Name: $v Entry: 7 - Data: 174|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 180|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: dominantRightHand @@ -3087,7 +3234,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 175|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 181|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -3112,13 +3259,13 @@ MonoBehaviour: Data: localHandPos - Name: $v Entry: 7 - Data: 176|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 182|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: localHandPos - Name: k__BackingField Entry: 7 - Data: 177|System.RuntimeType, mscorlib + Data: 183|System.RuntimeType, mscorlib - Name: Entry: 1 Data: UnityEngine.Vector3, UnityEngine.CoreModule @@ -3127,7 +3274,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 177 + Data: 183 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -3142,7 +3289,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 178|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 184|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -3167,16 +3314,16 @@ MonoBehaviour: Data: lastLocalHandPos - Name: $v Entry: 7 - Data: 179|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 185|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: lastLocalHandPos - Name: k__BackingField Entry: 9 - Data: 177 + Data: 183 - Name: k__BackingField Entry: 9 - Data: 177 + Data: 183 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -3191,7 +3338,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 180|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 186|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -3216,13 +3363,13 @@ MonoBehaviour: Data: localPlayer - Name: $v Entry: 7 - Data: 181|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 187|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: localPlayer - Name: k__BackingField Entry: 7 - Data: 182|System.RuntimeType, mscorlib + Data: 188|System.RuntimeType, mscorlib - Name: Entry: 1 Data: VRC.SDKBase.VRCPlayerApi, VRCSDKBase @@ -3231,7 +3378,7 @@ MonoBehaviour: Data: - Name: k__BackingField Entry: 9 - Data: 182 + Data: 188 - Name: k__BackingField Entry: 7 Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib @@ -3246,7 +3393,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 183|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 189|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 @@ -3271,7 +3418,7 @@ MonoBehaviour: Data: vrEnabled - Name: $v Entry: 7 - Data: 184|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor + Data: 190|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor - Name: k__BackingField Entry: 1 Data: vrEnabled @@ -3295,7 +3442,7 @@ MonoBehaviour: Data: false - Name: _fieldAttributes Entry: 7 - Data: 185|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], + Data: 191|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib - Name: Entry: 12 diff --git a/Packages/com.varneon.vudon.quick-menu/Runtime/Udon Programs/QuickMenu.cs b/Packages/com.varneon.vudon.quick-menu/Runtime/Udon Programs/QuickMenu.cs index 85ba5c0..f5b99ed 100644 --- a/Packages/com.varneon.vudon.quick-menu/Runtime/Udon Programs/QuickMenu.cs +++ b/Packages/com.varneon.vudon.quick-menu/Runtime/Udon Programs/QuickMenu.cs @@ -177,6 +177,8 @@ private float NavigationDirection { navigationDirection = value; + holdingVerticalNavigation = value != 0f; + switch (navigationDirection) { case -1: @@ -186,6 +188,8 @@ private float NavigationDirection NavigateUp(); break; } + + verticalBuildup = 0f; } } } @@ -256,6 +260,28 @@ private int HorizontalDesktopNavigation private bool holdingHorizontalNavigation; + private float verticalBuildup; + + private int VerticalDesktopNavigation + { + get => verticalDesktopNavigation; + set + { + if (verticalDesktopNavigation != value) + { + verticalDesktopNavigation = value; + + holdingVerticalNavigation = verticalDesktopNavigation != 0; + + verticalBuildup = 0f; + } + } + } + + private int verticalDesktopNavigation; + + private bool holdingVerticalNavigation; + private float linearInputIncrement = 0.02f; private VRC_Pickup.PickupHand dominantPickupHand = VRC_Pickup.PickupHand.Right; @@ -300,6 +326,8 @@ private void Update() if (vrEnabled) { if (editingVRValue) { HandleVRValueEditingInput(); } + + if (holdingVerticalNavigation) { HandleVRAutoNavigation(); } } else { @@ -346,14 +374,6 @@ private void HandleDesktopInput() break; } } - else if (hasMoreThanOneItemInFolder && (Input.GetKeyDown(KeyCode.UpArrow) || scroll > 0.5f)) - { - NavigateUp(); - } - else if (hasMoreThanOneItemInFolder && (Input.GetKeyDown(KeyCode.DownArrow) || scroll < -0.5f)) - { - NavigateDown(); - } else if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Mouse0)) { NavigateForward(); @@ -362,6 +382,26 @@ private void HandleDesktopInput() { NavigateBack(); } + else if (hasMoreThanOneItemInFolder) + { + if (Input.GetKeyDown(KeyCode.UpArrow)) + { + NavigateUp(); + + VerticalDesktopNavigation = 1; + } + else if (Input.GetKeyDown(KeyCode.DownArrow)) + { + NavigateDown(); + + VerticalDesktopNavigation = -1; + } + else if(Math.Abs(scroll) > 0.5f) + { + if(scroll > 0.5f) { NavigateUp(); } + else if(scroll < -0.5f) { NavigateDown(); } + } + } if (holdingHorizontalNavigation) { @@ -392,6 +432,56 @@ private void HandleDesktopInput() break; } } + + if (holdingVerticalNavigation) + { + verticalBuildup += Time.deltaTime; + + if (verticalBuildup > 0.5f) + { + verticalBuildup -= 0.1f; + + switch (verticalDesktopNavigation) + { + case -1: + NavigateDown(); + break; + case 1: + NavigateUp(); + break; + } + } + + switch (verticalDesktopNavigation) + { + case -1: + if (Input.GetKeyUp(KeyCode.DownArrow)) { VerticalDesktopNavigation = 0; } + break; + case 1: + if (Input.GetKeyUp(KeyCode.UpArrow)) { VerticalDesktopNavigation = 0; } + break; + } + } + } + + private void HandleVRAutoNavigation() + { + verticalBuildup += Time.deltaTime; + + if (verticalBuildup > 0.5f) + { + verticalBuildup -= 0.1f; + + switch (navigationDirection) + { + case -1: + NavigateDown(); + break; + case 1: + NavigateUp(); + break; + } + } } private void NavigateUp() @@ -1074,6 +1164,12 @@ private void ToggleQuickMenu() sfxSource.PlayOneShot(open ? audioOpen : audioClose); + if (!open) + { + if (vrEnabled) { NavigationDirection = 0; } + else { VerticalDesktopNavigation = 0; } + } + TriggerHaptics(); } From 23b242fe134ab0afcab7af38423f3d10c84570ea Mon Sep 17 00:00:00 2001 From: Varneon Date: Sat, 28 Oct 2023 13:16:19 -0700 Subject: [PATCH 2/4] Remove UdonSharp dependency Closes #10 --- Packages/com.varneon.vudon.quick-menu/package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/Packages/com.varneon.vudon.quick-menu/package.json b/Packages/com.varneon.vudon.quick-menu/package.json index 9dcef9c..1161a9f 100644 --- a/Packages/com.varneon.vudon.quick-menu/package.json +++ b/Packages/com.varneon.vudon.quick-menu/package.json @@ -11,12 +11,10 @@ }, "resolutionStrategy": "highestMinor", "dependencies": { - "com.vrchat.udonsharp": "1.1.7", "com.varneon.vudon.array-extensions": "0.3.0", "com.varneon.vudon.menus": "0.1.0-alpha.4" }, "vpmDependencies": { - "com.vrchat.udonsharp": ">=1.1.7 <2.0.0", "com.varneon.vudon.array-extensions": ">=0.3.0", "com.varneon.vudon.menus": ">=0.1.0-alpha.3 <1.0.0" } From cb9cd77cdfdb30f14c0f0982e7138070b9972bf6 Mon Sep 17 00:00:00 2001 From: Varneon Date: Sat, 28 Oct 2023 13:17:29 -0700 Subject: [PATCH 3/4] Bump alpha version --- Packages/com.varneon.vudon.quick-menu/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.varneon.vudon.quick-menu/package.json b/Packages/com.varneon.vudon.quick-menu/package.json index 1161a9f..b1dd592 100644 --- a/Packages/com.varneon.vudon.quick-menu/package.json +++ b/Packages/com.varneon.vudon.quick-menu/package.json @@ -1,7 +1,7 @@ { "name": "com.varneon.vudon.quick-menu", "displayName": "VUdon - Quick Menu", - "version": "0.1.0-alpha.9", + "version": "0.1.0-alpha.10", "unity": "2019.4", "unityRelease": "29f1", "description": "HUD quick menu prefab for VRChat worlds", From f1868b2085f86ed6b85780ae9f21ca9b126f2b3e Mon Sep 17 00:00:00 2001 From: Varneon Date: Sat, 28 Oct 2023 13:18:26 -0700 Subject: [PATCH 4/4] Update dependency definition version ranges --- Packages/com.varneon.vudon.quick-menu/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Packages/com.varneon.vudon.quick-menu/package.json b/Packages/com.varneon.vudon.quick-menu/package.json index b1dd592..27df79e 100644 --- a/Packages/com.varneon.vudon.quick-menu/package.json +++ b/Packages/com.varneon.vudon.quick-menu/package.json @@ -11,11 +11,11 @@ }, "resolutionStrategy": "highestMinor", "dependencies": { - "com.varneon.vudon.array-extensions": "0.3.0", - "com.varneon.vudon.menus": "0.1.0-alpha.4" + "com.varneon.vudon.array-extensions": "0.3.1", + "com.varneon.vudon.menus": "0.1.0-alpha.5" }, "vpmDependencies": { - "com.varneon.vudon.array-extensions": ">=0.3.0", - "com.varneon.vudon.menus": ">=0.1.0-alpha.3 <1.0.0" + "com.varneon.vudon.array-extensions": ">=0.3.1", + "com.varneon.vudon.menus": ">=0.1.0-alpha.5 <1.0.0" } } \ No newline at end of file