From 8197fd4ed1e8102168fea5d9340a30f3a855b429 Mon Sep 17 00:00:00 2001 From: Bayu Satiyo Date: Fri, 9 Aug 2024 12:06:42 +0700 Subject: [PATCH] Add: Support New Input System, trigger action on push & manual Signed-off-by: Bayu Satiyo --- .github/workflows/main.yml | 3 + .../Runtime/Scripts/UniWindowController.cs | 13 ++- .../Runtime/Scripts/UniWindowMoveHandle.cs | 9 +- .../Runtime/Unity.UniWindowController.asmdef | 10 +- .../Samples/02_UiSample/UiSample.unity | 64 +++++++---- UniWinC/Packages/manifest.json | 2 +- UniWinC/Packages/packages-lock.json | 18 +-- UniWinC/ProjectSettings/ProjectSettings.asset | 106 +++++++++++++++++- UniWinC/ProjectSettings/ProjectVersion.txt | 4 +- 9 files changed, 186 insertions(+), 43 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6dacadd..fddb130 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,8 +5,11 @@ name: Generate upm branches on: push: + branches: + - main tags: - v* + workflow_dispatch: env: MAIN_BRANCH: main diff --git a/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/UniWindowController.cs b/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/UniWindowController.cs index 954e931..c303457 100644 --- a/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/UniWindowController.cs +++ b/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/UniWindowController.cs @@ -15,6 +15,9 @@ using System.Reflection; using UnityEngine.Events; #endif +#if ENABLE_INPUT_SYSTEM +using UnityEngine.InputSystem; +#endif namespace Kirurobo { @@ -637,7 +640,11 @@ private IEnumerator HitTestCoroutine() /// private void HitTestByOpaquePixel() { +#if ENABLE_INPUT_SYSTEM + Vector2 mousePos = Mouse.current.position.ReadValue(); +#elif ENABLE_LEGACY_INPUT_MANAGER Vector2 mousePos = Input.mousePosition; +#endif // マウス座標を調べる if (GetOnOpaquePixel(mousePos)) @@ -701,7 +708,11 @@ private bool GetOnOpaquePixel(Vector2 mousePos) /// private void HitTestByRaycast() { - var position = Input.mousePosition; +#if ENABLE_INPUT_SYSTEM + Vector2 position = Mouse.current.position.ReadValue(); +#elif ENABLE_LEGACY_INPUT_MANAGER + Vector2 position = Input.mousePosition; +#endif // // uGUIの上か否かを判定 var raycastResults = new List(); diff --git a/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/UniWindowMoveHandle.cs b/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/UniWindowMoveHandle.cs index 50a64cb..3eadbf7 100644 --- a/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/UniWindowMoveHandle.cs +++ b/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/UniWindowMoveHandle.cs @@ -10,6 +10,9 @@ using UnityEditor; using UnityEngine; using UnityEngine.EventSystems; +#if ENABLE_INPUT_SYSTEM +using UnityEngine.InputSystem; +#endif namespace Kirurobo { @@ -147,9 +150,13 @@ public void OnDrag(PointerEventData eventData) if (eventData.button != PointerEventData.InputButton.Left) return; // Return if any modifier key is pressed +#if ENABLE_INPUT_SYSTEM + if (Keyboard.current[Key.LeftShift].isPressed || Keyboard.current[Key.RightShift].isPressed || Keyboard.current[Key.LeftCtrl].isPressed || Keyboard.current[Key.RightCtrl].isPressed || Keyboard.current[Key.LeftAlt].isPressed || Keyboard.current[Key.RightAlt].isPressed) return; +#elif ENABLE_LEGACY_INPUT_MANAGER if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) - || Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl) + || Input.GetKey(KeyCode.LeftCtrl) || Input.GetKey(KeyCode.RightCtrl) || Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) return; +#endif // フルスクリーンならウィンドウ移動は行わない // エディタだと true になってしまうようなので、エディタ以外でのみ確認 diff --git a/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Unity.UniWindowController.asmdef b/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Unity.UniWindowController.asmdef index b6df801..a679371 100644 --- a/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Unity.UniWindowController.asmdef +++ b/UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Unity.UniWindowController.asmdef @@ -1,7 +1,9 @@ { "name": "Unity.UniWindowController", - "references": [], - "optionalUnityReferences": [], + "rootNamespace": "", + "references": [ + "GUID:75469ad4d38634e559750d17036d5f7c" + ], "includePlatforms": [ "Editor", "macOSStandalone", @@ -13,5 +15,7 @@ "overrideReferences": false, "precompiledReferences": [], "autoReferenced": true, - "defineConstraints": [] + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false } \ No newline at end of file diff --git a/UniWinC/Assets/Kirurobo/UniWindowController/Samples/02_UiSample/UiSample.unity b/UniWinC/Assets/Kirurobo/UniWindowController/Samples/02_UiSample/UiSample.unity index ba2c96a..ee860c6 100644 --- a/UniWinC/Assets/Kirurobo/UniWindowController/Samples/02_UiSample/UiSample.unity +++ b/UniWinC/Assets/Kirurobo/UniWindowController/Samples/02_UiSample/UiSample.unity @@ -38,7 +38,6 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481676, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &4 LightmapSettings: @@ -891,7 +890,7 @@ GameObject: m_Component: - component: {fileID: 1909436763} - component: {fileID: 1909436762} - - component: {fileID: 1909436761} + - component: {fileID: 1909436764} m_Layer: 0 m_Name: EventSystem m_TagString: Untagged @@ -899,26 +898,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &1909436761 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1909436760} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} - m_Name: - m_EditorClassIdentifier: - m_SendPointerHoverToParent: 1 - m_HorizontalAxis: Horizontal - m_VerticalAxis: Vertical - m_SubmitButton: Submit - m_CancelButton: Cancel - m_InputActionsPerSecond: 10 - m_RepeatDelay: 0.5 - m_ForceModuleActive: 0 --- !u!114 &1909436762 MonoBehaviour: m_ObjectHideFlags: 0 @@ -949,6 +928,47 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1909436764 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1909436760} + m_Enabled: 1 + m_EditorHideFlags: 0 + 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} + m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_DeselectOnBackgroundClick: 1 + m_PointerBehavior: 0 + m_CursorLockBehavior: 0 --- !u!1 &1923367064 GameObject: m_ObjectHideFlags: 0 diff --git a/UniWinC/Packages/manifest.json b/UniWinC/Packages/manifest.json index 4b94830..6722d22 100644 --- a/UniWinC/Packages/manifest.json +++ b/UniWinC/Packages/manifest.json @@ -1,7 +1,7 @@ { "dependencies": { - "com.unity.ai.navigation": "1.1.5", "com.unity.ide.visualstudio": "2.0.22", + "com.unity.inputsystem": "1.7.0", "com.unity.ugui": "1.0.0", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", diff --git a/UniWinC/Packages/packages-lock.json b/UniWinC/Packages/packages-lock.json index 58361b6..197273a 100644 --- a/UniWinC/Packages/packages-lock.json +++ b/UniWinC/Packages/packages-lock.json @@ -1,14 +1,5 @@ { "dependencies": { - "com.unity.ai.navigation": { - "version": "1.1.5", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.modules.ai": "1.0.0" - }, - "url": "https://packages.unity.com" - }, "com.unity.ext.nunit": { "version": "1.0.6", "depth": 2, @@ -25,6 +16,15 @@ }, "url": "https://packages.unity.com" }, + "com.unity.inputsystem": { + "version": "1.7.0", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.uielements": "1.0.0" + }, + "url": "https://packages.unity.com" + }, "com.unity.test-framework": { "version": "1.1.33", "depth": 1, diff --git a/UniWinC/ProjectSettings/ProjectSettings.asset b/UniWinC/ProjectSettings/ProjectSettings.asset index 5a90afa..472a9a8 100644 --- a/UniWinC/ProjectSettings/ProjectSettings.asset +++ b/UniWinC/ProjectSettings/ProjectSettings.asset @@ -48,6 +48,7 @@ PlayerSettings: defaultScreenHeightWeb: 600 m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 + unsupportedMSAAFallback: 0 m_SpriteBatchVertexThreshold: 300 m_MTRendering: 1 mipStripping: 0 @@ -75,6 +76,7 @@ PlayerSettings: androidMinimumWindowWidth: 400 androidMinimumWindowHeight: 300 androidFullscreenMode: 1 + androidAutoRotationBehavior: 1 defaultIsNativeResolution: 1 macRetinaSupport: 1 runInBackground: 1 @@ -135,6 +137,8 @@ PlayerSettings: vulkanEnableLateAcquireNextImage: 0 vulkanEnableCommandBufferRecycling: 1 loadStoreDebugModeEnabled: 0 + visionOSBundleVersion: 1.0 + tvOSBundleVersion: 1.0 bundleVersion: 0.9.2 preloadedAssets: [] metroInputSource: 0 @@ -147,6 +151,7 @@ PlayerSettings: isWsaHolographicRemotingEnabled: 0 enableFrameTimingStats: 0 enableOpenGLProfilerGPURecorders: 1 + allowHDRDisplaySupport: 0 useHDRDisplay: 0 hdrBitDepth: 0 m_ColorGamuts: 00000000 @@ -228,6 +233,7 @@ PlayerSettings: iOSMetalForceHardShadows: 0 metalEditorSupport: 1 metalAPIValidation: 1 + metalCompileShaderBinary: 0 iOSRenderExtraFrameOnPause: 0 iosCopyPluginsCodeInsteadOfSymlink: 0 appleDeveloperTeamID: @@ -278,7 +284,99 @@ PlayerSettings: AndroidValidateAppBundleSize: 1 AndroidAppBundleSizeToValidate: 150 m_BuildTargetIcons: [] - m_BuildTargetPlatformIcons: [] + m_BuildTargetPlatformIcons: + - m_BuildTarget: Android + m_Icons: + - m_Textures: [] + m_Width: 432 + m_Height: 432 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 324 + m_Height: 324 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 216 + m_Height: 216 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 162 + m_Height: 162 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 108 + m_Height: 108 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 81 + m_Height: 81 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 192 + m_Height: 192 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 144 + m_Height: 144 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 96 + m_Height: 96 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 72 + m_Height: 72 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 48 + m_Height: 48 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 36 + m_Height: 36 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 192 + m_Height: 192 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 144 + m_Height: 144 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 96 + m_Height: 96 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 72 + m_Height: 72 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 48 + m_Height: 48 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 36 + m_Height: 36 + m_Kind: 0 + m_SubKind: m_BuildTargetBatching: - m_BuildTarget: Standalone m_StaticBatching: 1 @@ -389,7 +487,7 @@ PlayerSettings: switchSocketConcurrencyLimit: 14 switchScreenResolutionBehavior: 2 switchUseCPUProfiler: 0 - switchUseGOLDLinker: 0 + switchEnableFileSystemTrace: 0 switchLTOSetting: 0 switchApplicationID: 0x01004b9000490000 switchNSODependencies: @@ -519,7 +617,6 @@ PlayerSettings: switchSocketBufferEfficiency: 4 switchSocketInitializeEnabled: 1 switchNetworkInterfaceManagerInitializeEnabled: 1 - switchPlayerConnectionEnabled: 1 switchUseNewStyleFilepaths: 0 switchUseLegacyFmodPriorities: 0 switchUseMicroSleepForYield: 1 @@ -686,6 +783,7 @@ PlayerSettings: metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, a: 1} metroSplashScreenUseBackgroundColor: 0 + syncCapabilities: 0 platformCapabilities: {} metroTargetDeviceFamilies: {} metroFTAName: @@ -739,7 +837,7 @@ PlayerSettings: hmiLogStartupTiming: 0 hmiCpuConfiguration: apiCompatibilityLevel: 6 - activeInputHandler: 0 + activeInputHandler: 2 windowsGamepadBackendHint: 0 cloudProjectId: framebufferDepthMemorylessMode: 0 diff --git a/UniWinC/ProjectSettings/ProjectVersion.txt b/UniWinC/ProjectSettings/ProjectVersion.txt index 9f9a533..32f4211 100644 --- a/UniWinC/ProjectSettings/ProjectVersion.txt +++ b/UniWinC/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2022.3.26f1 -m_EditorVersionWithRevision: 2022.3.26f1 (ec6cd8118806) +m_EditorVersion: 2022.3.39f1 +m_EditorVersionWithRevision: 2022.3.39f1 (4e1b0f82c39a)