diff --git a/package-dev/Runtime/SentryInitialization.cs b/package-dev/Runtime/SentryInitialization.cs index f3ee41ff4..f4e9aaa0a 100644 --- a/package-dev/Runtime/SentryInitialization.cs +++ b/package-dev/Runtime/SentryInitialization.cs @@ -9,6 +9,8 @@ #define SENTRY_NATIVE #elif UNITY_PS5 #define SENTRY_NATIVE +#elif UNITY_SWITCH +#define SENTRY_NATIVE #elif UNITY_WEBGL #define SENTRY_WEBGL #endif diff --git a/src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs b/src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs index 081dc3d5c..b4f24f13e 100644 --- a/src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs +++ b/src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs @@ -147,6 +147,10 @@ internal static void Display(ScriptableSentryUnityOptions options, SentryCliOpti options.PlayStationNativeSupportEnabled = EditorGUILayout.Toggle( new GUIContent("PlayStation", "Whether to enable native crash support on PlayStation."), options.PlayStationNativeSupportEnabled); + + options.SwitchNativeSupportEnabled = EditorGUILayout.Toggle( + new GUIContent("Nintendo Switch", "Whether to enable native crash support on Nintendo Switch."), + options.SwitchNativeSupportEnabled); } EditorGUI.indentLevel--; diff --git a/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs b/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs index eaabfb48d..e47710831 100644 --- a/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs +++ b/src/Sentry.Unity.Editor/Native/BuildPostProcess.cs @@ -19,7 +19,8 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath) var targetGroup = BuildPipeline.GetBuildTargetGroup(target); if (targetGroup is not BuildTargetGroup.Standalone and not BuildTargetGroup.GameCoreXboxSeries - and not BuildTargetGroup.PS5) + and not BuildTargetGroup.PS5 + and not BuildTargetGroup.Switch) { return; } @@ -54,6 +55,7 @@ and not BuildTargetGroup.GameCoreXboxSeries BuildTargetGroup.Standalone => Path.GetDirectoryName(executablePath), BuildTargetGroup.GameCoreXboxSeries => executablePath, BuildTargetGroup.PS5 => executablePath, + BuildTargetGroup.Switch => executablePath, _ => string.Empty }; @@ -91,6 +93,7 @@ and not BuildTargetGroup.GameCoreXboxSeries BuildTarget.StandaloneLinux64 => options.LinuxNativeSupportEnabled, BuildTarget.GameCoreXboxSeries or BuildTarget.GameCoreXboxOne => options.XboxNativeSupportEnabled, BuildTarget.PS5 => options.PlayStationNativeSupportEnabled, + BuildTarget.Switch => options.SwitchNativeSupportEnabled, _ => false, }; @@ -115,6 +118,9 @@ private static void AddCrashHandler(IDiagnosticLogger logger, BuildTarget target case BuildTarget.PS5: // No standalone crash handler for PlayStation return; + case BuildTarget.Switch: + // No standalone crash handler for Nintendo Switch + return; default: throw new ArgumentException($"Unsupported build target: {target}"); } @@ -186,6 +192,13 @@ private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget tar paths += $" \"{macOSSentryDsym}\""; } break; + case BuildTarget.Switch: + var switchSentryPluginPath = Path.GetFullPath("Assets/Plugins/Sentry/"); + if (Directory.Exists(switchSentryPluginPath)) + { + paths += $" \"{switchSentryPluginPath}\""; + } + break; default: logger.LogError($"Symbol upload for '{target}' is currently not supported."); return; diff --git a/src/Sentry.Unity.Native/SentryNativeBridge.cs b/src/Sentry.Unity.Native/SentryNativeBridge.cs index b73ec7203..47a0914dc 100644 --- a/src/Sentry.Unity.Native/SentryNativeBridge.cs +++ b/src/Sentry.Unity.Native/SentryNativeBridge.cs @@ -18,7 +18,8 @@ public static bool Init(SentryUnityOptions options) { _useLibC = Application.platform is RuntimePlatform.LinuxPlayer or RuntimePlatform.LinuxServer - or RuntimePlatform.PS5; + or RuntimePlatform.PS5 + or RuntimePlatform.Switch; _isWindows = Application.platform is RuntimePlatform.WindowsPlayer or RuntimePlatform.WindowsServer; var cOptions = sentry_options_new(); @@ -62,7 +63,7 @@ is RuntimePlatform.LinuxPlayer or RuntimePlatform.LinuxServer if (_isWindows) { options.DiagnosticLogger?.LogDebug("Setting CacheDirectoryPath on Windows: {0}", dir); - sentry_options_set_database_pathw(cOptions, dir); + // sentry_options_set_database_pathw(cOptions, dir); } else { diff --git a/src/Sentry.Unity/ScriptableSentryUnityOptions.cs b/src/Sentry.Unity/ScriptableSentryUnityOptions.cs index a7f7e6012..d13bf7ed1 100644 --- a/src/Sentry.Unity/ScriptableSentryUnityOptions.cs +++ b/src/Sentry.Unity/ScriptableSentryUnityOptions.cs @@ -112,6 +112,7 @@ public static string GetConfigPath(string? notDefaultConfigName = null) [field: SerializeField] public bool LinuxNativeSupportEnabled { get; set; } = true; [field: SerializeField] public bool XboxNativeSupportEnabled { get; set; } = true; [field: SerializeField] public bool PlayStationNativeSupportEnabled { get; set; } = true; + [field: SerializeField] public bool SwitchNativeSupportEnabled { get; set; } = true; [field: SerializeField] public bool Il2CppLineNumberSupportEnabled { get; set; } = true; [field: SerializeField] public SentryOptionsConfiguration? OptionsConfiguration { get; set; } @@ -193,6 +194,7 @@ internal SentryUnityOptions ToSentryUnityOptions( LinuxNativeSupportEnabled = LinuxNativeSupportEnabled, XboxNativeSupportEnabled = XboxNativeSupportEnabled, PlayStationNativeSupportEnabled = PlayStationNativeSupportEnabled, + SwitchNativeSupportEnabled = SwitchNativeSupportEnabled, Il2CppLineNumberSupportEnabled = Il2CppLineNumberSupportEnabled, PerformanceAutoInstrumentationEnabled = AutoAwakeTraces, EnableLogs = EnableStructuredLogging, diff --git a/src/Sentry.Unity/SentryUnityOptions.cs b/src/Sentry.Unity/SentryUnityOptions.cs index 155fd3716..a9da34e40 100644 --- a/src/Sentry.Unity/SentryUnityOptions.cs +++ b/src/Sentry.Unity/SentryUnityOptions.cs @@ -237,6 +237,11 @@ public sealed class SentryUnityOptions : SentryOptions /// public bool PlayStationNativeSupportEnabled { get; set; } = true; + /// + /// Whether the SDK should add native support for Nintendo Switch + /// + public bool SwitchNativeSupportEnabled { get; set; } = true; + /// /// Whether the SDK should add IL2CPP line number support /// @@ -502,7 +507,8 @@ or RuntimePlatform.LinuxServer or RuntimePlatform.WebGLPlayer or RuntimePlatform.GameCoreXboxSeries or RuntimePlatform.GameCoreXboxOne - or RuntimePlatform.PS5; + or RuntimePlatform.PS5 + or RuntimePlatform.Switch; } public override string ToString() diff --git a/src/Sentry.Unity/SentryUnityOptionsExtensions.cs b/src/Sentry.Unity/SentryUnityOptionsExtensions.cs index 48e75ef31..bb3df576d 100644 --- a/src/Sentry.Unity/SentryUnityOptionsExtensions.cs +++ b/src/Sentry.Unity/SentryUnityOptionsExtensions.cs @@ -60,6 +60,7 @@ internal static bool IsNativeSupportEnabled(this SentryUnityOptions options, Run RuntimePlatform.LinuxPlayer or RuntimePlatform.LinuxServer => options.LinuxNativeSupportEnabled, RuntimePlatform.GameCoreXboxSeries or RuntimePlatform.GameCoreXboxOne => options.XboxNativeSupportEnabled, RuntimePlatform.PS5 => options.PlayStationNativeSupportEnabled, + RuntimePlatform.Switch => options.SwitchNativeSupportEnabled, _ => false }; }