@@ -29,13 +29,14 @@ namespace PlayEveryWare.EpicOnlineServices
2929
3030#if UNITY_EDITOR
3131 using UnityEditor ;
32+ using PlayEveryWare . Common . Utility ;
3233#endif
3334
3435#if ! EXTERNAL_TO_UNITY
3536 using UnityEngine ;
3637#endif
3738 using Utility ;
38-
39+
3940 public static partial class PlatformManager
4041 {
4142 /// <summary>
@@ -87,26 +88,14 @@ public static PlatformInfo Create<T>(string fullName, string configFileName, str
8788 }
8889 }
8990
90- #if ! INCLUDE_RESTRICTED_PLATFORMS
9191 /// <summary>
9292 /// Private collection to store information about each platform.
9393 /// </summary>
94- private static readonly IDictionary < Platform , PlatformInfo > PlatformInformation =
95- new Dictionary < Platform , PlatformInfo > ( )
96- {
97- #if ! EXTERNAL_TO_UNITY
98- { Platform . Android , PlatformInfo . Create < AndroidConfig > ( "Android" , "eos_android_config.json" , null , "Android" ) } ,
99- { Platform . iOS , PlatformInfo . Create < IOSConfig > ( "iOS" , "eos_ios_config.json" , null , "iPhone" ) } ,
100- { Platform . Linux , PlatformInfo . Create < LinuxConfig > ( "Linux" , "eos_linux_config.json" , ".so" , "Standalone" ) } ,
101- { Platform . macOS , PlatformInfo . Create < MacOSConfig > ( "macOS" , "eos_macos_config.json" , ".dylib" , "Standalone" ) } ,
102- #endif
103- { Platform . Windows , PlatformInfo . Create < WindowsConfig > ( "Windows" , "eos_windows_config.json" , ".dll" , "Standalone" ) } ,
104- } ;
105- #endif
94+ private static IDictionary < Platform , PlatformInfo > PlatformInformation = new Dictionary < Platform , PlatformInfo > ( ) ;
10695
107- /// <summary>
108- /// Backing value for the CurrentPlatform property.
109- /// </summary>
96+ /// <summary>
97+ /// Backing value for the CurrentPlatform property.
98+ /// </summary>
11099 private static Platform s_CurrentPlatform ;
111100
112101 /// <summary>
@@ -139,8 +128,41 @@ public static Platform CurrentPlatform
139128 }
140129 }
141130
131+ /// <summary>
132+ /// To be accessible to the platform manager, the static constructors
133+ /// for each platform config need to be executed, this function ensures
134+ /// that happens.
135+ /// </summary>
136+ private static void InitializePlatformConfigs ( )
137+ {
138+ // This compile conditional is here because in the editor, it is
139+ // acceptable to use reflection to make sure all the
140+ // PlatformConfigs have their static constructors executed.
141+ #if UNITY_EDITOR
142+ ReflectionUtility . CallStaticConstructorsOnDerivingClasses < PlatformConfig > ( ) ;
143+ #endif
144+
145+ #if ! EXTERNAL_TO_UNITY
146+ PlatformInformation . Add ( Platform . Android , PlatformInfo . Create < AndroidConfig > ( "Android" , "eos_android_config.json" , null , "Android" ) ) ;
147+ PlatformInformation . Add ( Platform . iOS , PlatformInfo . Create < IOSConfig > ( "iOS" , "eos_ios_config.json" , null , "iPhone" ) ) ;
148+ PlatformInformation . Add ( Platform . Linux , PlatformInfo . Create < LinuxConfig > ( "Linux" , "eos_linux_config.json" , ".so" , "Standalone" ) ) ;
149+ PlatformInformation . Add ( Platform . macOS , PlatformInfo . Create < MacOSConfig > ( "macOS" , "eos_macos_config.json" , ".dylib" , "Standalone" ) ) ;
150+ #endif
151+ PlatformInformation . Add ( Platform . Windows , PlatformInfo . Create < WindowsConfig > ( "Windows" , "eos_windows_config.json" , ".dll" , "Standalone" ) ) ;
152+ }
153+
154+ /// <summary>
155+ /// This partial method is defined here so that a partial class
156+ /// definition can provide implementation that initializes other
157+ /// platform configs.
158+ /// </summary>
159+ static partial void InitializeProprietaryPlatformConfigs ( ) ;
160+
142161 static PlatformManager ( )
143162 {
163+ InitializePlatformConfigs ( ) ;
164+ InitializeProprietaryPlatformConfigs ( ) ;
165+
144166 // If external to unity, then we know that the current platform
145167 // is Windows.
146168#if EXTERNAL_TO_UNITY
0 commit comments