diff --git a/Packages/src/Runtime/Internal/Extensions/ComponentExtensions.cs b/Packages/src/Runtime/Internal/Extensions/ComponentExtensions.cs index b13d8b4..b5fae9e 100644 --- a/Packages/src/Runtime/Internal/Extensions/ComponentExtensions.cs +++ b/Packages/src/Runtime/Internal/Extensions/ComponentExtensions.cs @@ -12,6 +12,33 @@ namespace Coffee.UIEffectInternal /// internal static class ComponentExtensions { +#if !UNITY_2019_2_OR_NEWER + public static bool TryGetComponent(this GameObject self, out T component) + where T : Component + { + if (self == null) + { + component = null; + return false; + } + + component = self.GetComponent(); + return component != null; + } + + public static bool TryGetComponent(this Component self, out T component) + where T : Component + { + if (self == null) + { + component = null; + return false; + } + + return self.gameObject.TryGetComponent(out component); + } +#endif + /// /// Get components in children of a specific type in the hierarchy of a GameObject. /// diff --git a/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs b/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs index 835cb57..fac51f6 100644 --- a/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs +++ b/Packages/src/Runtime/Internal/ProjectSettings/PreloadedProjectSettings.cs @@ -23,17 +23,14 @@ namespace Coffee.UIEffectInternal protected static bool s_BuildingPlayer; - private class Postprocessor : AssetPostprocessor + private class EditorEvents : AssetPostprocessor, IPreprocessBuildWithReport, IPostprocessBuildWithReport { + int IOrderedCallback.callbackOrder => 0; + private static void OnPostprocessAllAssets(string[] _, string[] __, string[] ___, string[] ____) { Initialize(); } - } - - private class ExcludeFromBuild : IPreprocessBuildWithReport, IPostprocessBuildWithReport - { - int IOrderedCallback.callbackOrder => 0; void IPreprocessBuildWithReport.OnPreprocessBuild(BuildReport report) { @@ -240,7 +237,7 @@ namespace Coffee.UIEffectInternal } } #else - public static T instance => s_Instance != null ? s_Instance : s_Instance = CreateInstance(); + public static T instance => s_Instance != null ? s_Instance : s_Instance = CreateInstance(); #endif /// @@ -256,6 +253,7 @@ namespace Coffee.UIEffectInternal return; } + EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; EditorApplication.playModeStateChanged += OnPlayModeStateChanged; #else if (s_Instance && s_Instance != this) diff --git a/Packages/src/Runtime/Internal/Utilities/FastAction.cs b/Packages/src/Runtime/Internal/Utilities/FastAction.cs index 798f33f..907c7fb 100755 --- a/Packages/src/Runtime/Internal/Utilities/FastAction.cs +++ b/Packages/src/Runtime/Internal/Utilities/FastAction.cs @@ -66,11 +66,6 @@ namespace Coffee.UIEffectInternal node = node.Next; } } - - public void Clear() - { - _delegates.Clear(); - } } /// diff --git a/Packages/src/Runtime/Internal/Utilities/Misc.cs b/Packages/src/Runtime/Internal/Utilities/Misc.cs index 543a9e5..4c24df1 100644 --- a/Packages/src/Runtime/Internal/Utilities/Misc.cs +++ b/Packages/src/Runtime/Internal/Utilities/Misc.cs @@ -48,15 +48,10 @@ namespace Coffee.UIEffectInternal { if (obj == null) return; #if UNITY_EDITOR - if (Application.isEditor) - { - Object.DestroyImmediate(obj); - } - else + Object.DestroyImmediate(obj, true); +#else + Object.Destroy(obj); #endif - { - Object.Destroy(obj); - } } [Conditional("UNITY_EDITOR")] @@ -114,7 +109,7 @@ namespace Coffee.UIEffectInternal { if (Misc.isBatchOrBuilding) return; - var types = TypeCache.GetTypesWithAttribute(); + var types = TypeCache.GetTypesWithAttribute(typeof(IconAttribute)); var scripts = MonoImporter.GetAllRuntimeMonoScripts(); foreach (var type in types) { diff --git a/Packages/src/Runtime/Internal/Utilities/UIExtraCallbacks.cs b/Packages/src/Runtime/Internal/Utilities/UIExtraCallbacks.cs index 0dd9ac6..70ba7df 100755 --- a/Packages/src/Runtime/Internal/Utilities/UIExtraCallbacks.cs +++ b/Packages/src/Runtime/Internal/Utilities/UIExtraCallbacks.cs @@ -90,6 +90,7 @@ namespace Coffee.UIEffectInternal { Canvas.willRenderCanvases -= OnAfterCanvasRebuild; s_IsInitializedAfterCanvasRebuild = false; + s_LastScreenSize = default; } ///