-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnityObjectDestoyer 改め RuntimeGltfInstance #1021
UnityObjectDestoyer 改め RuntimeGltfInstance #1021
Conversation
GameObject(prefab root)の移譲の判定にしか使っていなかった。設計変更で不要になった
5efbcef
to
81e02c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
よさそう!
名称だけ…
@@ -21,7 +21,7 @@ public static void OnGUIAnimation(ScriptedImporter importer, GltfParser parser) | |||
} | |||
} | |||
|
|||
importer.DrawRemapGUI<AnimationClip>(parser.GLTF.animations.Select(x => new SubAssetKey(typeof(AnimationClip), x.name))); | |||
importer.DrawRemapGUI<AnimationClip>(AnimationImporterUtil.EnumerateSubAssetKeys(parser.GLTF)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yosasou
{ | ||
public static class UnityObjectDestoyer | ||
{ | ||
public static void DestroyRuntimeOrEditor(UnityEngine.Object o) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄
/// TransferOwnership により、破棄責任を移譲することができる。 | ||
/// | ||
/// </summary> | ||
public interface IResponsibilityForDestroyObjects : IDisposable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
よさそう
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これも名前がもうひとひねりほしい気がするが、思いつかない……
長ったらしく書くと、このインタフェースを実装するクラスの責務は「所有権を持つ UnityEngine.Object を移譲することができる」だと思うのだが、う~ん…
/// <summary> | ||
/// Mesh, Material, Texture などを抱えておいて確実に破棄できるようにする | ||
/// </summary> | ||
public class UnityObjectManager : MonoBehaviour, IResponsibilityForDestroyObjects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
存在はいい!が名前が…う~ん…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ユーザの期待としては Load
API の返り値は「ロードした glTF/VRM モデルそのもの」だと思うので、そういう名称にしてしまっていいと思う。
ModelInstance
とか glTFModel
とか
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
インスタンスの変数名も loaded
じゃなくて loadedModel
とか model
でよさそう
|
||
public void Dispose() | ||
{ | ||
UnityObjectDestoyer.DestroyRuntimeOrEditor(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.gameObject
を Destroy すべきかも
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
たしかに!
サンプルコードもいずれ合わせて要修正 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -61,7 +61,7 @@ public class ImporterContext : IResponsibilityForDestroyObjects | |||
}; | |||
|
|||
#region Load. Build unity objects | |||
public virtual async Task<UnityObjectManager> LoadAsync(IAwaitCaller awaitCaller = null, Func<string, IDisposable> MeasureTime = null) | |||
public virtual async Task<RuntimeGltfInstance> LoadAsync(IAwaitCaller awaitCaller = null, Func<string, IDisposable> MeasureTime = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
よさそう!
/// </summary> | ||
public class UnityObjectManager : MonoBehaviour, IResponsibilityForDestroyObjects | ||
public class RuntimeGltfInstance : MonoBehaviour, IResponsibilityForDestroyObjects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
よさそう!
/// <summary> | ||
/// this is UniGLTF root gameObject | ||
/// </summary> | ||
public GameObject Root => this.gameObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
よさそう!
@@ -58,7 +64,7 @@ public void TransferOwnership(TakeResponsibilityForDestroyObjectFunc take) | |||
|
|||
public void Dispose() | |||
{ | |||
UnityObjectDestoyer.DestroyRuntimeOrEditor(this); | |||
UnityObjectDestoyer.DestroyRuntimeOrEditor(this.gameObject); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
よさそう!
#1018
新しい使い方は以下のような感じ。
インタフェース。デストロイすべき UnityEngine.Object をため込む