mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-18 22:08:30 +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> ();
|
_anim = this.gameObject.GetOrAddComponent<UnityEngine.Animation> ();
|
||||||
|
|
||||||
|
// remove mixing transforms for all anim states
|
||||||
|
this.RemoveAllMixingTransformsForAllAnimStates();
|
||||||
|
|
||||||
LoadModel(Definition.ModelName, Definition.TextureDictionaryName);
|
LoadModel(Definition.ModelName, Definition.TextureDictionaryName);
|
||||||
|
|
||||||
// save original model state
|
// save original model state
|
||||||
|
@ -262,7 +265,6 @@ namespace SanAndreasUnity.Behaviours
|
||||||
Destroy(_frames.Root.gameObject);
|
Destroy(_frames.Root.gameObject);
|
||||||
Destroy(_frames);
|
Destroy(_frames);
|
||||||
_frames = null;
|
_frames = null;
|
||||||
_loadedAnims.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var geoms = Geometry.Load(modelName, txds);
|
var geoms = Geometry.Load(modelName, txds);
|
||||||
|
@ -491,7 +493,8 @@ namespace SanAndreasUnity.Behaviours
|
||||||
List<Transform> list;
|
List<Transform> list;
|
||||||
if (m_mixedTransforms.TryGetValue (state, out list)) {
|
if (m_mixedTransforms.TryGetValue (state, out list)) {
|
||||||
int count = list.Count;
|
int count = list.Count;
|
||||||
foreach (var mix in list) {
|
foreach (Transform mix in list) {
|
||||||
|
if (mix != null)
|
||||||
state.RemoveMixingTransform (mix);
|
state.RemoveMixingTransform (mix);
|
||||||
}
|
}
|
||||||
list.Clear ();
|
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)
|
public Anim GetAnim (AnimGroup group, AnimIndex anim)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue