mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-23 12:33:02 +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,8 +493,9 @@ namespace SanAndreasUnity.Behaviours
|
|||
List<Transform> list;
|
||||
if (m_mixedTransforms.TryGetValue (state, out list)) {
|
||||
int count = list.Count;
|
||||
foreach (var mix in list) {
|
||||
state.RemoveMixingTransform (mix);
|
||||
foreach (Transform mix in list) {
|
||||
if (mix != null)
|
||||
state.RemoveMixingTransform (mix);
|
||||
}
|
||||
list.Clear ();
|
||||
return count;
|
||||
|
@ -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