VRMImporter.cs
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System;
using System.IO;
using UniGLTF;
using UnityEngine;
#if ((NET_4_6 || NET_STANDARD_2_0) && UNITY_2017_1_OR_NEWER)
using System.Threading.Tasks;
#endif
namespace VRM
{
public static class VRMImporter
{
[Obsolete("use VRMImporterContext.Load(path)")]
public static GameObject LoadFromPath(string path)
{
var context = new VRMImporterContext();
context.Parse(path, File.ReadAllBytes(path));
context.Load();
context.ShowMeshes();
context.EnableUpdateWhenOffscreen();
return context.Root;
}
[Obsolete("use VRMImporterContext.Load(bytes)")]
public static GameObject LoadFromBytes(Byte[] bytes)
{
var context = new VRMImporterContext();
context.ParseGlb(bytes);
context.Load();
context.ShowMeshes();
context.EnableUpdateWhenOffscreen();
return context.Root;
}
[Obsolete("use VRMImporterContext.Load()")]
public static void LoadFromBytes(VRMImporterContext context)
{
context.Load();
context.ShowMeshes();
context.EnableUpdateWhenOffscreen();
}
#region LoadVrmAsync
[Obsolete("use VRMImporterContext.LoadAsync")]
public static void LoadVrmAsync(string path, Action<GameObject> onLoaded, Action<Exception> onError = null, bool show = true)
{
LoadVrmAsync(File.ReadAllBytes(path), onLoaded, onError, show);
}
[Obsolete("use VRMImporterContext.LoadAsync")]
public static void LoadVrmAsync(Byte[] bytes, Action<GameObject> onLoaded, Action<Exception> onError = null, bool show = true)
{
var context = new VRMImporterContext();
using (context.MeasureTime("ParseGlb"))
{
context.ParseGlb(bytes);
}
context.LoadAsync(_ =>
{
if (show)
{
context.ShowMeshes();
}
onLoaded(context.Root);
},
onError);
}
[Obsolete("use VRMImporterContext.LoadAsync")]
public static void LoadVrmAsync(VRMImporterContext context, Action<GameObject> onLoaded, Action<Exception> onError = null, bool show = true)
{
context.LoadAsync(_ =>
{
if (show)
{
context.ShowMeshes();
}
onLoaded(context.Root);
},
onError);
}
#endregion
#if ((NET_4_6 || NET_STANDARD_2_0) && UNITY_2017_1_OR_NEWER && !UNITY_WEBGL)
[Obsolete("use VRMImporterContext.LoadAsync()")]
public static Task<GameObject> LoadVrmAsync(string path, bool show = true)
{
var context = new VRMImporterContext();
context.ParseGlb(File.ReadAllBytes(path));
return LoadVrmAsync(context, show);
}
[Obsolete("use VRMImporterContext.LoadAsync()")]
public static Task<GameObject> LoadVrmAsync(Byte[] bytes, bool show = true)
{
var context = new VRMImporterContext();
context.ParseGlb(bytes);
return LoadVrmAsync(context, show);
}
[Obsolete("use VRMImporterContext.LoadAsync()")]
public async static Task<GameObject> LoadVrmAsync(VRMImporterContext ctx, bool show = true)
{
await ctx.LoadAsyncTask();
if (show)
{
ctx.ShowMeshes();
}
return ctx.Root;
}
#endif
}
}