diff --git a/Assets/Plugins/Android/AndroidManifest.xml b/Assets/Plugins/Android/AndroidManifest.xml index 624c177d..232ed581 100644 --- a/Assets/Plugins/Android/AndroidManifest.xml +++ b/Assets/Plugins/Android/AndroidManifest.xml @@ -7,6 +7,11 @@ + + + + + diff --git a/Assets/Resources/银河守护者-扬州邗江区探索中心外带.xlsm.meta b/Assets/Resources/银河守护者-扬州邗江区探索中心外带.xlsm.meta index 40d3782f..4acbd878 100644 --- a/Assets/Resources/银河守护者-扬州邗江区探索中心外带.xlsm.meta +++ b/Assets/Resources/银河守护者-扬州邗江区探索中心外带.xlsm.meta @@ -1,6 +1,11 @@ fileFormatVersion: 2 +<<<<<<<< HEAD:Assets/Unity.VisualScripting.Generated/VisualScripting.Core/link.xml.meta +guid: 8877eee7fdd9bdc40a1eee419cdea92b +TextScriptImporter: +======== guid: 981b7aa1cb4befb4b8cb3d93a59c3d96 DefaultImporter: +>>>>>>>> origin/main_ZYT:Assets/Resources/银河守护者-扬州邗江区探索中心外带.xlsm.meta externalObjects: {} userData: assetBundleName: diff --git a/Assets/Scripts/BuildPostProcessor.cs b/Assets/Scripts/BuildPostProcessor.cs new file mode 100644 index 00000000..3d52deac --- /dev/null +++ b/Assets/Scripts/BuildPostProcessor.cs @@ -0,0 +1,40 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEditor.Build; +using UnityEditor.Build.Reporting; +using UnityEngine; +using System.IO; +using System.Text.RegularExpressions; + +public class BuildPostProcessor : IPreprocessBuildWithReport +{ + public int callbackOrder => 0; + + public void OnPreprocessBuild(BuildReport report) + { + if (report.summary.platform == BuildTarget.Android) + { + UpdateAndroidManifest(); + } + } + + private void UpdateAndroidManifest() + { + string manifestPath = Path.Combine(Application.dataPath, "Plugins/Android/AndroidManifest.xml"); + + if (File.Exists(manifestPath)) + { + string manifestContent = File.ReadAllText(manifestPath); + string packageName = PlayerSettings.applicationIdentifier; + + // 使用正则表达式匹配并替换 android:path 的值 + string updatedContent = Regex.Replace(manifestContent, + @"android:path=""[^""]*""", + $"android:path=\"/{packageName}\""); + + File.WriteAllText(manifestPath, updatedContent); + Debug.Log($"Updated AndroidManifest.xml with package name: {packageName}"); + } + } +} +#endif diff --git a/Assets/Scripts/BuildPostProcessor.cs.meta b/Assets/Scripts/BuildPostProcessor.cs.meta new file mode 100644 index 00000000..fcd98d6c --- /dev/null +++ b/Assets/Scripts/BuildPostProcessor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b48ecd91b34b7a845a9caf521919ffad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/MRInput.cs b/Assets/Scripts/MRInput.cs index c2e3ddbe..b3707974 100644 --- a/Assets/Scripts/MRInput.cs +++ b/Assets/Scripts/MRInput.cs @@ -35,7 +35,7 @@ public class MRInput : MonoBehaviour #if !UNITY_EDITOR && UNITY_ANDROID && (PICO || VIVE) PXR_Input.SendHapticImpulse(VibrateType.RightController, amplitude, duration, frequency); - TrueGearEffectManager.Ins.OnHit(true,4,true); + //TrueGearEffectManager.Ins.OnHit(true,4,true); #endif } diff --git a/Assets/Scripts/Manager/GameManager.cs b/Assets/Scripts/Manager/GameManager.cs index 757051cf..c642e2d0 100644 --- a/Assets/Scripts/Manager/GameManager.cs +++ b/Assets/Scripts/Manager/GameManager.cs @@ -155,9 +155,10 @@ public class GameManager : MonoBehaviour #if !UNITY_EDITOR PXR_Enterprise.InitEnterpriseService(); PXR_Enterprise.BindEnterpriseService(); - TrueGearEffectManager.Ins.StartRequestTrueGear(); + TrueGearEffectManager.Ins.StartRequestTrueGear(); #endif CoroutineTaskManager.Instance.WaitSecondTodo(ShowPlayerUI, 1.5f); + } /// diff --git a/Assets/Scripts/Manager/TrueGearEffectManager.cs b/Assets/Scripts/Manager/TrueGearEffectManager.cs index 1aaf34f1..dda3321d 100644 --- a/Assets/Scripts/Manager/TrueGearEffectManager.cs +++ b/Assets/Scripts/Manager/TrueGearEffectManager.cs @@ -18,7 +18,7 @@ public class TrueGearEffectManager : MonoBehaviour GetConnectIndex = 20; AddHitPart(); #if !UNITY_EDITOR - TrueGearEffectManager.Ins.StartRequestTrueGear(); + //TrueGearEffectManager.Ins.StartRequestTrueGear(); #endif } @@ -111,17 +111,27 @@ public class TrueGearEffectManager : MonoBehaviour if (!res) return; - List res1 = androidConnector.GetScanedDevices(); - Debug.Log(res1.ToString()); - foreach (var item in res1) + List devices = androidConnector.GetScanedDevices(); + if (devices == null || devices.Count == 0) { + Debug.Log("未扫描到任何设备"); + return; + } + + foreach (var device in devices) + { + bool connected = androidConnector.ConnectToDevice(device.address); + if (connected) { - androidConnector.ConnectToDevice(item.address); - Debug.Log(string.Format("Device Connect: {0}, {1}", item.name, item.address)); + Debug.Log($"成功连接设备: {device.name} - {device.address}"); isGetConnect = true; ChangeElectricalLevel(); return; } + else + { + Debug.LogWarning($"设备被占用或连接失败: {device.name} - {device.address}"); + } } Debug.Log("No device found"); } @@ -197,7 +207,7 @@ public class TrueGearEffectManager : MonoBehaviour }} ] }}"; - + SendPlayEffectByContent(json); } @@ -208,8 +218,34 @@ public class TrueGearEffectManager : MonoBehaviour Debug.Log("OnTestClick" + res); if (!res) return; - androidConnector.SendPlayEffectByContent(jsonStr); + try + { + androidConnector.SendPlayEffectByContent(jsonStr); + } + catch (Exception ex) + { + Debug.LogError("调用 TrueGear 崩溃保护: " + ex); + ReconnectTrueGear(); + } + } + + // 当检测蓝牙断开或异常时调用 + void ReconnectTrueGear() + { + try + { + var conn = TruegearAndroidConnector.Instance; + conn.InitShellJavaObject(); + conn.RequestPermission(); + conn.StartScan(); + } + catch (Exception e) + { + Debug.LogError("重新初始化 TrueGear 失败:" + e); + } + } + public List hitParts=new List(); public void AddHitPart() @@ -222,7 +258,28 @@ public class TrueGearEffectManager : MonoBehaviour } public void OnHit(bool isUp, int index,bool isArm) { - //ChangeElectricalLevel(); + TruegearAndroidConnector androidConnector = TruegearAndroidConnector.Instance; + if (androidConnector == null) + { + Debug.LogWarning("TrueGear connector 为空,跳过调用"); + isGetConnect = false; + return; + } + + if (!androidConnector.IsAvailable()) + { + Debug.LogWarning("TrueGear 蓝牙不可用或断开,跳过调用"); + isGetConnect = false; + return; + } + + if (!isGetConnect) + { + androidConnector.InitShellJavaObject(); + androidConnector.RequestPermission(); + StartCoroutine(TrueGearAndroidConnector()); + return; + } List motorIDs = new List(); string hitPart= hitParts[index]; switch (hitPart) @@ -241,6 +298,7 @@ public class TrueGearEffectManager : MonoBehaviour default: motorIDs.Add(0); break; } + PlayVibrationEffect( effectName: $"Hit_{hitPart}", motorIndex: motorIDs, diff --git a/Assets/StreamingAssets/build_info b/Assets/StreamingAssets/build_info index ffdcc747..2cd5e348 100644 --- a/Assets/StreamingAssets/build_info +++ b/Assets/StreamingAssets/build_info @@ -1 +1 @@ -Build from ZTT at 2025/10/21 10:47:07 \ No newline at end of file +Build from CHINAMI-UKDLSK3 at 2025/10/17 19:33:53 \ No newline at end of file diff --git a/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Room A.mat b/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Room A.mat index 2f5f2333..a5e76430 100644 --- a/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Room A.mat +++ b/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Room A.mat @@ -115,7 +115,7 @@ Material: - _BaseColor: {r: 0.9921568, g: 0.93333334, b: 0.24705878, a: 0.47058824} - _BaseColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0} - _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0} - - _Color: {r: 0.9921568, g: 0.93333334, b: 0.24705875, a: 0.47058824} + - _Color: {r: 0.9921568, g: 0.93333334, b: 0.24705878, a: 0.47058824} - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} - _GlowColor: {r: 1, g: 1, b: 0, a: 1} - _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0} diff --git a/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Room C.mat b/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Room C.mat index f486dd99..54adce21 100644 --- a/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Room C.mat +++ b/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Room C.mat @@ -114,7 +114,7 @@ Material: - _BaseColor: {r: 0.99215686, g: 0.93333334, b: 0.24705882, a: 0.47058824} - _BaseColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0} - _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0} - - _Color: {r: 0.9921568, g: 0.93333334, b: 0.24705878, a: 0.47058824} + - _Color: {r: 0.99215686, g: 0.93333334, b: 0.24705882, a: 0.47058824} - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} - _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0} - _TintColor: {r: 1, g: 0.7922921, b: 0.5294118, a: 0.5} diff --git a/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Your Message.mat b/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Your Message.mat index 014590b9..2c75191e 100644 --- a/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Your Message.mat +++ b/Assets/sucai/_Creepy_Cat/_ShowRoom_Vol 3/_Textures/Your Message.mat @@ -114,7 +114,7 @@ Material: - _BaseColor: {r: 0.99215686, g: 0.93333334, b: 0.24705882, a: 0.47058824} - _BaseColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0} - _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0} - - _Color: {r: 0.9921568, g: 0.93333334, b: 0.24705878, a: 0.47058824} + - _Color: {r: 0.99215686, g: 0.93333334, b: 0.24705882, a: 0.47058824} - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} - _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0} - _TintColor: {r: 1, g: 0.7922921, b: 0.5294118, a: 0.5} diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index c69a9519..b7aec058 100644 --- a/ProjectSettings/GraphicsSettings.asset +++ b/ProjectSettings/GraphicsSettings.asset @@ -108,7 +108,7 @@ GraphicsSettings: m_FogKeepExp: 1 m_FogKeepExp2: 1 m_AlbedoSwatchInfos: [] - m_LightsUseLinearIntensity: 1 + m_LightsUseLinearIntensity: 0 m_LightsUseColorTemperature: 1 m_DefaultRenderingLayerMask: 1 m_LogWhenShaderIsCompiled: 0