mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-10-01 15:22:53 -05:00
IResponsibilityForDestroyObjects
This commit is contained in:
@@ -10,7 +10,7 @@ namespace UniGLTF
|
||||
/// <summary>
|
||||
/// GLTF importer
|
||||
/// </summary>
|
||||
public class ImporterContext : IDisposable
|
||||
public class ImporterContext : IResponsibilityForDestroyObjects
|
||||
{
|
||||
public ITextureDescriptorGenerator TextureDescriptorGenerator { get; protected set; }
|
||||
public IMaterialDescriptorGenerator MaterialDescriptorGenerator { get; protected set; }
|
||||
@@ -358,7 +358,7 @@ namespace UniGLTF
|
||||
/// Root ヒエラルキーで使っているリソース
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual void TransferOwnership(Func<UnityEngine.Object, bool> take)
|
||||
public virtual void TransferOwnership(TakeResponsibilityForDestroyObjectFunc take)
|
||||
{
|
||||
var list = new List<UnityEngine.Object>();
|
||||
foreach (var mesh in Meshes)
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace VRM
|
||||
return meta;
|
||||
}
|
||||
|
||||
public override void TransferOwnership(Func<UnityEngine.Object, bool> take)
|
||||
public override void TransferOwnership(TakeResponsibilityForDestroyObjectFunc take)
|
||||
{
|
||||
// VRM 固有のリソース(ScriptableObject)
|
||||
if (take(HumanoidAvatar))
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace VRMShaders
|
||||
{
|
||||
public delegate bool TakeResponsibilityForDestroyObjectFunc(UnityEngine.Object obj);
|
||||
|
||||
/// <summary>
|
||||
/// UnityObjectを破棄する責務。
|
||||
///
|
||||
/// この interface を実装するクラスは、利用後に破棄すべき UnityObject を保持する可能性があるので
|
||||
/// Dispose により解放すること。
|
||||
///
|
||||
/// TransferOwnership により、破棄責任を移譲することができる。
|
||||
///
|
||||
/// </summary>
|
||||
public interface IResponsibilityForDestroyObjects : IDisposable
|
||||
{
|
||||
void TransferOwnership(TakeResponsibilityForDestroyObjectFunc take);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93ab2216c7e8c684d84873bd2ae72c6e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -9,7 +9,7 @@ namespace VRMShaders
|
||||
{
|
||||
public delegate Task<Texture> GetTextureAsyncFunc(TextureDescriptor texDesc);
|
||||
|
||||
public class MaterialFactory : IDisposable
|
||||
public class MaterialFactory : IResponsibilityForDestroyObjects
|
||||
{
|
||||
private readonly IReadOnlyDictionary<SubAssetKey, Material> m_externalMap;
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace VRMShaders
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="take"></param>
|
||||
public void TransferOwnership(Func<UnityEngine.Object, bool> take)
|
||||
public void TransferOwnership(TakeResponsibilityForDestroyObjectFunc take)
|
||||
{
|
||||
var list = new List<Material>();
|
||||
foreach (var x in m_materials)
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace VRMShaders
|
||||
{
|
||||
public class TextureFactory : IDisposable
|
||||
public class TextureFactory : IResponsibilityForDestroyObjects
|
||||
{
|
||||
private readonly ITextureDeserializer _textureDeserializer;
|
||||
private readonly IReadOnlyDictionary<SubAssetKey, Texture> _externalMap;
|
||||
@@ -43,7 +43,7 @@ namespace VRMShaders
|
||||
/// 所有権(Dispose権)を移譲する
|
||||
/// </summary>
|
||||
/// <param name="take"></param>
|
||||
public void TransferOwnership(Func<UnityEngine.Object, bool> take)
|
||||
public void TransferOwnership(TakeResponsibilityForDestroyObjectFunc take)
|
||||
{
|
||||
var transferredAssets = new HashSet<SubAssetKey>();
|
||||
foreach (var x in _textureCache)
|
||||
|
||||
Reference in New Issue
Block a user