mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-21 06:27:29 -05:00
Add ArgumentChecker. Hide boxman when loaded
This commit is contained in:
parent
fcc8eb6ee1
commit
0cd565fb85
|
|
@ -244,6 +244,61 @@ namespace UniVRM10.VRM10Viewer
|
|||
|
||||
Loaded m_loaded;
|
||||
|
||||
static class ArgumentChecker
|
||||
{
|
||||
static string[] Supported = {
|
||||
".gltf",
|
||||
".glb",
|
||||
".vrm",
|
||||
".zip",
|
||||
};
|
||||
|
||||
static string UnityHubPath => System.Environment.GetEnvironmentVariable("ProgramFiles") + "\\Unity\\Hub";
|
||||
|
||||
public static bool IsLoadable(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
// not exists
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Application.isEditor)
|
||||
{
|
||||
// skip editor argument
|
||||
// {UnityHub_Resources}\PackageManager\ProjectTemplates\com.unity.template.3d-5.0.4.tgz
|
||||
if (path.StartsWith(UnityHubPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var ext = Path.GetExtension(path).ToLower();
|
||||
if (!Supported.Contains(ext))
|
||||
{
|
||||
// unknown extension
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TryGetFirstLoadable(out string cmd)
|
||||
{
|
||||
foreach (var arg in System.Environment.GetCommandLineArgs())
|
||||
{
|
||||
if (ArgumentChecker.IsLoadable(arg))
|
||||
{
|
||||
cmd = arg;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
cmd = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_version.text = string.Format("VRMViewer {0}.{1}",
|
||||
|
|
@ -259,13 +314,9 @@ namespace UniVRM10.VRM10Viewer
|
|||
Motion = BvhMotion.LoadBvhFromText(m_motion.text);
|
||||
}
|
||||
|
||||
string[] cmds = System.Environment.GetCommandLineArgs();
|
||||
for (int i = 1; i < cmds.Length; ++i)
|
||||
if (ArgumentChecker.TryGetFirstLoadable(out var cmd))
|
||||
{
|
||||
if (File.Exists(cmds[i]))
|
||||
{
|
||||
LoadModel(cmds[i]);
|
||||
}
|
||||
LoadModel(cmd);
|
||||
}
|
||||
|
||||
m_texts.Start();
|
||||
|
|
@ -431,6 +482,7 @@ namespace UniVRM10.VRM10Viewer
|
|||
instance.ShowMeshes();
|
||||
instance.EnableUpdateWhenOffscreen();
|
||||
m_loaded = new Loaded(instance, m_target.transform);
|
||||
m_showBoxMan.isOn = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user