mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-26 12:55:18 -05:00
add VRMMeta
This commit is contained in:
@@ -8,8 +8,8 @@ public static class VRMMonoBehaviourComparator
|
||||
public static bool AssertAreEquals(GameObject l, GameObject r)
|
||||
{
|
||||
return
|
||||
AssertAreEquals<VRMMetaInformation>(l, r,
|
||||
(x, y) => x[0].Equals(y[0]))
|
||||
AssertAreEquals<VRMMeta>(l, r,
|
||||
(x, y) => x[0].Meta.Equals(y[0].Meta))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
#if false
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -210,3 +211,4 @@ namespace VRM
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -147,21 +147,41 @@ namespace VRM
|
||||
});
|
||||
}
|
||||
|
||||
// meta
|
||||
var meta = exporter.Copy.GetComponent<VRMMetaInformation>();
|
||||
if (meta != null)
|
||||
// meta(obsolete)
|
||||
{
|
||||
gltf.extensions.VRM.meta.author = meta.Author;
|
||||
gltf.extensions.VRM.meta.contactInformation = meta.ContactInformation;
|
||||
gltf.extensions.VRM.meta.title = meta.Title;
|
||||
if (meta.Thumbnail != null)
|
||||
var meta = exporter.Copy.GetComponent<VRMMetaInformation>();
|
||||
if (meta != null)
|
||||
{
|
||||
gltf.extensions.VRM.meta.texture = gltfExporter.ExportTexture(gltf, gltf.buffers.Count - 1, meta.Thumbnail);
|
||||
gltf.extensions.VRM.meta.author = meta.Author;
|
||||
gltf.extensions.VRM.meta.contactInformation = meta.ContactInformation;
|
||||
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);
|
||||
}
|
||||
gltf.extensions.VRM.meta.licenseType = meta.LicenseType;
|
||||
gltf.extensions.VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl;
|
||||
gltf.extensions.VRM.meta.reference = meta.Reference;
|
||||
}
|
||||
gltf.extensions.VRM.meta.licenseType = meta.LicenseType;
|
||||
gltf.extensions.VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl;
|
||||
gltf.extensions.VRM.meta.reference = meta.Reference;
|
||||
}
|
||||
// meta
|
||||
{
|
||||
var _meta = exporter.Copy.GetComponent<VRMMeta>();
|
||||
if (_meta != null && _meta.Meta!=null)
|
||||
{
|
||||
var meta = _meta.Meta;
|
||||
gltf.extensions.VRM.meta.author = meta.Author;
|
||||
gltf.extensions.VRM.meta.contactInformation = meta.ContactInformation;
|
||||
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);
|
||||
}
|
||||
gltf.extensions.VRM.meta.licenseType = meta.LicenseType;
|
||||
gltf.extensions.VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl;
|
||||
gltf.extensions.VRM.meta.reference = meta.Reference;
|
||||
}
|
||||
}
|
||||
|
||||
// firstPerson
|
||||
var firstPerson = exporter.Copy.GetComponent<VRMFirstPerson>();
|
||||
|
||||
@@ -113,13 +113,22 @@ namespace VRM
|
||||
}
|
||||
|
||||
{
|
||||
// meta
|
||||
// meta(obsolete)
|
||||
var src = go.GetComponent<VRMMetaInformation>();
|
||||
if (src != null)
|
||||
{
|
||||
src.CopyTo(root);
|
||||
}
|
||||
}
|
||||
{
|
||||
// meta
|
||||
var src = go.GetComponent<VRMMeta>();
|
||||
if (src != null)
|
||||
{
|
||||
var dst = root.AddComponent<VRMMeta>();
|
||||
dst.Meta = src.Meta;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// firstPerson
|
||||
|
||||
@@ -156,7 +156,8 @@ namespace VRM
|
||||
|
||||
static void LoadMeta(VRMImporterContext context)
|
||||
{
|
||||
var meta = context.Root.AddComponent<VRMMetaInformation>();
|
||||
var meta = ScriptableObject.CreateInstance<VRMMetaObject>();
|
||||
meta.name = "Meta";
|
||||
var gltfMeta = context.VRM.extensions.VRM.meta;
|
||||
meta.Author = gltfMeta.author;
|
||||
meta.ContactInformation = gltfMeta.contactInformation;
|
||||
@@ -172,12 +173,15 @@ namespace VRM
|
||||
var thumbnail = lookAt.CreateThumbnail();
|
||||
thumbnail.name = "thumbnail";
|
||||
meta.Thumbnail = thumbnail;
|
||||
//context.Textures.Add(new TextureItem(thumbnail));
|
||||
context.Textures.Add(new TextureItem(thumbnail));
|
||||
}
|
||||
|
||||
meta.LicenseType = gltfMeta.licenseType;
|
||||
meta.OtherLicenseUrl = gltfMeta.otherLicenseUrl;
|
||||
meta.Reference = gltfMeta.reference;
|
||||
|
||||
var _meta = context.Root.AddComponent<VRMMeta>();
|
||||
_meta.Meta = meta;
|
||||
context.Meta = meta;
|
||||
}
|
||||
|
||||
static void LoadFirstPerson(VRMImporterContext context)
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace VRM
|
||||
public UniHumanoid.AvatarDescription AvatarDescription;
|
||||
public Avatar HumanoidAvatar;
|
||||
public BlendShapeAvatar BlendShapeAvatar;
|
||||
public VRMMetaObject Meta;
|
||||
|
||||
public glTF_VRM VRM
|
||||
{
|
||||
@@ -37,6 +38,8 @@ namespace VRM
|
||||
yield return x;
|
||||
}
|
||||
}
|
||||
|
||||
yield return Meta;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
11
Scripts/Meta/VRMMeta.cs
Normal file
11
Scripts/Meta/VRMMeta.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
public class VRMMeta : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
public VRMMetaObject Meta;
|
||||
}
|
||||
}
|
||||
12
Scripts/Meta/VRMMeta.cs.meta
Normal file
12
Scripts/Meta/VRMMeta.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 690ea0146224b8b4694a1925dddeb352
|
||||
timeCreated: 1522391118
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -6,6 +6,7 @@ using UniGLTF;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
[Obsolete]
|
||||
[Serializable]
|
||||
[DisallowMultipleComponent]
|
||||
public class VRMMetaInformation : MonoBehaviour, IEquatable<VRMMetaInformation>
|
||||
|
||||
44
Scripts/Meta/VRMMetaObject.cs
Normal file
44
Scripts/Meta/VRMMetaObject.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
public class VRMMetaObject : ScriptableObject
|
||||
{
|
||||
#region Info
|
||||
[SerializeField, Header("Information")]
|
||||
public string Title;
|
||||
|
||||
[SerializeField]
|
||||
public string Author;
|
||||
|
||||
[SerializeField]
|
||||
public string ContactInformation;
|
||||
|
||||
[SerializeField]
|
||||
public Texture2D Thumbnail;
|
||||
|
||||
[SerializeField]
|
||||
public string Reference;
|
||||
#endregion
|
||||
|
||||
#region License
|
||||
[SerializeField, Header("License")]
|
||||
public LicenseType LicenseType;
|
||||
|
||||
[SerializeField]
|
||||
public string OtherLicenseUrl;
|
||||
#endregion
|
||||
|
||||
public bool Equals(VRMMetaObject other)
|
||||
{
|
||||
return
|
||||
Author == other.Author
|
||||
&& Title == other.Title
|
||||
&& UniGLTF.MonoBehaviourComparator.AssetAreEquals(Thumbnail, other.Thumbnail)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Scripts/Meta/VRMMetaObject.cs.meta
Normal file
12
Scripts/Meta/VRMMetaObject.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63b589176a34b344b9ccbee2b7e7114a
|
||||
timeCreated: 1522391129
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user