Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4 from sh-akira/master
Browse files Browse the repository at this point in the history
[RuntimeLoader] fix obsolete import API to new API
  • Loading branch information
ousttrue authored Oct 11, 2018
2 parents 2d693dd + 82b4806 commit b7cb4ea
Show file tree
Hide file tree
Showing 2 changed files with 203 additions and 188 deletions.
37 changes: 23 additions & 14 deletions Assets/VRM.Samples/Scripts/VRMRuntimeLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ void LoadVRMClicked()
}
else
{
VRMImporter.LoadFromBytes(context);
OnLoaded(context.Root);
context.Load();
OnLoaded(context);
}
}

Expand All @@ -127,15 +127,20 @@ void LoadVRMClicked_without_meta()
var bytes = File.ReadAllBytes(path);
// なんらかの方法でByte列を得た

var context = new VRMImporterContext();

// GLB形式でJSONを取得しParseします
context.ParseGlb(bytes);

if (m_loadAsync)
{
// ローカルファイルシステムからロードします
VRMImporter.LoadVrmAsync(bytes, OnLoaded);
LoadAsync(context);
}
else
{
var root=VRMImporter.LoadFromBytes(bytes);
OnLoaded(root);
context.Load();
OnLoaded(context);
}

#else
Expand All @@ -158,10 +163,11 @@ void LoadAsync(VRMImporterContext context)
{
#if true
var now = Time.time;
VRMImporter.LoadVrmAsync(context, go=> {
context.LoadAsync(_ =>
{
var delta = Time.time - now;
Debug.LogFormat("LoadVrmAsync {0:0.0} seconds", delta);
OnLoaded(go);
Debug.LogFormat("LoadAsync {0:0.0} seconds", delta);
OnLoaded(context);
});
#else
// ローカルファイルシステムからロードします
Expand All @@ -182,10 +188,14 @@ void LoadBVHClicked()
#endif
}

void OnLoaded(GameObject root)
void OnLoaded(VRMImporterContext context)
{
var root = context.Root;
root.transform.SetParent(transform, false);

//メッシュを表示します
context.ShowMeshes();

// add motion
var humanPoseTransfer = root.AddComponent<UniHumanoid.HumanPoseTransfer>();
if (m_target != null)
Expand All @@ -199,11 +209,10 @@ void OnLoaded(GameObject root)
void LoadBvh(string path)
{
Debug.LogFormat("ImportBvh: {0}", path);
var context = new UniHumanoid.ImporterContext
{
Path = path
};
UniHumanoid.BvhImporter.Import(context);
var context = new UniHumanoid.BvhImporterContext();

context.Parse(path);
context.Load();

if (m_source != null)
{
Expand Down
Loading

0 comments on commit b7cb4ea

Please sign in to comment.