update License

This commit is contained in:
ousttrue 2018-04-06 21:46:15 +09:00
parent c3ea3c3db1
commit 83dea51fac
6 changed files with 171 additions and 65 deletions

View File

@ -167,21 +167,36 @@ namespace VRM
// meta
{
var _meta = exporter.Copy.GetComponent<VRMMeta>();
if (_meta != null && _meta.Meta!=null)
if (_meta != null && _meta.Meta != null)
{
var meta = _meta.Meta;
// info
gltf.extensions.VRM.meta.version = meta.Version;
gltf.extensions.VRM.meta.author = meta.Author;
gltf.extensions.VRM.meta.contactInformation = meta.ContactInformation;
gltf.extensions.VRM.meta.reference = meta.Reference;
gltf.extensions.VRM.meta.title = meta.Title;
if (meta.Thumbnail != null)
{
gltf.extensions.VRM.meta.texture = gltfExporter.ExportTexture(gltf, gltf.buffers.Count - 1, meta.Thumbnail);
}
// ussage pemission
gltf.extensions.VRM.meta.allowedUser = meta.AllowedUser;
gltf.extensions.VRM.meta.violentUssage = meta.ViolentUssage;
gltf.extensions.VRM.meta.sexualUssage = meta.ViolentUssage;
gltf.extensions.VRM.meta.commercialUssage = meta.ViolentUssage;
gltf.extensions.VRM.meta.otherPermissionUrl = meta.OtherPermissionUrl;
// distribution license
gltf.extensions.VRM.meta.licenseType = meta.LicenseType;
gltf.extensions.VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl;
gltf.extensions.VRM.meta.reference = meta.Reference;
if (meta.LicenseType == LicenseType.Other)
{
gltf.extensions.VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl;
}
}
}
}
// firstPerson
var firstPerson = exporter.Copy.GetComponent<VRMFirstPerson>();

View File

@ -38,17 +38,27 @@ namespace VRM
{
var meta=ScriptableObject.CreateInstance<VRMMetaObject>();
meta.name = "Meta";
var gltfMeta = VRM.extensions.VRM.meta;
meta.Version = gltfMeta.version;
meta.Author = gltfMeta.author;
meta.ContactInformation = gltfMeta.contactInformation;
meta.Reference = gltfMeta.reference;
meta.Title = gltfMeta.title;
if (gltfMeta.texture != -1)
{
meta.Thumbnail = Textures[gltfMeta.texture].Texture;
}
meta.AllowedUser = gltfMeta.allowedUser;
meta.ViolentUssage = gltfMeta.violentUssage;
meta.SexualUssage = gltfMeta.sexualUssage;
meta.CommercialUssage = gltfMeta.commercialUssage;
meta.OtherPermissionUrl = gltfMeta.otherPermissionUrl;
meta.LicenseType = gltfMeta.licenseType;
meta.OtherLicenseUrl = gltfMeta.otherLicenseUrl;
meta.Reference = gltfMeta.reference;
return meta;
}

View File

@ -4,11 +4,11 @@ namespace VRM
public static class VRMVersion
{
public const int MAJOR = 0;
public const int MINOR = 16;
public const int MINOR = 17;
public const string VERSION = "0.16";
public const string VERSION = "0.17";
public const string DecrementMenuName = "VRM/Version(0.16) Decrement";
public const string IncrementMenuName = "VRM/Version(0.16) Increment";
public const string DecrementMenuName = "VRM/Version(0.17) Decrement";
public const string IncrementMenuName = "VRM/Version(0.17) Increment";
}
}

View File

@ -7,14 +7,13 @@ namespace VRM
public enum AllowedUser
{
OnlyAuthor,
ExplicitlyLicensedPerson,
Everyone,
}
public enum LicenseType
{
RedistributionProhibited,
Redistribution_Prohibited,
CC0,
CC_BY,
CC_BY_NC,
@ -22,24 +21,37 @@ namespace VRM
CC_BY_NC_SA,
CC_BY_ND,
CC_BY_NC_ND,
Other
}
public enum UssageLicense
{
Disallow,
Allow,
}
[Serializable]
public class glTF_VRM_Meta : JsonSerializableBase
{
static UssageLicense FromString(string src)
{
try
{
return (UssageLicense)Enum.Parse(typeof(UssageLicense), src, true);
}
catch (Exception)
{
return UssageLicense.Disallow;
}
}
public string version;
public string author;
public string contactInformation;
public string reference;
public string title;
public int texture = -1;
#region PersonationCharacterizationPermission Permission;
#region Ussage Permission
public string allowedUserName;
public AllowedUser allowedUser
{
@ -59,11 +71,25 @@ namespace VRM
allowedUserName = value.ToString();
}
}
public bool allowImmoralUssage;
public bool allowCcertainBeliefsUssage;
public bool allowPoliticalUssage;
public bool allowCommercialUssage;
public string violentUssageName;
public UssageLicense violentUssage
{
get { return FromString(violentUssageName); }
set { violentUssageName = value.ToString(); }
}
public string sexualUssageName;
public UssageLicense sexualUssage
{
get { return FromString(sexualUssageName); }
set { sexualUssageName = value.ToString(); }
}
public string commercialUssageName;
public UssageLicense commercialUssage
{
get { return FromString(commercialUssageName); }
set { commercialUssageName = value.ToString(); }
}
public string otherPermissionUrl;
#endregion
#region Distribution License
@ -101,10 +127,10 @@ namespace VRM
f.KeyValue(() => texture);
f.KeyValue(() => allowedUserName);
f.KeyValue(() => allowImmoralUssage);
f.KeyValue(() => allowCcertainBeliefsUssage);
f.KeyValue(() => allowPoliticalUssage);
f.KeyValue(() => allowCommercialUssage);
f.KeyValue(() => violentUssageName);
f.KeyValue(() => sexualUssageName);
f.KeyValue(() => commercialUssageName);
f.KeyValue(() => otherPermissionUrl);
f.KeyValue(() => licenseName);
f.KeyValue(() => otherLicenseUrl);

View File

@ -1,4 +1,5 @@
using UnityEditor;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@ -7,11 +8,42 @@ namespace VRM
[CustomEditor(typeof(VRMMeta))]
public class VRMMetaEditor : Editor
{
//VRMMeta m_target;
SerializedProperty m_ScriptProp;
SerializedProperty m_VRMMetaObjectProp;
SerializedProperty VRMMetaObjectProp
{
get { return m_VRMMetaObjectProp; }
set
{
if (m_VRMMetaObjectProp == value) return;
m_VRMMetaObjectProp = value;
// get props
Debug.Log("clear");
m_propMap.Clear();
}
}
Dictionary<string, SerializedProperty> m_propMap = new Dictionary<string, SerializedProperty>();
void InitMap(SerializedObject so)
{
if (VRMMetaObjectProp == null) return;
//if (m_propMap.Count > 0) return;
m_propMap.Clear();
for (var it = so.GetIterator(); it.NextVisible(true);)
{
if (it.name == "m_Script") continue;
//Debug.LogFormat("{0}", it.name);
m_propMap.Add(it.name, so.FindProperty(it.name));
}
}
private void OnEnable()
{
//m_target = (VRMMeta)target;
m_ScriptProp = serializedObject.FindProperty("m_Script");
m_VRMMetaObjectProp = serializedObject.FindProperty("Meta");
}
@ -19,49 +51,67 @@ namespace VRM
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField(m_ScriptProp, true);
EditorGUILayout.PropertyField(m_VRMMetaObjectProp, true);
serializedObject.ApplyModifiedProperties();
EditorGUILayout.Space();
#if true
if (m_VRMMetaObjectProp.objectReferenceValue != null)
{
VRMMetaObjectGUI(new SerializedObject(m_VRMMetaObjectProp.objectReferenceValue));
}
serializedObject.ApplyModifiedProperties();
#else
if(m_target!=null && m_target.Meta != null)
{
VRMMetaObjectGUI(new SerializedObject(m_target.Meta));
}
#endif
}
bool m_foldoutInfo = true;
bool m_foldoutPersmission=true;
bool m_foldoutDistribution=true;
void VRMMetaObjectGUI(SerializedObject so)
{
InitMap(so);
if (m_propMap == null || m_propMap.Count==0) return;
so.Update();
int i = 0;
for (SerializedProperty iterator = so.GetIterator();
iterator.NextVisible(true);
++i
)
m_foldoutInfo = EditorGUILayout.Foldout(m_foldoutInfo, "Information");
if (m_foldoutInfo)
{
if (i == 0) continue;
/*
Debug.LogFormat("{0}: {1}({2}) = {3}",
iterator.depth,
iterator.name,
iterator.displayName,
iterator.propertyType
);
*/
if (iterator.name == "Thumbnail")
{
iterator.objectReferenceValue=TextureField(iterator.name, (Texture2D)iterator.objectReferenceValue, 100);
}
else {
EditorGUILayout.PropertyField(iterator, false);
}
EditorGUILayout.PropertyField(m_propMap["Version"]);
EditorGUILayout.PropertyField(m_propMap["Author"]);
EditorGUILayout.PropertyField(m_propMap["ContactInformation"]);
EditorGUILayout.PropertyField(m_propMap["Reference"]);
EditorGUILayout.PropertyField(m_propMap["Title"]);
var thumbnail = m_propMap["Thumbnail"];
thumbnail.objectReferenceValue = TextureField("", (Texture2D)thumbnail.objectReferenceValue, 100);
}
m_foldoutPersmission = EditorGUILayout.Foldout(m_foldoutPersmission, "Personation / Characterization Permission");
if (m_foldoutPersmission)
{
EditorGUILayout.PropertyField(m_propMap["AllowedUser"], new GUIContent("A person who can perform with this avatar"), false);
EditorGUILayout.PropertyField(m_propMap["ViolentUssage"], new GUIContent("Violent acts using this avatar"));
EditorGUILayout.PropertyField(m_propMap["SexualUssage"], new GUIContent("Sexuality acts using this avatar"));
EditorGUILayout.PropertyField(m_propMap["CommercialUssage"], new GUIContent("For commercial use"));
EditorGUILayout.PropertyField(m_propMap["OtherPermissionUrl"], new GUIContent("Other License Url"));
}
m_foldoutDistribution = EditorGUILayout.Foldout(m_foldoutDistribution, "Redistribution / Modifications License");
if (m_foldoutDistribution)
{
var licenseType = m_propMap["LicenseType"];
EditorGUILayout.PropertyField(licenseType);
if ((LicenseType)licenseType.intValue == LicenseType.Other)
{
EditorGUILayout.PropertyField(m_propMap["OtherLicenseUrl"]);
}
}
so.ApplyModifiedProperties();
}

View File

@ -6,7 +6,7 @@ namespace VRM
public class VRMMetaObject : ScriptableObject
{
#region Info
[SerializeField, Header("Information")]
[SerializeField]
public string Version;
[SerializeField]
@ -26,27 +26,31 @@ namespace VRM
#endregion
#region Permission
[SerializeField, Header("Permission")]
public AllowedUser allowedUser;
[SerializeField, Tooltip("A person who can perform with this avatar")]
public AllowedUser AllowedUser;
[SerializeField]
public bool allowImmoralUssage;
[SerializeField]
public bool allowCcertainBeliefsUssage;
[SerializeField]
public bool allowPoliticalUssage;
[SerializeField]
public bool allowCommercialUssage;
[SerializeField, Tooltip("Violent acts using this avatar")]
public UssageLicense ViolentUssage;
[SerializeField, Tooltip("Sexuality acts using this avatar")]
public UssageLicense SexualUssage;
[SerializeField, Tooltip("For commercial use")]
public UssageLicense CommercialUssage;
[SerializeField, Tooltip("Other License Url")]
public string OtherPermissionUrl;
#endregion
#region License
[SerializeField, Header("Distribution License")]
#region Distribution License
[SerializeField]
public LicenseType LicenseType;
[SerializeField]
public string OtherLicenseUrl;
#endregion
/*
public bool Equals(VRMMetaObject other)
{
return
@ -55,5 +59,6 @@ namespace VRM
&& UniGLTF.MonoBehaviourComparator.AssetAreEquals(Thumbnail, other.Thumbnail)
;
}
*/
}
}