mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-27 06:20:17 +00:00
fix memory leak related to anim clips
This commit is contained in:
parent
6ffaf6a552
commit
8cae6c9206
1 changed files with 17 additions and 3 deletions
|
@ -217,6 +217,9 @@ namespace SanAndreasUnity.Behaviours
|
|||
|
||||
_anim = this.gameObject.GetOrAddComponent<UnityEngine.Animation> ();
|
||||
|
||||
// remove mixing transforms for all anim states
|
||||
this.RemoveAllMixingTransformsForAllAnimStates();
|
||||
|
||||
LoadModel(Definition.ModelName, Definition.TextureDictionaryName);
|
||||
|
||||
// save original model state
|
||||
|
@ -262,7 +265,6 @@ namespace SanAndreasUnity.Behaviours
|
|||
Destroy(_frames.Root.gameObject);
|
||||
Destroy(_frames);
|
||||
_frames = null;
|
||||
_loadedAnims.Clear();
|
||||
}
|
||||
|
||||
var geoms = Geometry.Load(modelName, txds);
|
||||
|
@ -491,7 +493,8 @@ namespace SanAndreasUnity.Behaviours
|
|||
List<Transform> list;
|
||||
if (m_mixedTransforms.TryGetValue (state, out list)) {
|
||||
int count = list.Count;
|
||||
foreach (var mix in list) {
|
||||
foreach (Transform mix in list) {
|
||||
if (mix != null)
|
||||
state.RemoveMixingTransform (mix);
|
||||
}
|
||||
list.Clear ();
|
||||
|
@ -501,6 +504,17 @@ namespace SanAndreasUnity.Behaviours
|
|||
}
|
||||
}
|
||||
|
||||
public void RemoveAllMixingTransformsForAllAnimStates()
|
||||
{
|
||||
foreach (AnimationState s in this.AnimComponent)
|
||||
{
|
||||
if (s != null)
|
||||
this.RemoveAllMixingTransforms(s);
|
||||
}
|
||||
|
||||
m_mixedTransforms.Clear();
|
||||
}
|
||||
|
||||
|
||||
public Anim GetAnim (AnimGroup group, AnimIndex anim)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue