From bd85430cbb7a13411b050cb233670ace7156d038 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 6 Apr 2018 15:13:33 +0900 Subject: [PATCH] update Meta --- Scripts/Format/glTF_VRM_Meta.cs | 84 +++++++++++++++++++++------- Scripts/Meta/Editor/VRMMetaEditor.cs | 20 ++++++- Scripts/Meta/VRMMetaObject.cs | 29 +++++++--- 3 files changed, 104 insertions(+), 29 deletions(-) diff --git a/Scripts/Format/glTF_VRM_Meta.cs b/Scripts/Format/glTF_VRM_Meta.cs index 4819aa0b3..dcffb372c 100644 --- a/Scripts/Format/glTF_VRM_Meta.cs +++ b/Scripts/Format/glTF_VRM_Meta.cs @@ -4,6 +4,13 @@ using UniGLTF; namespace VRM { + public enum AllowedUser + { + OnlyAuthor, + Everyone, + } + + public enum LicenseType { RedistributionProhibited, @@ -19,32 +26,60 @@ namespace VRM Other } - public static class LicenseTypeExtensions - { - public static LicenseType ToLicenseType(this string src) - { - try - { - return (LicenseType)Enum.Parse(typeof(LicenseType), src, true); - } - catch (Exception) - { - return default(LicenseType); - } - } - } [Serializable] public class glTF_VRM_Meta : JsonSerializableBase { + public string version; + public string author; public string contactInformation; + public string reference; + + public string title; + public int texture = -1; + + #region PersonationCharacterizationPermission Permission; + public string allowedUserName; + public AllowedUser allowedUser + { + get + { + try + { + return (AllowedUser)Enum.Parse(typeof(AllowedUser), allowedUserName, true); + } + catch (Exception) + { + return AllowedUser.OnlyAuthor; + } + } + set + { + allowedUserName = value.ToString(); + } + } + + public bool allowImmoralUssage; + public bool allowCcertainBeliefsUssage; + public bool allowPoliticalUssage; + public bool allowCommercialUssage; + #endregion + + #region Distribution License public string licenseName; public LicenseType licenseType { get { - return licenseName.ToLicenseType(); + try + { + return (LicenseType)Enum.Parse(typeof(LicenseType), licenseName, true); + } + catch (Exception) + { + return default(LicenseType); + } } set { @@ -52,20 +87,27 @@ namespace VRM } } public string otherLicenseUrl; - public string reference; - - public string title; - public int texture = -1; + #endregion protected override void SerializeMembers(JsonFormatter f) { + f.KeyValue(() => version); + f.KeyValue(() => author); f.KeyValue(() => contactInformation); - f.KeyValue(() => licenseName); - f.KeyValue(() => otherLicenseUrl); f.KeyValue(() => reference); + f.KeyValue(() => title); f.KeyValue(() => texture); + + f.KeyValue(() => allowedUserName); + f.KeyValue(() => allowImmoralUssage); + f.KeyValue(() => allowCcertainBeliefsUssage); + f.KeyValue(() => allowPoliticalUssage); + f.KeyValue(() => allowCommercialUssage); + + f.KeyValue(() => licenseName); + f.KeyValue(() => otherLicenseUrl); } } } diff --git a/Scripts/Meta/Editor/VRMMetaEditor.cs b/Scripts/Meta/Editor/VRMMetaEditor.cs index 9b7a6d28b..c031c6af5 100644 --- a/Scripts/Meta/Editor/VRMMetaEditor.cs +++ b/Scripts/Meta/Editor/VRMMetaEditor.cs @@ -53,10 +53,28 @@ namespace VRM iterator.propertyType ); */ - EditorGUILayout.PropertyField(iterator, false); + if (iterator.name == "Thumbnail") + { + iterator.objectReferenceValue=TextureField(iterator.name, (Texture2D)iterator.objectReferenceValue); + } + else { + EditorGUILayout.PropertyField(iterator, false); + } } so.ApplyModifiedProperties(); } + + private static Texture2D TextureField(string name, Texture2D texture) + { + GUILayout.BeginVertical(); + var style = new GUIStyle(GUI.skin.label); + style.alignment = TextAnchor.UpperCenter; + style.fixedWidth = 70; + GUILayout.Label(name, style); + var result = (Texture2D)EditorGUILayout.ObjectField(texture, typeof(Texture2D), false, GUILayout.Width(70), GUILayout.Height(70)); + GUILayout.EndVertical(); + return result; + } } } diff --git a/Scripts/Meta/VRMMetaObject.cs b/Scripts/Meta/VRMMetaObject.cs index 4c16fdb1f..d19d2f8f4 100644 --- a/Scripts/Meta/VRMMetaObject.cs +++ b/Scripts/Meta/VRMMetaObject.cs @@ -1,6 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; namespace VRM @@ -9,7 +7,7 @@ namespace VRM { #region Info [SerializeField, Header("Information")] - public string Title; + public string Version; [SerializeField] public string Author; @@ -18,14 +16,31 @@ namespace VRM public string ContactInformation; [SerializeField] - public Texture2D Thumbnail; + public string Reference; [SerializeField] - public string Reference; + public string Title; + + [SerializeField] + public Texture2D Thumbnail; + #endregion + + #region Permission + [SerializeField, Header("Permission")] + public AllowedUser allowedUser; + + [SerializeField] + public bool allowImmoralUssage; + [SerializeField] + public bool allowCcertainBeliefsUssage; + [SerializeField] + public bool allowPoliticalUssage; + [SerializeField] + public bool allowCommercialUssage; #endregion #region License - [SerializeField, Header("License")] + [SerializeField, Header("Distribution License")] public LicenseType LicenseType; [SerializeField]