Modified SkeletonRenderer OnEnable OnDisable to be Awake and OnDestroy to clear meshes to fix a few behavioral changes.

This commit is contained in:
Fenrisul 2015-02-05 19:04:23 -08:00
parent b2ae8cba9f
commit 68cc57143e

View File

@ -78,6 +78,21 @@ public class SkeletonRenderer : MonoBehaviour {
meshFilter.sharedMesh = null;
if (renderer != null)
renderer.sharedMaterial = null;
if (mesh1 != null) {
if (Application.isPlaying)
Destroy(mesh1);
else
DestroyImmediate(mesh1);
}
if (mesh2 != null) {
if (Application.isPlaying)
Destroy(mesh2);
else
DestroyImmediate(mesh2);
}
mesh1 = null;
mesh2 = null;
lastVertexCount = 0;
@ -115,22 +130,16 @@ public class SkeletonRenderer : MonoBehaviour {
submeshSeparatorSlots.Add(skeleton.FindSlot(submeshSeparators[i]));
}
// Store flipped triangles for meshes
if (OnReset != null)
OnReset(this);
}
public virtual void OnEnable() {
if (mesh1 == null || mesh2 == null)
public virtual void Awake () {
Reset();
}
public virtual void OnDisable() {
if (Application.isPlaying && gameObject.activeInHierarchy == false) {
public virtual void OnDestroy () {
if (Application.isPlaying) {
if (mesh1 != null) {
Destroy(mesh1);
mesh1 = null;
@ -140,7 +149,6 @@ public class SkeletonRenderer : MonoBehaviour {
Destroy(mesh2);
mesh2 = null;
}
}
}