diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/IResponsibilityForDestroyObjects.cs b/Assets/VRMShaders/GLTF/IO/Runtime/IResponsibilityForDestroyObjects.cs index 05ae257b3..00a7d675b 100644 --- a/Assets/VRMShaders/GLTF/IO/Runtime/IResponsibilityForDestroyObjects.cs +++ b/Assets/VRMShaders/GLTF/IO/Runtime/IResponsibilityForDestroyObjects.cs @@ -10,7 +10,10 @@ namespace VRMShaders /// この interface を実装するクラスは、利用後に破棄すべき UnityObject を保持する可能性があるので /// Dispose により解放すること。 /// - /// TransferOwnership により、破棄責任を移譲することができる。 + /// [Runtime] TransferOwnership により、破棄責任を RuntimeGltfInstance に移譲する。 + /// RuntimeGltfInstance.OnDestroy でこれを破棄する。 + /// [Editor] TransferOwnership により、Asset化して破棄しない + /// DestroyするとAssetが消えてしまう。 /// /// public interface IResponsibilityForDestroyObjects : IDisposable diff --git a/docs/implementation/runtime_resource_management.md b/docs/implementation/runtime_resource_management.md new file mode 100644 index 000000000..f2a7f09dc --- /dev/null +++ b/docs/implementation/runtime_resource_management.md @@ -0,0 +1,53 @@ +# Runtime のリソース管理について + +Runtime Import で `Texture`, `Material`, `Mesh` などのリソースを Root の `GameObject.OnDestroy` +と同時に `UnityEngine.Object.Destroy` したい。 + +## RuntimeGltfInstance + +`RuntimeGltfInstance.OnDestroy` で破棄を実行するようにした。 + +``` +ImporterContext + [Own]List + AnimationClipFactory[Own]List + TextureFactory[Own]List + MaterialFactory[Own]List + +👇 ImporterContext.LoadAsync + RuntimeGltfInstance.AttachTo + ImporterContext.TransferOwnership + +RuntimeGltfInstance + [Own]List + [Own]List + [Own]List + [Own]List +``` + +> VRM-0.X では `RuntimeGltfInstance` にリソースを委譲している。 + +## Vrm10Instance + +``` +Vrm10Importer + [Own]HumanoidAvatar + [Own]Vrm10Object + [Own]List + +👇 Vrm10Importer.LoadAsync + +RuntimeGltfInstance + [Own]HumanoidAvatar + [Own]VrmObject + [Own]List +``` + +### FirstPerson + +``` +👇 Vrm10Instance.FirstPerson.SetupAsync + +RuntimeGltfInstance + [Own]List.Add(headless) +``` diff --git a/docs/index.md b/docs/index.md index 2161c4bf6..9e9cbc0ff 100644 --- a/docs/index.md +++ b/docs/index.md @@ -37,6 +37,13 @@ vrm0/0_58_blendshape.md vrm0/firstperson.md ``` +## 実装メモ + +```{toctree} + +implementation/runtime_resource_management.md +``` + ### Samples - SimpleViewer