glTF_VRM_Meta.cs
5.18 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using System;
using UniGLTF;
using UniJSON;
namespace VRM
{
public enum AllowedUser
{
OnlyAuthor,
ExplicitlyLicensedPerson,
Everyone,
}
public enum LicenseType
{
Redistribution_Prohibited,
CC0,
CC_BY,
CC_BY_NC,
CC_BY_SA,
CC_BY_NC_SA,
CC_BY_ND,
CC_BY_NC_ND,
Other
}
public enum UssageLicense
{
Disallow,
Allow,
}
[Serializable]
[JsonSchema(Title = "vrm.meta")]
public class glTF_VRM_Meta : JsonSerializableBase
{
static UssageLicense FromString(string src)
{
return EnumUtil.TryParseOrDefault<UssageLicense>(src);
}
[JsonSchema(Description = "Title of VRM model")]
public string title;
[JsonSchema(Description = "Version of VRM model")]
public string version;
[JsonSchema(Description = "Author of VRM model")]
public string author;
[JsonSchema(Description = "Contact Information of VRM model author")]
public string contactInformation;
[JsonSchema(Description = "Reference of VRM model")]
public string reference;
// When the value is -1, it means that texture is not specified.
[JsonSchema(Description = "Thumbnail of VRM model", Minimum = 0, ExplicitIgnorableValue = -1)]
public int texture = -1;
#region Ussage Permission
[JsonSchema(Required = true, Description = "A person who can perform with this avatar ", EnumValues = new object[] {
"OnlyAuthor",
"ExplicitlyLicensedPerson",
"Everyone",
}, EnumSerializationType = EnumSerializationType.AsString)]
public string allowedUserName = "OnlyAuthor";
public AllowedUser allowedUser
{
get
{
return EnumUtil.TryParseOrDefault<AllowedUser>(allowedUserName);
}
set
{
allowedUserName = value.ToString();
}
}
[JsonSchema(Required = true, Description = "Permission to perform violent acts with this avatar", EnumValues = new object[]
{
"Disallow",
"Allow",
}, EnumSerializationType = EnumSerializationType.AsString)]
public string violentUssageName = "Disallow";
public UssageLicense violentUssage
{
get { return FromString(violentUssageName); }
set { violentUssageName = value.ToString(); }
}
[JsonSchema(Required = true, Description = "Permission to perform sexual acts with this avatar", EnumValues = new object[]
{
"Disallow",
"Allow",
}, EnumSerializationType = EnumSerializationType.AsString)]
public string sexualUssageName = "Disallow";
public UssageLicense sexualUssage
{
get { return FromString(sexualUssageName); }
set { sexualUssageName = value.ToString(); }
}
[JsonSchema(Required = true, Description = "For commercial use", EnumValues = new object[]
{
"Disallow",
"Allow",
}, EnumSerializationType = EnumSerializationType.AsString)]
public string commercialUssageName = "Disallow";
public UssageLicense commercialUssage
{
get { return FromString(commercialUssageName); }
set { commercialUssageName = value.ToString(); }
}
[JsonSchema(Description = "If there are any conditions not mentioned above, put the URL link of the license document here.")]
public string otherPermissionUrl;
#endregion
#region Distribution License
[JsonSchema(Required = true, Description = "License type", EnumValues = new object[]
{
"Redistribution_Prohibited",
"CC0",
"CC_BY",
"CC_BY_NC",
"CC_BY_SA",
"CC_BY_NC_SA",
"CC_BY_ND",
"CC_BY_NC_ND",
"Other"
}, EnumSerializationType = EnumSerializationType.AsString)]
public string licenseName = "Redistribution_Prohibited";
public LicenseType licenseType
{
get
{
return EnumUtil.TryParseOrDefault<LicenseType>(licenseName);
}
set
{
licenseName = value.ToString();
}
}
[JsonSchema(Description = "If “Other” is selected, put the URL link of the license document here.")]
public string otherLicenseUrl;
#endregion
protected override void SerializeMembers(GLTFJsonFormatter f)
{
f.KeyValue(() => version);
f.KeyValue(() => author);
f.KeyValue(() => contactInformation);
f.KeyValue(() => reference);
f.KeyValue(() => title);
f.KeyValue(() => texture);
f.KeyValue(() => allowedUserName);
f.KeyValue(() => violentUssageName);
f.KeyValue(() => sexualUssageName);
f.KeyValue(() => commercialUssageName);
f.KeyValue(() => otherPermissionUrl);
f.KeyValue(() => licenseName);
f.KeyValue(() => otherLicenseUrl);
}
}
}