Skip to content

Commit 7b225d0

Browse files
authored
feat: Xbox Native Support (#2314)
1 parent 2cbcce9 commit 7b225d0

File tree

9 files changed

+55
-11
lines changed

9 files changed

+55
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
## Unreleased
44

5-
### Fixes
5+
### Features
6+
7+
- Added Xbox Native Support ([#2314](https://github.com/getsentry/sentry-unity/pull/2314))
8+
9+
### Fixes
610

711
- Fixed input handling in samples to work with old and new input system ([#2319](https://github.com/getsentry/sentry-unity/pull/2319))
812

package-dev/Runtime/SentryInitialization.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#define SENTRY_NATIVE_ANDROID
66
#elif UNITY_64 && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX)
77
#define SENTRY_NATIVE
8+
#elif UNITY_GAMECORE
9+
#define SENTRY_NATIVE
810
#elif UNITY_WEBGL
911
#define SENTRY_WEBGL
1012
#endif

src/Sentry.Unity.Editor/ConfigurationWindow/AdvancedTab.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ internal static void Display(ScriptableSentryUnityOptions options, SentryCliOpti
9191
EditorGUI.indentLevel++;
9292
if (UnfoldNativeOptions)
9393
{
94+
GUILayout.Label("Desktop", EditorStyles.boldLabel);
95+
9496
options.WindowsNativeSupportEnabled = EditorGUILayout.Toggle(
9597
new GUIContent("Windows", "Whether to enable native crashes support on Windows."),
9698
options.WindowsNativeSupportEnabled);
@@ -103,6 +105,8 @@ internal static void Display(ScriptableSentryUnityOptions options, SentryCliOpti
103105
new GUIContent("Linux", "Whether to enable native crashes support on Linux."),
104106
options.LinuxNativeSupportEnabled);
105107

108+
GUILayout.Label("Mobile", EditorStyles.boldLabel);
109+
106110
options.IosNativeSupportEnabled = EditorGUILayout.Toggle(
107111
new GUIContent("iOS", "Whether to enable Native iOS support to capture" +
108112
"errors written in languages such as Objective-C, Swift, C and C++."),
@@ -133,6 +137,12 @@ internal static void Display(ScriptableSentryUnityOptions options, SentryCliOpti
133137
EditorGUI.EndDisabledGroup();
134138
EditorGUI.EndDisabledGroup();
135139
EditorGUI.indentLevel--;
140+
141+
GUILayout.Label("Console", EditorStyles.boldLabel);
142+
143+
options.XboxNativeSupportEnabled = EditorGUILayout.Toggle(
144+
new GUIContent("Xbox", "Whether to enable native crashes support on Xbox."),
145+
options.XboxNativeSupportEnabled);
136146
}
137147

138148
EditorGUI.indentLevel--;

src/Sentry.Unity.Editor/Native/BuildPostProcess.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static class BuildPostProcess
1818
public static void OnPostProcessBuild(BuildTarget target, string executablePath)
1919
{
2020
var targetGroup = BuildPipeline.GetBuildTargetGroup(target);
21-
if (targetGroup is not BuildTargetGroup.Standalone)
21+
if (targetGroup is not BuildTargetGroup.Standalone and not BuildTargetGroup.GameCoreXboxSeries)
2222
{
2323
return;
2424
}
@@ -77,6 +77,7 @@ public static void OnPostProcessBuild(BuildTarget target, string executablePath)
7777
BuildTarget.StandaloneWindows64 => options.WindowsNativeSupportEnabled,
7878
BuildTarget.StandaloneOSX => options.MacosNativeSupportEnabled,
7979
BuildTarget.StandaloneLinux64 => options.LinuxNativeSupportEnabled,
80+
BuildTarget.GameCoreXboxSeries or BuildTarget.GameCoreXboxOne => options.XboxNativeSupportEnabled,
8081
_ => false,
8182
};
8283

@@ -94,6 +95,10 @@ private static void AddCrashHandler(IDiagnosticLogger logger, BuildTarget target
9495
case BuildTarget.StandaloneOSX:
9596
// No standalone crash handler for Linux/macOS - uses built-in handlers.
9697
return;
98+
case BuildTarget.GameCoreXboxSeries:
99+
case BuildTarget.GameCoreXboxOne:
100+
// TODO: Figure out if we need to ship with a crash handler
101+
return;
97102
default:
98103
throw new ArgumentException($"Unsupported build target: {target}");
99104
}

src/Sentry.Unity/Il2CppEventProcessor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,9 @@ is RuntimePlatform.Android
361361
or RuntimePlatform.LinuxPlayer
362362
or RuntimePlatform.LinuxServer
363363
or RuntimePlatform.WindowsPlayer
364-
or RuntimePlatform.WindowsServer;
364+
or RuntimePlatform.WindowsServer
365+
or RuntimePlatform.GameCoreXboxSeries
366+
or RuntimePlatform.GameCoreXboxOne;
365367
}
366368

367369
private string GetPlatformDebugImageType(RuntimePlatform? platform = null)
@@ -379,6 +381,8 @@ private string GetPlatformDebugImageType(RuntimePlatform? platform = null)
379381
return "macho";
380382
case RuntimePlatform.WindowsPlayer:
381383
case RuntimePlatform.WindowsServer:
384+
case RuntimePlatform.GameCoreXboxSeries:
385+
case RuntimePlatform.GameCoreXboxOne:
382386
return "pe";
383387
default:
384388
return "unknown";

src/Sentry.Unity/Integrations/UnityScopeIntegration.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Sentry.Reflection;
44
using Sentry.Integrations;
55
using Sentry.Unity.Integrations;
6+
using UnityEngine;
67
using OperatingSystem = Sentry.Protocol.OperatingSystem;
78

89
namespace Sentry.Unity;
@@ -78,9 +79,18 @@ private void PopulateApp(App app)
7879
app.BuildType = isDebugBuild is null ? null : (isDebugBuild.Value ? "debug" : "release");
7980
}
8081

81-
private void PopulateOperatingSystem(OperatingSystem operatingSystem)
82+
private void PopulateOperatingSystem(OperatingSystem operatingSystemContext)
8283
{
83-
operatingSystem.RawDescription = MainThreadData.OperatingSystem;
84+
if (ApplicationAdapter.Instance.Platform
85+
is RuntimePlatform.GameCoreXboxSeries
86+
or RuntimePlatform.GameCoreXboxOne)
87+
{
88+
operatingSystemContext.Name = "Xbox";
89+
}
90+
else
91+
{
92+
operatingSystemContext.RawDescription = MainThreadData.OperatingSystem;
93+
}
8494
}
8595

8696
private void PopulateDevice(Device device)

src/Sentry.Unity/ScriptableSentryUnityOptions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static string GetConfigPath(string? notDefaultConfigName = null)
103103
[field: SerializeField] public bool WindowsNativeSupportEnabled { get; set; } = true;
104104
[field: SerializeField] public bool MacosNativeSupportEnabled { get; set; } = true;
105105
[field: SerializeField] public bool LinuxNativeSupportEnabled { get; set; } = true;
106-
106+
[field: SerializeField] public bool XboxNativeSupportEnabled { get; set; } = true;
107107
[field: SerializeField] public bool Il2CppLineNumberSupportEnabled { get; set; } = true;
108108

109109
[field: SerializeField] public SentryRuntimeOptionsConfiguration? RuntimeOptionsConfiguration { get; set; }
@@ -185,6 +185,7 @@ internal SentryUnityOptions ToSentryUnityOptions(
185185
WindowsNativeSupportEnabled = WindowsNativeSupportEnabled,
186186
MacosNativeSupportEnabled = MacosNativeSupportEnabled,
187187
LinuxNativeSupportEnabled = LinuxNativeSupportEnabled,
188+
XboxNativeSupportEnabled = XboxNativeSupportEnabled,
188189
Il2CppLineNumberSupportEnabled = Il2CppLineNumberSupportEnabled,
189190
PerformanceAutoInstrumentationEnabled = AutoAwakeTraces,
190191
};

src/Sentry.Unity/SentryUnityOptions.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ public sealed class SentryUnityOptions : SentryOptions
209209
/// </summary>
210210
public bool LinuxNativeSupportEnabled { get; set; } = true;
211211

212+
/// <summary>
213+
/// Whether the SDK should add native support for Xbox
214+
/// </summary>
215+
public bool XboxNativeSupportEnabled { get; set; } = true;
216+
212217
/// <summary>
213218
/// Whether the SDK should add IL2CPP line number support
214219
/// </summary>
@@ -393,16 +398,18 @@ internal static bool IsKnownPlatform(RuntimePlatform? platform = null)
393398
return platform
394399
is RuntimePlatform.Android
395400
or RuntimePlatform.IPhonePlayer
396-
or RuntimePlatform.WindowsEditor
397-
or RuntimePlatform.WindowsPlayer
398401
or RuntimePlatform.OSXEditor
399402
or RuntimePlatform.OSXPlayer
403+
or RuntimePlatform.OSXServer
404+
or RuntimePlatform.WindowsEditor
405+
or RuntimePlatform.WindowsPlayer
406+
or RuntimePlatform.WindowsServer
400407
or RuntimePlatform.LinuxEditor
401408
or RuntimePlatform.LinuxPlayer
409+
or RuntimePlatform.LinuxServer
402410
or RuntimePlatform.WebGLPlayer
403-
or RuntimePlatform.WindowsServer
404-
or RuntimePlatform.OSXServer
405-
or RuntimePlatform.LinuxServer;
411+
or RuntimePlatform.GameCoreXboxSeries
412+
or RuntimePlatform.GameCoreXboxOne;
406413
}
407414

408415
public override string ToString()

src/Sentry.Unity/SentryUnityOptionsExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ internal static bool IsNativeSupportEnabled(this SentryUnityOptions options, Run
5858
RuntimePlatform.WindowsPlayer or RuntimePlatform.WindowsServer => options.WindowsNativeSupportEnabled,
5959
RuntimePlatform.OSXPlayer or RuntimePlatform.OSXServer => options.MacosNativeSupportEnabled,
6060
RuntimePlatform.LinuxPlayer or RuntimePlatform.LinuxServer => options.LinuxNativeSupportEnabled,
61+
RuntimePlatform.GameCoreXboxSeries or RuntimePlatform.GameCoreXboxOne => options.XboxNativeSupportEnabled,
6162
_ => false
6263
};
6364
}

0 commit comments

Comments
 (0)