mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-01 12:15:05 +08:00
f6ac07e1cd
* opti: perf improvements for armature lock * chore: unity 2019 compatibility * chore: update comments
40 lines
813 B
C#
40 lines
813 B
C#
#region
|
|
|
|
using System;
|
|
using UnityEditor;
|
|
|
|
#endregion
|
|
|
|
namespace nadena.dev.modular_avatar.core.armature_lock
|
|
{
|
|
internal static class DeferDestroy
|
|
{
|
|
private static bool _immediate = false;
|
|
|
|
internal static void DestroyImmediate(IDisposable obj)
|
|
{
|
|
var oldValue = _immediate;
|
|
_immediate = true;
|
|
try
|
|
{
|
|
obj.Dispose();
|
|
}
|
|
finally
|
|
{
|
|
_immediate = oldValue;
|
|
}
|
|
}
|
|
|
|
internal static void DeferDestroyObj(IDisposable obj)
|
|
{
|
|
if (_immediate)
|
|
{
|
|
obj.Dispose();
|
|
return;
|
|
}
|
|
#if UNITY_EDITOR
|
|
EditorApplication.delayCall += () => obj.Dispose();
|
|
#endif
|
|
}
|
|
}
|
|
} |