Browse Source

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

Harald Csaszar 5 years ago
parent
commit
84443288b5

+ 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.
  *****************************************************************************/
 
+#if UNITY_2019_3_OR_NEWER
+#define CONFIGURABLE_ENTER_PLAY_MODE
+#endif
+
+
 using UnityEngine;
 using System.Collections.Generic;
 using System;
 
+
 namespace Spine.Unity.AttachmentTools {
 
 	public static class AtlasUtilities {
@@ -41,6 +47,14 @@ namespace Spine.Unity.AttachmentTools {
 
 		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) {
 			return t.ToAtlasRegion(materialPropertySource.shader, scale, materialPropertySource);
 		}