diff --git a/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Runtime/InteropTypeNameAttribute.cs b/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Runtime/InteropTypeNameAttribute.cs new file mode 100644 index 00000000..3c61caae --- /dev/null +++ b/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Runtime/InteropTypeNameAttribute.cs @@ -0,0 +1,19 @@ +using System; + +namespace Apple.Core +{ + /// + /// Attribute for manually specifying a class's corresponding Objective-C type name. This is required for classes + /// that do not share their C# type name with their Objective-C counterpart, such as nested classes. + /// + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] + public class InteropTypeNameAttribute : Attribute + { + public string TypeName { get; private set; } + + public InteropTypeNameAttribute(string customTypeName) + { + TypeName = customTypeName; + } + } +} diff --git a/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Runtime/InteropTypeNameAttribute.cs.meta b/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Runtime/InteropTypeNameAttribute.cs.meta new file mode 100644 index 00000000..218967ff --- /dev/null +++ b/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Runtime/InteropTypeNameAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6c3c61f3764d4688a279325a72606e82 +timeCreated: 1775773530 \ No newline at end of file diff --git a/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Runtime/NSObject.cs b/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Runtime/NSObject.cs index 5b833e15..82e12f8b 100644 --- a/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Runtime/NSObject.cs +++ b/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Runtime/NSObject.cs @@ -38,8 +38,7 @@ protected static string GetInteropTypeName(Type type) var typeName = type.Name; // Special case for types that provide a custom interop type name. - if (type.GetProperty("InteropTypeName", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) - ?.GetValue(null) is string customTypeName) + if(type.GetCustomAttribute()?.TypeName is string customTypeName) { typeName = customTypeName; } diff --git a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Leaderboards/GKLeaderboard.cs b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Leaderboards/GKLeaderboard.cs index b5fe5b77..24a5afcd 100644 --- a/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Leaderboards/GKLeaderboard.cs +++ b/plug-ins/Apple.GameKit/Apple.GameKit_Unity/Assets/Apple.GameKit/Source/Leaderboards/GKLeaderboard.cs @@ -58,14 +58,12 @@ public enum TimeScope : long /// /// Information about a single score by a player on a leaderboard. /// + [InteropTypeName("GKLeaderboardEntry")] [Introduced(iOS: "14.0", macOS: "11.0", tvOS: "14.0", visionOS: "1.0")] public class Entry : NSObject { internal Entry(IntPtr pointer) : base(pointer) {} - // This allows interop to work with the Objective-C type which has a different name: GKLeaderboardEntry. - internal static string InteropTypeName => "GKLeaderboardEntry"; - /// /// An integer value that your game uses. ///