From 1f13add10196b0500ff3e514e5456ccb624e4fb6 Mon Sep 17 00:00:00 2001 From: Fenrisul Date: Thu, 5 Feb 2015 19:09:47 -0800 Subject: [PATCH] One more adjustment to SkeletonRenderer. --- .../Assets/spine-unity/SkeletonRenderer.cs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/spine-unity/Assets/spine-unity/SkeletonRenderer.cs b/spine-unity/Assets/spine-unity/SkeletonRenderer.cs index da445f6dd..d200de45c 100644 --- a/spine-unity/Assets/spine-unity/SkeletonRenderer.cs +++ b/spine-unity/Assets/spine-unity/SkeletonRenderer.cs @@ -139,17 +139,22 @@ public class SkeletonRenderer : MonoBehaviour { } public virtual void OnDestroy () { - if (Application.isPlaying) { - if (mesh1 != null) { + if (mesh1 != null) { + if (Application.isPlaying) Destroy(mesh1); - mesh1 = null; - } - - if (mesh2 != null) { - Destroy(mesh2); - mesh2 = null; - } + else + DestroyImmediate(mesh1); } + + if (mesh2 != null) { + if (Application.isPlaying) + Destroy(mesh2); + else + DestroyImmediate(mesh2); + } + + mesh1 = null; + mesh2 = null; } private Mesh newMesh () {