Skip to content

Commit

Permalink
feat: Added GltfAssetBase.Dispose for releasing resources
Browse files Browse the repository at this point in the history
  • Loading branch information
atteneder committed May 25, 2022
1 parent 0eb9387 commit cc4d480
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- A target layer can be defined for instantiated GameObjects via `GameObjectInstantiator.Settings.layer` (thanks [Krzysztof Lesiak][Holo-Krzysztof] for #393)
- Re-normalize bone weights (always for design-time import and opt-in at runtime via `GLTFAST_SAFE` scripting define)
- `GltfAssetBase.Dispose` for releasing resources
### Changed
- Mecanim (non-legacy) is now the default for importing animation clips at design-time (thanks [@hybridherbst][hybridherbst] for #388)
- All four bone weights are imported at design-time, regardless of quality setting
Expand Down
11 changes: 9 additions & 2 deletions Runtime/Scripts/GltfAssetBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,19 @@ protected virtual void PostInstantiation(IInstantiator instantiator, bool succes
currentSceneId = success ? importer.defaultSceneIndex : (int?)null;
}

protected virtual void OnDestroy()
{
/// <summary>
/// Releases previously allocated resources.
/// </summary>
public void Dispose() {
if(importer!=null) {
importer.Dispose();
importer=null;
}
}

protected virtual void OnDestroy()
{
Dispose();
}
}
}

0 comments on commit cc4d480

Please sign in to comment.