diff --git a/plug-ins/Apple.Core/Apple.Core_Unity/ProjectSettings/ProjectVersion.txt b/plug-ins/Apple.Core/Apple.Core_Unity/ProjectSettings/ProjectVersion.txt
index 21588a1a..c47c8be7 100644
--- a/plug-ins/Apple.Core/Apple.Core_Unity/ProjectSettings/ProjectVersion.txt
+++ b/plug-ins/Apple.Core/Apple.Core_Unity/ProjectSettings/ProjectVersion.txt
@@ -1,2 +1,2 @@
-m_EditorVersion: 2022.3.18f1
-m_EditorVersionWithRevision: 2022.3.18f1 (d29bea25151d)
+m_EditorVersion: 2022.3.22f1
+m_EditorVersionWithRevision: 2022.3.22f1 (887be4894c44)
diff --git a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/CHANGELOG.md b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/CHANGELOG.md
index c56ea573..844939e5 100644
--- a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/CHANGELOG.md
+++ b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/CHANGELOG.md
@@ -1,6 +1,9 @@
# CHANGELOG
All notable changes to this project will be documented in this file.
+## [2.2.1] - 2023-04-01
+- Fix some issues with how view controllers are handled on visionOS.
+
## [2.2.0] - 2023-02-23
### Added
- Support for visionOS
diff --git a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Demos/Apple.GameKit.Sample/Scripts/AccessPointPanel.cs b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Demos/Apple.GameKit.Sample/Scripts/AccessPointPanel.cs
index 22b9764a..1a9b5928 100644
--- a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Demos/Apple.GameKit.Sample/Scripts/AccessPointPanel.cs
+++ b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Demos/Apple.GameKit.Sample/Scripts/AccessPointPanel.cs
@@ -10,14 +10,6 @@ public class AccessPointPanel : MonoBehaviour
{
[SerializeField] Dropdown _stateDropdown = default;
- // Start is called before the first frame update
- void Start()
- {
- GKAccessPoint.Shared.Location = GKAccessPoint.GKAccessPointLocation.TopLeading;
- GKAccessPoint.Shared.ShowHighlights = false;
- GKAccessPoint.Shared.IsActive = true;
- }
-
public void OnToggleAccessPoint()
{
GKAccessPoint.Shared.IsActive = !GKAccessPoint.Shared.IsActive;
diff --git a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatch.cs b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatch.cs
index 0c50a317..089c39b4 100644
--- a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatch.cs
+++ b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatch.cs
@@ -64,13 +64,13 @@ protected override void OnDispose(bool isDisposing)
///
/// The local player's properties that matchmaking rules used to find the players with some additions.
///
- [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2")]
+ [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2", visionOS: "1.1")]
public GKMatchProperties Properties => PointerCast(Interop.GKMatch_GetProperties(Pointer));
///
/// The properties for other players that matchmaking rules uses to find players, with some additions.
///
- [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2")]
+ [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2", visionOS: "1.1")]
public NSDictionary PlayerProperties => PointerCast>(Interop.GKMatch_GetPlayerProperties(Pointer));
///
diff --git a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchRequest.cs b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchRequest.cs
index 1d4644b5..f1fae06e 100644
--- a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchRequest.cs
+++ b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchRequest.cs
@@ -134,7 +134,7 @@ public NSArray Recipients
///
/// The name of the queue that Game Center places the match request in.
///
- [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2")]
+ [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2", visionOS: "1.1")]
public string QueueName
{
get => Interop.GKMatchRequest_GetQueueName(Pointer);
@@ -144,7 +144,7 @@ public string QueueName
///
/// The criteria for the local player that Game Center uses to find other players when using matchmaking rules.
///
- [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2")]
+ [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2", visionOS: "1.1")]
public GKMatchProperties Properties
{
get => PointerCast(Interop.GKMatchRequest_GetProperties(Pointer));
@@ -154,7 +154,7 @@ public GKMatchProperties Properties
///
/// The criteria for recipients of the match request that Game Center uses to find other players when using matchmaking rules.
///
- [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2")]
+ [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2", visionOS: "1.1")]
public NSDictionary RecipientProperties
{
get => PointerCast>(Interop.GKMatchRequest_GetRecipientProperties(Pointer));
diff --git a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchedPlayers.cs b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchedPlayers.cs
index ca4ff4c6..189eabc2 100644
--- a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchedPlayers.cs
+++ b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchedPlayers.cs
@@ -10,7 +10,7 @@ namespace Apple.GameKit.Multiplayer
///
/// An object that represents matchmaking results, including the players that join the match and their properties that matchmaking rules uses.
///
- [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2")]
+ [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2", visionOS: "1.1")]
public class GKMatchedPlayers : NSObject
{
///
diff --git a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchmaker.cs b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchmaker.cs
index 0c653433..a584cfac 100644
--- a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchmaker.cs
+++ b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchmaker.cs
@@ -131,7 +131,7 @@ private static void OnFindPlayersError(long taskId, IntPtr errorPointer)
///
/// The configuration for the match.
/// The players that join the match, including their properties that matchmaking rules uses. If unsuccessful, this parameter is null.
- [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2")]
+ [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2", visionOS: "1.1")]
public Task FindMatchedPlayers(GKMatchRequest matchRequest)
{
var tcs = InteropTasks.Create(out var taskId);
@@ -216,7 +216,7 @@ private static void OnQueryActivityError(long taskId, IntPtr errorPointer)
/// The string should be in reverse-DNS format and queue names are case sensitive.
///
/// The number of match requests in the queue during the previous 60 seconds.
- [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2")]
+ [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2", visionOS: "1.1")]
public Task QueryQueueActivity(string queueName)
{
var tcs = InteropTasks.Create(out var taskId);
@@ -387,8 +387,10 @@ private static class Interop
public static extern void GKMatchmaker_StartBrowsingForNearbyPlayers(IntPtr gkMatchmakerPtr, InternalNearbyPlayerReachableHandler nearbyPlayerReachableHandler);
[DllImport(InteropUtility.DLLName)]
public static extern void GKMatchmaker_StopBrowsingForNearbyPlayers(IntPtr gkMatchmakerPtr);
+#if !UNITY_TVOS
[DllImport(InteropUtility.DLLName)]
public static extern void GKMatchmaker_StartGroupActivity(IntPtr gkMatchmakerPtr, InternalPlayerJoiningGroupActivityHandler playerJoiningGroupActivityHandler);
+#endif
[DllImport(InteropUtility.DLLName)]
public static extern void GKMatchmaker_StopGroupActivity(IntPtr gkMatchmakerPtr);
}
diff --git a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchmakerViewControllerDelegate.cs b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchmakerViewControllerDelegate.cs
index 2c2c13e4..c68e6106 100644
--- a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchmakerViewControllerDelegate.cs
+++ b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Multiplayer/GKMatchmakerViewControllerDelegate.cs
@@ -147,14 +147,14 @@ private static void OnHostedPlayerDidAccept(IntPtr pointer, IntPtr matchmakerVie
/// The view controller that finds players for the match.
/// A player to invite to the match.
/// The properties for recipient that the local player invites to the match.
- [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2")]
+ [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2", visionOS: "1.1")]
public delegate Task GetMatchPropertiesForRecipientHandler(GKMatchmakerViewController matchmakerViewController, GKPlayer invitedPlayer);
private delegate void InteropGetMatchPropertiesForRecipientHandler(IntPtr gkMatchmakerViewControllerDelegatePtr, IntPtr gkMatchmakerViewControllerPtr, IntPtr gkPlayerPtr, IntPtr completionHandlerPtr);
///
/// Dispatches GetMatchPropertiesForRecipient events.
///
- [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2")]
+ [Introduced(iOS: "17.2", macOS: "14.2", tvOS: "17.2", visionOS: "1.1")]
public event GetMatchPropertiesForRecipientHandler GetMatchPropertiesForRecipient;
[MonoPInvokeCallback(typeof(InteropGetMatchPropertiesForRecipientHandler))]
diff --git a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/ProjectSettings/ProjectVersion.txt b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/ProjectSettings/ProjectVersion.txt
index 21588a1a..c47c8be7 100644
--- a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/ProjectSettings/ProjectVersion.txt
+++ b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/ProjectSettings/ProjectVersion.txt
@@ -1,2 +1,2 @@
-m_EditorVersion: 2022.3.18f1
-m_EditorVersionWithRevision: 2022.3.18f1 (d29bea25151d)
+m_EditorVersion: 2022.3.22f1
+m_EditorVersionWithRevision: 2022.3.22f1 (887be4894c44)
diff --git a/plug-ins/Apple.GameKit/Native/GameKitWrapper.xcodeproj/project.pbxproj b/plug-ins/Apple.GameKit/Native/GameKitWrapper.xcodeproj/project.pbxproj
index 092838c2..15b7258b 100644
--- a/plug-ins/Apple.GameKit/Native/GameKitWrapper.xcodeproj/project.pbxproj
+++ b/plug-ins/Apple.GameKit/Native/GameKitWrapper.xcodeproj/project.pbxproj
@@ -163,6 +163,10 @@
FB8694492AD73AE5009B8676 /* GKMatchedPlayers.m in Sources */ = {isa = PBXBuildFile; fileRef = FB8694482AD73AE5009B8676 /* GKMatchedPlayers.m */; };
FB86944A2AD73AE5009B8676 /* GKMatchedPlayers.m in Sources */ = {isa = PBXBuildFile; fileRef = FB8694482AD73AE5009B8676 /* GKMatchedPlayers.m */; };
FB86944B2AD73AE5009B8676 /* GKMatchedPlayers.m in Sources */ = {isa = PBXBuildFile; fileRef = FB8694482AD73AE5009B8676 /* GKMatchedPlayers.m */; };
+ FB89C4EB2BAE49320078B971 /* UiUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB89C4EA2BAE49320078B971 /* UiUtilities.swift */; };
+ FB89C4EC2BAE4BA20078B971 /* UiUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB89C4EA2BAE49320078B971 /* UiUtilities.swift */; };
+ FB89C4ED2BAE4BA30078B971 /* UiUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB89C4EA2BAE49320078B971 /* UiUtilities.swift */; };
+ FB89C4EE2BAE4BA40078B971 /* UiUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB89C4EA2BAE49320078B971 /* UiUtilities.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -213,6 +217,7 @@
7AE5BBA22502C0DD00BDBEDA /* GameKitWrapper.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GameKitWrapper.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FB7384C92ADE05A200616362 /* GKErrorCodeExtension.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GKErrorCodeExtension.h; sourceTree = ""; };
FB8694482AD73AE5009B8676 /* GKMatchedPlayers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GKMatchedPlayers.m; sourceTree = ""; };
+ FB89C4EA2BAE49320078B971 /* UiUtilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UiUtilities.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -271,6 +276,7 @@
7A9B815524A4FC3800FB2FE8 /* GameKitWrapper */ = {
isa = PBXGroup;
children = (
+ FB89C4EA2BAE49320078B971 /* UiUtilities.swift */,
7A7D6B7F25D6E7650072DB37 /* AccessPoint_BridgingHeader.h */,
7A4ADFE924DDF23400664BD3 /* AccessPoint.swift */,
7A486BA926A09D7A00255BD5 /* AppleCoreRuntimeShared.h */,
@@ -552,6 +558,7 @@
24B0647A2B7F29E1007ABBB8 /* GKAchievement.swift in Sources */,
24B0647B2B7F29E1007ABBB8 /* GKVoiceChat.swift in Sources */,
24B0647C2B7F29E1007ABBB8 /* GKTurnBasedMatchDelegate.swift in Sources */,
+ FB89C4ED2BAE4BA30078B971 /* UiUtilities.swift in Sources */,
24B0647D2B7F29E1007ABBB8 /* GKTurnBasedMatch.swift in Sources */,
24B0647E2B7F29E1007ABBB8 /* GKMatchmakerViewController.swift in Sources */,
24B0647F2B7F29E1007ABBB8 /* GameKitUIDelegateHandler.swift in Sources */,
@@ -594,6 +601,7 @@
7AA8AD5E2729EF5500D3F909 /* GKAchievement.swift in Sources */,
7A7E43A124B509130086FB7A /* GameKitUIDelegateHandler.swift in Sources */,
7AA8AD9F272A46AF00D3F909 /* GKVoiceChat.swift in Sources */,
+ FB89C4EE2BAE4BA40078B971 /* UiUtilities.swift in Sources */,
7AA8ADB3272B02AF00D3F909 /* GKTurnBasedMatchDelegate.swift in Sources */,
7AA8ADAE272AF7A000D3F909 /* GKTurnBasedMatch.swift in Sources */,
7AA8AD90272A3EE600D3F909 /* GKMatchmakerViewController.swift in Sources */,
@@ -636,6 +644,7 @@
7AA8AD5C2729EF5500D3F909 /* GKAchievement.swift in Sources */,
7AA8AD9D272A46AF00D3F909 /* GKVoiceChat.swift in Sources */,
7AA8ADB1272B02AF00D3F909 /* GKTurnBasedMatchDelegate.swift in Sources */,
+ FB89C4EB2BAE49320078B971 /* UiUtilities.swift in Sources */,
7AA8ADAC272AF7A000D3F909 /* GKTurnBasedMatch.swift in Sources */,
7AA8AD8E272A3EE600D3F909 /* GKMatchmakerViewController.swift in Sources */,
7A50579324ABD01000477507 /* GameKitUIDelegateHandler.swift in Sources */,
@@ -678,6 +687,7 @@
7AA8AD5D2729EF5500D3F909 /* GKAchievement.swift in Sources */,
7AA8AD9E272A46AF00D3F909 /* GKVoiceChat.swift in Sources */,
7AA8ADB2272B02AF00D3F909 /* GKTurnBasedMatchDelegate.swift in Sources */,
+ FB89C4EC2BAE4BA20078B971 /* UiUtilities.swift in Sources */,
7AA8ADAD272AF7A000D3F909 /* GKTurnBasedMatch.swift in Sources */,
7AA8AD8F272A3EE600D3F909 /* GKMatchmakerViewController.swift in Sources */,
7AE5BB9C2502C0DD00BDBEDA /* GameKitUIDelegateHandler.swift in Sources */,
diff --git a/plug-ins/Apple.GameKit/Native/GameKitWrapper/AccessPoint.swift b/plug-ins/Apple.GameKit/Native/GameKitWrapper/AccessPoint.swift
index ca9b12a9..3b4963a8 100644
--- a/plug-ins/Apple.GameKit/Native/GameKitWrapper/AccessPoint.swift
+++ b/plug-ins/Apple.GameKit/Native/GameKitWrapper/AccessPoint.swift
@@ -139,6 +139,11 @@ public func GKAccessPoint_SetIsActive
)
{
let target = Unmanaged.fromOpaque(pointer).takeUnretainedValue();
+
+ if value {
+ target.parentWindow = UiUtilities.defaultWindow()
+ }
+
target.isActive = value;
}
diff --git a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKGameCenterViewController.swift b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKGameCenterViewController.swift
index 43979a41..0d0bd42a 100644
--- a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKGameCenterViewController.swift
+++ b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKGameCenterViewController.swift
@@ -62,13 +62,8 @@ public func GKGameCenterViewController_Present
let target = Unmanaged.fromOpaque(pointer).takeUnretainedValue();
_currentPresentingGameCenterDelegate = GameKitUIDelegateHandler(taskId: taskId, onSuccess: onSuccess);
target.gameCenterDelegate = _currentPresentingGameCenterDelegate;
-
- // TODO: (123075676)
-#if os(iOS) || os(tvOS)
- let viewController = UIApplication.shared.windows.first!.rootViewController;
- viewController?.present(target, animated: true);
-#elseif os(macOS)
- GKDialogController.shared().parentWindow = NSApplication.shared.keyWindow;
- GKDialogController.shared().present(target);
-#endif
+
+ if let defaultWindow = UiUtilities.defaultWindow() {
+ UiUtilities.presentViewController(viewController: target)
+ }
}
diff --git a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKLocalPlayer.swift b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKLocalPlayer.swift
index f007df02..edc8f727 100644
--- a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKLocalPlayer.swift
+++ b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKLocalPlayer.swift
@@ -20,28 +20,20 @@ public func GKLocalPlayer_Authenticate
onSuccess(taskId, GKLocalPlayer_GetLocal());
return;
}
-
+
GKLocalPlayer.local.authenticateHandler = { gcAuthVC, error in
- if (error != nil) {
- onError(taskId, Unmanaged.passRetained(error! as NSError).toOpaque());
- return;
- }
- // TODO: (123075676)
-#if !os(visionOS)
// Always show the viewController if provided...
- if gcAuthVC != nil {
- #if os(iOS) || os(tvOS)
- let viewController = UIApplication.shared.windows.first!.rootViewController;
- viewController?.present(gcAuthVC!, animated: true)
- #else
- let viewController = NSApplication.shared.keyWindow?.contentViewController;
- viewController?.presentAsModalWindow(gcAuthVC!)
- #endif
- } else {
- GKLocalPlayer.local.register(_localPlayerListener);
- onSuccess(taskId, GKLocalPlayer_GetLocal());
+ if let gcAuthVC = gcAuthVC {
+ UiUtilities.presentViewController(viewController: gcAuthVC);
+ }
+
+ if let error = error {
+ onError(taskId, Unmanaged.passRetained(error as NSError).toOpaque());
+ return;
}
-#endif
+
+ GKLocalPlayer.local.register(_localPlayerListener);
+ onSuccess(taskId, GKLocalPlayer_GetLocal());
};
}
diff --git a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatch.swift b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatch.swift
index da9ded6e..3bb5c102 100644
--- a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatch.swift
+++ b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatch.swift
@@ -51,7 +51,7 @@ public func GKMatch_GetPlayerProperties
gkMatchPtr: UnsafeMutableRawPointer
) -> UnsafeMutableRawPointer?
{
- if #available(iOS 17.2, tvOS 17.2, macOS 14.2, visionOS 1.0, *) {
+ if #available(iOS 17.2, tvOS 17.2, macOS 14.2, visionOS 1.1, *) {
let gkMatch = Unmanaged.fromOpaque(gkMatchPtr).takeUnretainedValue()
if let dictionary = gkMatch.playerProperties as NSDictionary? {
return Unmanaged.passRetained(dictionary).toOpaque();
diff --git a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchRequest.swift b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchRequest.swift
index 9e09afff..f8e1ee0b 100644
--- a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchRequest.swift
+++ b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchRequest.swift
@@ -195,9 +195,7 @@ public func GKMatchRequest_SetProperties
nsDictionaryPtr: UnsafeMutableRawPointer?
)
{
- // TODO: (123075676)
-#if !os(visionOS)
- if #available(iOS 17.2, tvOS 17.2, macOS 14.2, *) {
+ if #available(iOS 17.2, tvOS 17.2, macOS 14.2, visionOS 1.1, *) {
let gkMatchRequest = Unmanaged.fromOpaque(gkMatchRequestPtr).takeUnretainedValue();
if let nonNullDictionaryPtr = nsDictionaryPtr {
let nsDictionary = Unmanaged.fromOpaque(nonNullDictionaryPtr).takeUnretainedValue();
@@ -206,7 +204,6 @@ public func GKMatchRequest_SetProperties
gkMatchRequest.properties = nil;
}
}
-#endif
}
@_cdecl("GKMatchRequest_GetRecipientProperties")
diff --git a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchmaker.swift b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchmaker.swift
index 16f707cc..ffbab598 100644
--- a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchmaker.swift
+++ b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchmaker.swift
@@ -128,7 +128,7 @@ public func GKMatchMaker_FindMatchedPlayers
onError: @escaping NSErrorCallback
)
{
- if #available(iOS 17.2, tvOS 17.2, macOS 14.2, visionOS 1.1, *) {
+ if #available(iOS 17.2, tvOS 17.2, macOS 14.2, visionOS 1.1, *) {
let gkMatchMaker = Unmanaged.fromOpaque(gkMatchmakerPtr).takeUnretainedValue()
let gkMatchRequest = Unmanaged.fromOpaque(gkMatchRequestPtr).takeUnretainedValue()
diff --git a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchmakerViewController.swift b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchmakerViewController.swift
index 9f0dbd33..d7821d96 100644
--- a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchmakerViewController.swift
+++ b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKMatchmakerViewController.swift
@@ -131,15 +131,7 @@ public func GKMatchmakerViewController_Present
)
{
let target = Unmanaged.fromOpaque(pointer).takeUnretainedValue();
-
- // TODO: (123075676)
-#if os(iOS) || os(tvOS)
- let viewController = UIApplication.shared.windows.first!.rootViewController;
- viewController?.present(target, animated: true);
-#elseif os(macOS)
- GKDialogController.shared().parentWindow = NSApplication.shared.keyWindow;
- GKDialogController.shared().present(target);
-#endif
+ UiUtilities.presentViewController(viewController: target)
}
public func GKMatchmakerViewController_Dismiss
@@ -147,13 +139,7 @@ public func GKMatchmakerViewController_Dismiss
viewController: GKMatchmakerViewController
)
{
- // TODO: (123075676)
- #if os(iOS) || os(tvOS)
- viewController.dismiss(animated: true);
- #elseif os(macOS)
- GKDialogController.shared().dismiss(viewController);
- #endif
-
+ UiUtilities.dismissViewController(viewController: viewController)
_activeRealtimeMatchmakerDelegate = nil;
}
diff --git a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKTurnBasedMatchmakerViewController.swift b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKTurnBasedMatchmakerViewController.swift
index 386d7bcd..25e2bc7b 100644
--- a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKTurnBasedMatchmakerViewController.swift
+++ b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GKTurnBasedMatchmakerViewController.swift
@@ -99,15 +99,7 @@ public func GKTurnBasedMatchmakerViewController_Present
{
let target = Unmanaged.fromOpaque(pointer).takeUnretainedValue();
_presentingTurnBasedMatchmakerViewController = target;
-
- // TODO: (123075676)
-#if os(iOS) || os(tvOS)
- let viewController = UIApplication.shared.windows.first!.rootViewController;
- viewController?.present(target, animated: true);
-#elseif os(macOS)
- GKDialogController.shared().parentWindow = NSApplication.shared.keyWindow;
- GKDialogController.shared().present(target);
-#endif
+ UiUtilities.presentViewController(viewController: target)
}
@_cdecl("GKTurnBasedMatchmakerViewController_Dismiss")
@@ -116,13 +108,7 @@ public func GKTurnBasedMatchmakerViewController_Dismiss
viewController: GKTurnBasedMatchmakerViewController
)
{
- // TODO: (123075676)
- #if os(iOS) || os(tvOS)
- viewController.dismiss(animated: true);
- #elseif os(macOS)
- GKDialogController.shared().dismiss(viewController);
- #endif
-
+ UiUtilities.dismissViewController(viewController: viewController)
_presentingTurnBasedMatchmakerViewController = nil;
_activeTurnBasedMatchmakerDelegate = nil;
}
diff --git a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GameKitUIDelegateHandler.swift b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GameKitUIDelegateHandler.swift
index 59e7ae6c..cd6c85e0 100644
--- a/plug-ins/Apple.GameKit/Native/GameKitWrapper/GameKitUIDelegateHandler.swift
+++ b/plug-ins/Apple.GameKit/Native/GameKitWrapper/GameKitUIDelegateHandler.swift
@@ -20,14 +20,13 @@ public class GameKitUIDelegateHandler : NSObject {
extension GameKitUIDelegateHandler : GKGameCenterControllerDelegate {
public func gameCenterViewControllerDidFinish(_ gameCenterViewController: GKGameCenterViewController) {
- // TODO: (123075676)
- #if os(iOS) || os(tvOS)
- gameCenterViewController.dismiss(animated: true, completion: {
- self._onSuccess?(self._taskId!);
- });
- #elseif os(macOS)
- GKDialogController.shared().dismiss(gameCenterViewController);
+#if os(macOS)
+ GKDialogController.shared().dismiss(gameCenterViewController);
+ self._onSuccess?(self._taskId!);
+#else
+ gameCenterViewController.dismiss(animated: true, completion: {
self._onSuccess?(self._taskId!);
- #endif
+ });
+#endif
}
}
diff --git a/plug-ins/Apple.GameKit/Native/GameKitWrapper/UiUtilities.swift b/plug-ins/Apple.GameKit/Native/GameKitWrapper/UiUtilities.swift
new file mode 100644
index 00000000..56e9863c
--- /dev/null
+++ b/plug-ins/Apple.GameKit/Native/GameKitWrapper/UiUtilities.swift
@@ -0,0 +1,60 @@
+//
+// UiUtilities.swift
+// AppleCoreNative
+//
+
+import Foundation
+import GameKit
+import SwiftUI
+
+class UiUtilities {
+#if os(macOS)
+ static func defaultWindow() -> NSWindow? {
+ return NSApplication.shared.keyWindow;
+ }
+
+ static func rootViewController() -> NSViewController? {
+ return defaultWindow()?.contentViewController;
+ }
+
+ static func presentViewController(viewController: NSViewController) {
+ rootViewController()?.presentAsModalWindow(viewController);
+ }
+
+ static func presentViewController(viewController: any NSViewController & GKViewController) {
+ GKDialogController.shared().parentWindow = defaultWindow();
+ GKDialogController.shared().present(viewController);
+ }
+
+ static func dismissViewController(viewController: any NSViewController & GKViewController) {
+ GKDialogController.shared().dismiss(viewController);
+ }
+
+#else
+ static func defaultWindow() -> UIWindow? {
+ guard let windowScene = UIApplication.shared.connectedScenes.first(where: { scene in
+ return scene is UIWindowScene;
+ }) as? UIWindowScene else {
+ return nil;
+ }
+ if let window = windowScene.windows.first(where: { window in
+ return window.rootViewController != nil;
+ }) {
+ return window;
+ }
+ return nil;
+ }
+
+ static func rootViewController() -> UIViewController? {
+ return defaultWindow()?.rootViewController;
+ }
+
+ static func presentViewController(viewController: UIViewController) {
+ rootViewController()?.present(viewController, animated: true);
+ }
+
+ static func dismissViewController(viewController: UINavigationController) {
+ viewController.dismiss(animated: true);
+ }
+#endif
+}