From 4b5346bb41d687720b40ec20f4632552df4676c5 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Fri, 29 Jan 2021 18:43:30 +0900 Subject: [PATCH] Complete meta "violentUssageName" & "sexualUssageName" migration. --- Assets/VRM10/Runtime/Migration/Migration.cs | 48 +++++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/Assets/VRM10/Runtime/Migration/Migration.cs b/Assets/VRM10/Runtime/Migration/Migration.cs index 5f4e2e4cd..6b90b83ab 100644 --- a/Assets/VRM10/Runtime/Migration/Migration.cs +++ b/Assets/VRM10/Runtime/Migration/Migration.cs @@ -177,8 +177,8 @@ namespace UniVRM10 case "allowedUserName": { - var allowedUserType = kv.Value.GetString(); - switch (allowedUserType) + var allowedUserName = kv.Value.GetString(); + switch (allowedUserName) { case "OnlyAuthor": meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.onlyAuthor; @@ -190,17 +190,49 @@ namespace UniVRM10 meta.AvatarPermission = UniGLTF.Extensions.VRMC_vrm.AvatarPermissionType.everyone; break; default: - throw new NotImplementedException($"allowedUser: {allowedUserType}"); + throw new NotImplementedException($"{key}: {allowedUserName}"); } } break; - case "violentUssageName": meta.AllowExcessivelyViolentUsage = kv.Value.GetString().ToLower() == "allow"; break; // Typo "Ussage" is VRM 0.x spec. - case "sexualUssageName": meta.AllowExcessivelySexualUsage = kv.Value.GetString().ToLower() == "allow"; break; // Typo "Ussage" is VRM 0.x spec. + case "violentUssageName": // Typo "Ussage" is VRM 0.x spec. + { + var violentUsageName = kv.Value.GetString(); + switch (violentUsageName) + { + case "allow": + meta.AllowExcessivelyViolentUsage = true; + break; + case "disallow": + meta.AllowExcessivelyViolentUsage = false; + break; + default: + throw new NotImplementedException($"{key}: {violentUsageName}"); + } + } + break; + + case "sexualUssageName": // Typo "Ussage" is VRM 0.x spec. + { + var sexualUsageName = kv.Value.GetString(); + switch (sexualUsageName) + { + case "Allow": + meta.AllowExcessivelySexualUsage = true; + break; + case "Disallow": + meta.AllowExcessivelySexualUsage = false; + break; + default: + throw new NotImplementedException($"{key}: {sexualUsageName}"); + } + } + break; + case "commercialUssageName": // Typo "Ussage" is VRM 0.x spec. { - var commercialUsageType = kv.Value.GetString(); - switch (commercialUsageType) + var commercialUsageName = kv.Value.GetString(); + switch (commercialUsageName) { case "Allow": meta.CommercialUsage = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalProfit; @@ -209,7 +241,7 @@ namespace UniVRM10 meta.CommercialUsage = UniGLTF.Extensions.VRMC_vrm.CommercialUsageType.personalNonProfit; break; default: - throw new NotImplementedException($"{key}: {commercialUsageType}"); + throw new NotImplementedException($"{key}: {commercialUsageName}"); } } break;