Merge pull request #355 from Fenrisul/master

Patched SkeletonRenderer
This commit is contained in:
Fenrisul 2015-02-05 19:05:47 -08:00
commit 825259dbdb
2 changed files with 33 additions and 17 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8dc542c228b046648ae29be625ecd1b4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

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