diff --git a/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Editor/ApplePlugInEnvironment.cs b/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Editor/ApplePlugInEnvironment.cs index cefc0659..de1feb3d 100644 --- a/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Editor/ApplePlugInEnvironment.cs +++ b/plug-ins/Apple.Core/Apple.Core_Unity/Assets/Apple.Core/Editor/ApplePlugInEnvironment.cs @@ -38,6 +38,7 @@ static ApplePlatformID() } } + [InitializeOnLoad] public class ApplePlugInEnvironment : AssetPostprocessor { /// @@ -105,6 +106,7 @@ public class ApplePlugInEnvironment : AssetPostprocessor /// private enum UpdateState { + NotInitialized, Initializing, Updating } @@ -126,13 +128,25 @@ private enum UpdateState /// State tracking for select platform /// private static string _trackedApplePlatform; + + /// + /// Initialize C# objects. Do not create or load assets here. + /// + static ApplePlugInEnvironment() + { + // Initialize collection of packages + _appleUnityPackages = new Dictionary(); + _packageManagerListRequest = Client.List(); + + _updateState = UpdateState.NotInitialized; + } /// /// Initialize the ApplePlugInEnvironment after all assets finished processing, so we can alter our own. /// private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload) { - if (_updateState != UpdateState.Initializing) { return; } + if (_updateState != UpdateState.NotInitialized) { return; } // Ensure that the necessary Apple Unity Plug-In support folders exist and let user know if any have been created. string createFolderMessage = "[Apple Unity Plug-ins] Creating support folders:\n"; @@ -167,10 +181,6 @@ private static void OnPostprocessAllAssets(string[] importedAssets, string[] del _defaultProfile = AppleBuildProfile.DefaultProfile(); _defaultProfile.ResolveBuildSteps(); - // Initialize collection of packages - _appleUnityPackages = new Dictionary(); - _packageManagerListRequest = Client.List(); - // Initialize state tracking _updateState = UpdateState.Initializing; _trackedAppleConfig = GetAppleBuildConfig();