mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-11 05:19:14 -05:00
ImporterContext.LoadAsync が UnityObjectManager を戻すようにインタフェースを変更
This commit is contained in:
@@ -59,13 +59,12 @@ namespace VRM.Samples
|
||||
Debug.LogFormat("meta: title:{0}", meta.Title);
|
||||
|
||||
// ParseしたJSONをシーンオブジェクトに変換していく
|
||||
await context.LoadAsync();
|
||||
var loaded = await context.LoadAsync();
|
||||
|
||||
context.ShowMeshes();
|
||||
context.EnableUpdateWhenOffscreen();
|
||||
var destroyer = context.DisposeOnGameObjectDestroyed();
|
||||
loaded.ShowMeshes();
|
||||
loaded.EnableUpdateWhenOffscreen();
|
||||
|
||||
OnLoaded(destroyer.gameObject);
|
||||
OnLoaded(loaded.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,16 +97,17 @@ namespace VRM.Samples
|
||||
Debug.LogFormat("meta: title:{0}", meta.Title);
|
||||
|
||||
// ParseしたJSONをシーンオブジェクトに変換していく
|
||||
var loaded = default(UnityObjectManager);
|
||||
if (m_loadAsync)
|
||||
{
|
||||
await context.LoadAsync();
|
||||
loaded = await context.LoadAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Load();
|
||||
loaded = context.Load();
|
||||
}
|
||||
|
||||
OnLoaded(context);
|
||||
OnLoaded(loaded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,15 +136,16 @@ namespace VRM.Samples
|
||||
parser.ParseGlb(bytes);
|
||||
|
||||
var context = new VRMImporterContext(parser);
|
||||
var loaded = default(UnityObjectManager);
|
||||
if (m_loadAsync)
|
||||
{
|
||||
await context.LoadAsync();
|
||||
loaded = await context.LoadAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Load();
|
||||
loaded = context.Load();
|
||||
}
|
||||
OnLoaded(context);
|
||||
OnLoaded(loaded);
|
||||
}
|
||||
|
||||
void LoadBVHClicked()
|
||||
@@ -165,15 +167,14 @@ namespace VRM.Samples
|
||||
#endif
|
||||
}
|
||||
|
||||
void OnLoaded(VRMImporterContext context)
|
||||
void OnLoaded(UnityObjectManager loaded)
|
||||
{
|
||||
var root = context.Root;
|
||||
var root = loaded.gameObject;
|
||||
|
||||
root.transform.SetParent(transform, false);
|
||||
|
||||
//メッシュを表示します
|
||||
context.ShowMeshes();
|
||||
context.DisposeOnGameObjectDestroyed();
|
||||
loaded.ShowMeshes();
|
||||
|
||||
// add motion
|
||||
var humanPoseTransfer = root.AddComponent<UniHumanoid.HumanPoseTransfer>();
|
||||
|
||||
@@ -317,11 +317,10 @@ namespace VRM.Samples
|
||||
using (var context = new VRMImporterContext(parser))
|
||||
{
|
||||
await m_texts.UpdateMetaAsync(context);
|
||||
await context.LoadAsync();
|
||||
context.EnableUpdateWhenOffscreen();
|
||||
context.ShowMeshes();
|
||||
context.DisposeOnGameObjectDestroyed();
|
||||
SetModel(context.Root);
|
||||
var loaded = await context.LoadAsync();
|
||||
loaded.EnableUpdateWhenOffscreen();
|
||||
loaded.ShowMeshes();
|
||||
SetModel(loaded.gameObject);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -333,11 +332,10 @@ namespace VRM.Samples
|
||||
parser.ParseGlb(file);
|
||||
|
||||
var context = new UniGLTF.ImporterContext(parser);
|
||||
context.Load();
|
||||
context.EnableUpdateWhenOffscreen();
|
||||
context.ShowMeshes();
|
||||
context.DisposeOnGameObjectDestroyed();
|
||||
SetModel(context.Root);
|
||||
var loaded = context.Load();
|
||||
loaded.EnableUpdateWhenOffscreen();
|
||||
loaded.ShowMeshes();
|
||||
SetModel(loaded.gameObject);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -348,11 +346,10 @@ namespace VRM.Samples
|
||||
parser.ParsePath(path);
|
||||
|
||||
var context = new UniGLTF.ImporterContext(parser);
|
||||
context.Load();
|
||||
context.EnableUpdateWhenOffscreen();
|
||||
context.ShowMeshes();
|
||||
context.DisposeOnGameObjectDestroyed();
|
||||
SetModel(context.Root);
|
||||
var loaded = context.Load();
|
||||
loaded.EnableUpdateWhenOffscreen();
|
||||
loaded.ShowMeshes();
|
||||
SetModel(loaded.gameObject);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user