Skip to content

Instantly share code, notes, and snippets.

@nekomimi-daimao
Created July 18, 2020 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nekomimi-daimao/8629d99e9b38bf00a68dad50c31543f4 to your computer and use it in GitHub Desktop.
Save nekomimi-daimao/8629d99e9b38bf00a68dad50c31543f4 to your computer and use it in GitHub Desktop.
call AutoDispose(), dispose VRMImporterContext OnDestroy
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