From dd9304e476619e1a187b8ebff00197869f570231 Mon Sep 17 00:00:00 2001 From: xpeng <1216772231@qq.com> Date: Tue, 15 Mar 2022 17:15:34 +0100 Subject: [PATCH] Fix touch collider issue --- Assets/Scenes/Main Scene.unity | 8 +- Assets/Scripts/ButtonToKey.cs | 1 - Assets/Scripts/Controller.cs | 1 - Assets/Scripts/Serial2.cs | 3 - Assets/Scripts/TouchToSerial.cs | 24 ++- .../Settings/Open XR Package Settings.asset | 4 +- ProjectSettings/ProjectSettings.asset | 173 +++--------------- 7 files changed, 49 insertions(+), 165 deletions(-) diff --git a/Assets/Scenes/Main Scene.unity b/Assets/Scenes/Main Scene.unity index c02400b..0e78532 100644 --- a/Assets/Scenes/Main Scene.unity +++ b/Assets/Scenes/Main Scene.unity @@ -1887,15 +1887,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 795547410136657018, guid: ea6463ca199d52046962b69f2ab654ef, type: 3} propertyPath: m_LocalPosition.x - value: -0 + value: 0 objectReference: {fileID: 0} - target: {fileID: 795547410136657018, guid: ea6463ca199d52046962b69f2ab654ef, type: 3} propertyPath: m_LocalPosition.y - value: 1.397 + value: 1.3969 objectReference: {fileID: 0} - target: {fileID: 795547410136657018, guid: ea6463ca199d52046962b69f2ab654ef, type: 3} propertyPath: m_LocalPosition.z - value: 0.061 + value: 0.0607 objectReference: {fileID: 0} - target: {fileID: 795547410136657018, guid: ea6463ca199d52046962b69f2ab654ef, type: 3} propertyPath: m_LocalRotation.w @@ -4420,7 +4420,7 @@ Transform: m_GameObject: {fileID: 1040369113} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0.2, y: 0.1, z: 0.1} + m_LocalScale: {x: 0.15, y: 0.05, z: 0.05} m_Children: [] m_Father: {fileID: 371544748} m_RootOrder: 0 diff --git a/Assets/Scripts/ButtonToKey.cs b/Assets/Scripts/ButtonToKey.cs index b55c030..b31f438 100644 --- a/Assets/Scripts/ButtonToKey.cs +++ b/Assets/Scripts/ButtonToKey.cs @@ -27,7 +27,6 @@ public class ButtonToKey : MonoBehaviour private void OnTriggerEnter(Collider other) { _insideColliderCount += 1; - } private void OnTriggerExit(Collider other) diff --git a/Assets/Scripts/Controller.cs b/Assets/Scripts/Controller.cs index 1a24ede..d39e519 100644 --- a/Assets/Scripts/Controller.cs +++ b/Assets/Scripts/Controller.cs @@ -4,7 +4,6 @@ using UnityEngine; using UnityEngine.XR; public class Controller : MonoBehaviour { - // Start is called before the first frame update public XRNode Hand; InputDevice device; public float duration; diff --git a/Assets/Scripts/Serial2.cs b/Assets/Scripts/Serial2.cs index 5f330ce..1b91c5f 100644 --- a/Assets/Scripts/Serial2.cs +++ b/Assets/Scripts/Serial2.cs @@ -8,7 +8,6 @@ public class Serial2 : MonoBehaviour byte[] incomPacket = new byte[6]; byte[] settingPacket = new byte[6]; static byte[] touchPacket = new byte[9]; - static bool startUp = true; //use ture for default start up state to prevent restart game float timer = 0; bool failed = false; byte recivData; @@ -36,7 +35,6 @@ public class Serial2 : MonoBehaviour { case 76: case 69: - startUp = false; break; case 114: case 107: @@ -46,7 +44,6 @@ public class Serial2 : MonoBehaviour Array.Clear(incomPacket, 0, incomPacket.Length); break; case 65: - startUp = true; break; } } diff --git a/Assets/Scripts/TouchToSerial.cs b/Assets/Scripts/TouchToSerial.cs index f551be6..7ede16d 100644 --- a/Assets/Scripts/TouchToSerial.cs +++ b/Assets/Scripts/TouchToSerial.cs @@ -3,16 +3,30 @@ using UnityEngine; public class TouchToSerial : MonoBehaviour { public int Area; + int _insideColliderCount = 0; + + private void Update() + { + if (_insideColliderCount == 0) + { + Serial.ChangeTouch((int)Area, true); + Serial.SendTouch(); + } + else + { + Serial.ChangeTouch((int)Area, false); + Serial.SendTouch(); + } + } + private void OnTriggerEnter(Collider other) { - Serial.ChangeTouch((int)Area, true); - Serial.SendTouch(); + _insideColliderCount += 1; } private void OnTriggerExit(Collider other) { - Serial.ChangeTouch((int)Area, false); - Serial.SendTouch(); + _insideColliderCount -= 1; + _insideColliderCount = Mathf.Max(0, _insideColliderCount); } - } diff --git a/Assets/XR/Settings/Open XR Package Settings.asset b/Assets/XR/Settings/Open XR Package Settings.asset index a667b17..29e9284 100644 --- a/Assets/XR/Settings/Open XR Package Settings.asset +++ b/Assets/XR/Settings/Open XR Package Settings.asset @@ -32,7 +32,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 761fdd4502cb7a84e9ec7a2b24f33f37, type: 3} m_Name: MicrosoftMotionControllerProfile Standalone m_EditorClassIdentifier: - m_enabled: 0 + m_enabled: 1 nameUi: Microsoft Motion Controller Profile version: 0.0.1 featureIdInternal: com.unity.openxr.feature.input.microsoftmotioncontroller @@ -195,7 +195,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f928d0d73a35f294fbe357ca17aa3547, type: 3} m_Name: MicrosoftHandInteraction Standalone m_EditorClassIdentifier: - m_enabled: 0 + m_enabled: 1 nameUi: Microsoft Hand Interaction Profile version: 0.0.1 featureIdInternal: com.unity.openxr.feature.input.handtracking diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index d5ba9bb..6f26795 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -16,11 +16,11 @@ PlayerSettings: productName: MaiDXR defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} - m_SplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1} + m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} m_ShowUnitySplashScreen: 1 m_ShowUnitySplashLogo: 1 m_SplashScreenOverlayOpacity: 1 - m_SplashScreenAnimation: 0 + m_SplashScreenAnimation: 1 m_SplashScreenLogoStyle: 1 m_SplashScreenDrawMode: 0 m_SplashScreenBackgroundAnimationZoom: 1 @@ -74,7 +74,7 @@ PlayerSettings: androidMinimumWindowWidth: 400 androidMinimumWindowHeight: 300 androidFullscreenMode: 1 - defaultIsNativeResolution: 0 + defaultIsNativeResolution: 1 macRetinaSupport: 1 runInBackground: 1 captureSingleScreen: 0 @@ -87,7 +87,7 @@ PlayerSettings: usePlayerLog: 1 bakeCollisionMeshes: 1 forceSingleInstance: 1 - useFlipModelSwapchain: 0 + useFlipModelSwapchain: 1 resizableWindow: 1 useMacAppStoreValidation: 0 macAppStoreCategory: public.app-category.games @@ -113,7 +113,7 @@ PlayerSettings: xboxOneDisableEsram: 0 xboxOneEnableTypeOptimization: 0 xboxOnePresentImmediateThreshold: 0 - switchQueueCommandMemory: 0 + switchQueueCommandMemory: 1048576 switchQueueControlMemory: 16384 switchQueueComputeMemory: 262144 switchNVNShaderPoolsGranularity: 33554432 @@ -134,56 +134,9 @@ PlayerSettings: 16:10: 1 16:9: 1 Others: 1 - bundleVersion: 0.7.1 + bundleVersion: 0.7.2 preloadedAssets: - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} - - {fileID: 0} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 @@ -210,7 +163,7 @@ PlayerSettings: AndroidBundleVersionCode: 1 AndroidMinSdkVersion: 19 AndroidTargetSdkVersion: 0 - AndroidPreferredInstallLocation: 0 + AndroidPreferredInstallLocation: 1 aotOptions: stripEngineCode: 1 iPhoneStrippingLevel: 0 @@ -220,7 +173,7 @@ PlayerSettings: CreateWallpaper: 0 APKExpansionFiles: 0 keepLoadedShadersAlive: 0 - StripUnusedMeshComponents: 1 + StripUnusedMeshComponents: 0 VertexChannelCompressionMask: 4054 iPhoneSdkVersion: 988 iOSTargetOSVersionString: 11.0 @@ -316,82 +269,11 @@ PlayerSettings: AndroidAppBundleSizeToValidate: 150 m_BuildTargetIcons: [] m_BuildTargetPlatformIcons: [] - m_BuildTargetBatching: - - m_BuildTarget: Standalone - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: tvOS - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: Android - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: iPhone - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: WebGL - m_StaticBatching: 0 - m_DynamicBatching: 0 - m_BuildTargetGraphicsJobs: - - m_BuildTarget: MacStandaloneSupport - m_GraphicsJobs: 0 - - m_BuildTarget: Switch - m_GraphicsJobs: 1 - - m_BuildTarget: MetroSupport - m_GraphicsJobs: 1 - - m_BuildTarget: AppleTVSupport - m_GraphicsJobs: 0 - - m_BuildTarget: BJMSupport - m_GraphicsJobs: 1 - - m_BuildTarget: LinuxStandaloneSupport - m_GraphicsJobs: 1 - - m_BuildTarget: PS4Player - m_GraphicsJobs: 1 - - m_BuildTarget: iOSSupport - m_GraphicsJobs: 0 - - m_BuildTarget: WindowsStandaloneSupport - m_GraphicsJobs: 1 - - m_BuildTarget: XboxOnePlayer - m_GraphicsJobs: 1 - - m_BuildTarget: LuminSupport - m_GraphicsJobs: 0 - - m_BuildTarget: AndroidPlayer - m_GraphicsJobs: 0 - - m_BuildTarget: WebGLSupport - m_GraphicsJobs: 0 - m_BuildTargetGraphicsJobMode: - - m_BuildTarget: PS4Player - m_GraphicsJobMode: 0 - - m_BuildTarget: XboxOnePlayer - m_GraphicsJobMode: 0 - m_BuildTargetGraphicsAPIs: - - m_BuildTarget: AndroidPlayer - m_APIs: 150000000b000000 - m_Automatic: 0 - - m_BuildTarget: iOSSupport - m_APIs: 10000000 - m_Automatic: 1 - - m_BuildTarget: AppleTVSupport - m_APIs: 10000000 - m_Automatic: 1 - - m_BuildTarget: WebGLSupport - m_APIs: 0b000000 - m_Automatic: 1 - - m_BuildTarget: MacStandaloneSupport - m_APIs: 10000000 - m_Automatic: 1 - - m_BuildTarget: LinuxStandaloneSupport - m_APIs: 1100000015000000 - m_Automatic: 1 - - m_BuildTarget: WindowsStandaloneSupport - m_APIs: 0200000015000000 - m_Automatic: 1 - m_BuildTargetVRSettings: - - m_BuildTarget: Standalone - m_Enabled: 0 - m_Devices: - - Oculus - - OpenVR + m_BuildTargetBatching: [] + m_BuildTargetGraphicsJobs: [] + m_BuildTargetGraphicsJobMode: [] + m_BuildTargetGraphicsAPIs: [] + m_BuildTargetVRSettings: [] openGLRequireES31: 0 openGLRequireES31AEP: 0 openGLRequireES32: 0 @@ -400,13 +282,8 @@ PlayerSettings: Android: 1 iPhone: 1 tvOS: 1 - m_BuildTargetGroupLightmapEncodingQuality: - - m_BuildTarget: Standalone - m_EncodingQuality: 1 - m_BuildTargetGroupLightmapSettings: - - m_BuildTarget: Standalone - m_TextureStreamingEnabled: 0 - m_TextureStreamingPriority: 0 + m_BuildTargetGroupLightmapEncodingQuality: [] + m_BuildTargetGroupLightmapSettings: [] m_BuildTargetNormalMapEncoding: [] playModeTestRunnerEnabled: 0 runPlayModeTestAsEditModeTest: 0 @@ -590,7 +467,7 @@ PlayerSettings: ps4RemotePlayKeyAssignment: -1 ps4RemotePlayKeyMappingDir: ps4PlayTogetherPlayerCount: 0 - ps4EnterButtonAssignment: 1 + ps4EnterButtonAssignment: 2 ps4ApplicationParam1: 0 ps4ApplicationParam2: 0 ps4ApplicationParam3: 0 @@ -613,7 +490,7 @@ PlayerSettings: ps4UseAudio3dBackend: 0 ps4UseLowGarlicFragmentationMode: 1 ps4SocialScreenEnabled: 0 - ps4ScriptOptimizationLevel: 0 + ps4ScriptOptimizationLevel: 2 ps4Audio3dVirtualSpeakerCount: 14 ps4attribCpuUsage: 0 ps4PatchPkgPath: @@ -639,7 +516,7 @@ PlayerSettings: splashScreenBackgroundSourcePortrait: {fileID: 0} blurSplashScreenBackground: 1 spritePackerPolicy: - webGLMemorySize: 16 + webGLMemorySize: 32 webGLExceptionSupport: 1 webGLNameFilesAsHashes: 0 webGLDataCaching: 1 @@ -649,7 +526,7 @@ PlayerSettings: webGLTemplate: APPLICATION:Default webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 - webGLCompressionFormat: 1 + webGLCompressionFormat: 0 webGLWasmArithmeticExceptions: 0 webGLLinkerTarget: 1 webGLThreadsSupport: 0 @@ -657,8 +534,7 @@ PlayerSettings: scriptingDefineSymbols: {} additionalCompilerArguments: {} platformArchitecture: {} - scriptingBackend: - Standalone: 0 + scriptingBackend: {} il2cppCompilerConfiguration: {} managedStrippingLevel: {} incrementalIl2cppBuild: {} @@ -669,21 +545,21 @@ PlayerSettings: enableRoslynAnalyzers: 1 additionalIl2CppArgs: scriptingRuntimeVersion: 1 - gcIncremental: 0 + gcIncremental: 1 assemblyVersionValidation: 1 gcWBarrierValidation: 0 apiCompatibilityLevelPerPlatform: Standalone: 3 m_RenderingPath: 1 m_MobileRenderingPath: 1 - metroPackageName: Template_3D + metroPackageName: MaiDXR metroPackageVersion: metroCertificatePath: metroCertificatePassword: metroCertificateSubject: metroCertificateIssuer: metroCertificateNotAfter: 0000000000000000 - metroApplicationDescription: Template_3D + metroApplicationDescription: MaiDXR wsaImages: {} metroTileShortName: metroTileShowName: 0 @@ -730,8 +606,7 @@ PlayerSettings: XboxOneOverrideIdentityName: XboxOneOverrideIdentityPublisher: vrEditorSettings: {} - cloudServicesEnabled: - UNet: 1 + cloudServicesEnabled: {} luminIcon: m_Name: m_ModelFolderPath: