Created
July 18, 2020 20:59
-
-
Save nekomimi-daimao/8629d99e9b38bf00a68dad50c31543f4 to your computer and use it in GitHub Desktop.
call AutoDispose(), dispose VRMImporterContext OnDestroy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
namespace VRM.Extension | |
{ | |
public class VRMAutoDisposer : MonoBehaviour | |
{ | |
public VRMImporterContext Context; | |
private void OnDestroy() | |
{ | |
Context?.Dispose(); | |
} | |
} | |
public static class VRMAutoDisposerExtension | |
{ | |
public static void AutoDispose(this VRMImporterContext context) | |
{ | |
var disposer = context.Root.AddComponent<VRMAutoDisposer>(); | |
disposer.Context = context; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment