瀏覽代碼

[unity] Fixed exception when new Unity 2019.3 `Enter Play Mode` has disabled domain reload. Closes #1621.

Harald Csaszar 5 年之前
父節點
當前提交
84443288b5
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs

+ 14 - 0
spine-unity/Assets/Spine/Runtime/spine-unity/Utility/AtlasUtilities.cs

@@ -27,10 +27,16 @@
  * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *****************************************************************************/
  *****************************************************************************/
 
 
+#if UNITY_2019_3_OR_NEWER
+#define CONFIGURABLE_ENTER_PLAY_MODE
+#endif
+
+
 using UnityEngine;
 using UnityEngine;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System;
 using System;
 
 
+
 namespace Spine.Unity.AttachmentTools {
 namespace Spine.Unity.AttachmentTools {
 
 
 	public static class AtlasUtilities {
 	public static class AtlasUtilities {
@@ -41,6 +47,14 @@ namespace Spine.Unity.AttachmentTools {
 
 
 		const int NonrenderingRegion = -1;
 		const int NonrenderingRegion = -1;
 
 
+	#if CONFIGURABLE_ENTER_PLAY_MODE
+		[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
+		static void Init () {
+			// handle disabled domain reload
+			AtlasUtilities.ClearCache();
+		}
+	#endif
+
 		public static AtlasRegion ToAtlasRegion (this Texture2D t, Material materialPropertySource, float scale = DefaultScale) {
 		public static AtlasRegion ToAtlasRegion (this Texture2D t, Material materialPropertySource, float scale = DefaultScale) {
 			return t.ToAtlasRegion(materialPropertySource.shader, scale, materialPropertySource);
 			return t.ToAtlasRegion(materialPropertySource.shader, scale, materialPropertySource);
 		}
 		}