From 3d1303759d0754edb51825c43d3ca7329e3eed23 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 8 Sep 2022 18:50:37 +0900 Subject: [PATCH] add LoadPathAsync --- Assets/VRM_Samples/SimpleViewer/ViewerUI.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Assets/VRM_Samples/SimpleViewer/ViewerUI.cs b/Assets/VRM_Samples/SimpleViewer/ViewerUI.cs index b9e034fdc..e73efc003 100644 --- a/Assets/VRM_Samples/SimpleViewer/ViewerUI.cs +++ b/Assets/VRM_Samples/SimpleViewer/ViewerUI.cs @@ -327,7 +327,7 @@ namespace VRM.SimpleViewer string[] cmds = System.Environment.GetCommandLineArgs(); if (cmds.Length > 1) { - LoadModelAsync(cmds[1]); + LoadPathAsync(cmds[1]); } m_texts.Start(); @@ -391,10 +391,20 @@ namespace VRM.SimpleViewer return; } - LoadModelAsync(path); + LoadPathAsync(path); } - async void LoadModelAsync(string path, byte[] bytes = null) + async void LoadPathAsync(string path) + { + if (!File.Exists(path)) + { + Debug.LogWarning($"{path} not exists"); + return; + } + LoadModelAsync(path, File.ReadAllBytes(path)); + } + + async void LoadModelAsync(string path, byte[] bytes) { var size = bytes != null ? bytes.Length : 0; Debug.Log($"LoadModelAsync: {path}: {size}bytes");