diff --git a/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter.meta b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter.meta new file mode 100644 index 000000000..1ab0d09b3 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: da380cc015227a946a8a8ccd61811b82 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10_Samples/VRM10Viewer/IMaterialImporter.cs b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/IMaterialImporter.cs similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/IMaterialImporter.cs rename to Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/IMaterialImporter.cs diff --git a/Assets/VRM10_Samples/VRM10Viewer/IMaterialImporter.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/IMaterialImporter.cs.meta similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/IMaterialImporter.cs.meta rename to Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/IMaterialImporter.cs.meta diff --git a/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/OrderedMaterialDescriptorGenerator.cs b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/OrderedMaterialDescriptorGenerator.cs new file mode 100644 index 000000000..e16f48447 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/OrderedMaterialDescriptorGenerator.cs @@ -0,0 +1,88 @@ +using System.Collections.Generic; +using UniGLTF; + +namespace UniVRM10.VRM10Viewer +{ + /// + /// Importersに格納したを順番に試行して成功したらそれを採用する。 + /// mtoon, unlit, pbr の順に試行することを想定。 + /// + public sealed class OrderedMaterialDescriptorGenerator : IMaterialDescriptorGenerator + { + public readonly List Importers = new(); + + public delegate MaterialDescriptor MakeDefaultMaterialDescriptor(string materialName); + + private readonly MakeDefaultMaterialDescriptor _makeDefault; + + /// + /// 順に TryCreateParam を実行して最初に成功したら終わる。 + /// 全て失敗したら UrpGltfDefaultMaterialImporter を実行する。 + /// 通常 vrm-1.0, unlit, pbr の順に試行する。 + /// + /// + public OrderedMaterialDescriptorGenerator(MakeDefaultMaterialDescriptor makeDefault, params IMaterialImporter[] importers) + { + _makeDefault = makeDefault; + Importers.AddRange(importers); + } + + public static OrderedMaterialDescriptorGenerator CreateCustomGenerator( + IMaterialImporter customPbr, + IMaterialImporter customMToonImporter = null) + { + + var generator = new OrderedMaterialDescriptorGenerator((new UrpGltfDefaultMaterialImporter()).CreateParam); + + // 最初にMToonの分岐 + // generator.Importers は前から順に処理します + if (customMToonImporter != null) + { + // TinyMToon(WebGL 向け) を使う例 + generator.Importers.Add(customMToonImporter); + } + else + { + // VRM10/Universal Render Pipeline/MToon10 を使う例 + generator.Importers.Add(new UrpMToonMaterialImporter()); + } + + // 次に unlit の分岐 + generator.Importers.Add(new UnlitMaterialImporter()); + + // 次に pbr の分岐 + if (customPbr != null) + { + // TinyPbr を使う例 + generator.Importers.Add(customPbr); + } + else + { + // Universal Render Pipeline/Lit を使う例 + // AlwaysIncludedShaders に登録すると、Variant が多すぎてビルドが終わらない問題があります。 + generator.Importers.Add(new UrpPbrMaterialImporter()); + } + + return generator; + } + + public MaterialDescriptor Get(GltfData data, int i) + { + foreach (var importer in Importers) + { + if (importer.TryCreateParam(data, i, out var param)) + { + return param; + } + } + // NOTE: Fallback to default material + if (Symbols.VRM_DEVELOP) + { + UniGLTFLogger.Warning($"material: {i} out of range. fallback"); + } + return GetGltfDefault(GltfMaterialImportUtils.ImportMaterialName(i, null)); + } + + public MaterialDescriptor GetGltfDefault(string materialName = null) => _makeDefault(materialName); + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/VRM10Viewer/OrderedMaterialDescriptorGenerator.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/OrderedMaterialDescriptorGenerator.cs.meta similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/OrderedMaterialDescriptorGenerator.cs.meta rename to Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/OrderedMaterialDescriptorGenerator.cs.meta diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialContext.cs b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyMToonMaterialContext.cs similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialContext.cs rename to Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyMToonMaterialContext.cs diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialContext.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyMToonMaterialContext.cs.meta similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialContext.cs.meta rename to Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyMToonMaterialContext.cs.meta diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialImporter.cs b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyMToonMaterialImporter.cs similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialImporter.cs rename to Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyMToonMaterialImporter.cs diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialImporter.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyMToonMaterialImporter.cs.meta similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/TinyMToonMaterialImporter.cs.meta rename to Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyMToonMaterialImporter.cs.meta diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialContext.cs b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyPbrMaterialContext.cs similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialContext.cs rename to Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyPbrMaterialContext.cs diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialContext.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyPbrMaterialContext.cs.meta similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialContext.cs.meta rename to Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyPbrMaterialContext.cs.meta diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialImporter.cs b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyPbrMaterialImporter.cs similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialImporter.cs rename to Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyPbrMaterialImporter.cs diff --git a/Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialImporter.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyPbrMaterialImporter.cs.meta similarity index 100% rename from Assets/VRM10_Samples/VRM10Viewer/TinyPbrMaterialImporter.cs.meta rename to Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/TinyPbrMaterialImporter.cs.meta diff --git a/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UnlitMaterialImporter.cs b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UnlitMaterialImporter.cs new file mode 100644 index 000000000..feffbc680 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UnlitMaterialImporter.cs @@ -0,0 +1,12 @@ +using UniGLTF; + +namespace UniVRM10.VRM10Viewer +{ + class UnlitMaterialImporter : IMaterialImporter + { + bool IMaterialImporter.TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc) + { + return BuiltInGltfUnlitMaterialImporter.TryCreateParam(data, i, out matDesc); + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UnlitMaterialImporter.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UnlitMaterialImporter.cs.meta new file mode 100644 index 000000000..e7c1d3ea9 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UnlitMaterialImporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f3cabd0c7193c374bbeb7db075c3479b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpMToonMaterialImporter.cs b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpMToonMaterialImporter.cs new file mode 100644 index 000000000..b0b04f5c1 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpMToonMaterialImporter.cs @@ -0,0 +1,19 @@ +using UniGLTF; + +namespace UniVRM10.VRM10Viewer +{ + /// + /// VRM10/Universal Render Pipeline/MToon10 + /// + public class UrpMToonMaterialImporter : IMaterialImporter + { + public bool TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc) + { + if (UrpVrm10MToonMaterialImporter.TryCreateParam(data, i, out matDesc)) + { + return true; + } + return false; + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpMToonMaterialImporter.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpMToonMaterialImporter.cs.meta new file mode 100644 index 000000000..0dcc56742 --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpMToonMaterialImporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c97cb941cc7451b49b9d347de508bdbd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpPbrMaterialImporter.cs b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpPbrMaterialImporter.cs new file mode 100644 index 000000000..a6df0407c --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpPbrMaterialImporter.cs @@ -0,0 +1,18 @@ +using UniGLTF; + +namespace UniVRM10.VRM10Viewer +{ + public class UrpPbrMaterialImporter : IMaterialImporter + { + public UrpGltfPbrMaterialImporter PbrMaterialImporter { get; } = new(); + + public bool TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc) + { + if (PbrMaterialImporter.TryCreateParam(data, i, out matDesc)) + { + return true; + } + return false; + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpPbrMaterialImporter.cs.meta b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpPbrMaterialImporter.cs.meta new file mode 100644 index 000000000..de35a2e2e --- /dev/null +++ b/Assets/VRM10_Samples/VRM10Viewer/MaterialImporter/UrpPbrMaterialImporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5541a21c1ccebff4e9d222a059c90c57 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10_Samples/VRM10Viewer/OrderedMaterialDescriptorGenerator.cs b/Assets/VRM10_Samples/VRM10Viewer/OrderedMaterialDescriptorGenerator.cs deleted file mode 100644 index e8d644d30..000000000 --- a/Assets/VRM10_Samples/VRM10Viewer/OrderedMaterialDescriptorGenerator.cs +++ /dev/null @@ -1,41 +0,0 @@ -using UniGLTF; - -namespace UniVRM10.VRM10Viewer -{ - public sealed class OrderedMaterialDescriptorGenerator : IMaterialDescriptorGenerator - { - private IMaterialImporter[] _importers; - - public UrpGltfDefaultMaterialImporter DefaultMaterialImporter { get; } = new(); - - /// - /// 順に TryCreateParam を実行して最初に成功したら終わる。 - /// 全て失敗したら UrpGltfDefaultMaterialImporter を実行する。 - /// 通常 vrm-1.0, unlit, pbr の順に試行する。 - /// - /// - public OrderedMaterialDescriptorGenerator(params IMaterialImporter[] importers) - { - _importers = importers; - } - - public MaterialDescriptor Get(GltfData data, int i) - { - foreach (var importer in _importers) - { - if (importer.TryCreateParam(data, i, out var param)) - { - return param; - } - } - // NOTE: Fallback to default material - if (Symbols.VRM_DEVELOP) - { - UniGLTFLogger.Warning($"material: {i} out of range. fallback"); - } - return GetGltfDefault(GltfMaterialImportUtils.ImportMaterialName(i, null)); - } - - public MaterialDescriptor GetGltfDefault(string materialName = null) => DefaultMaterialImporter.CreateParam(materialName); - } -} \ No newline at end of file diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity b/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity index dc470aae5..b78f34c9f 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity @@ -4931,6 +4931,7 @@ RectTransform: - {fileID: 1767706907} - {fileID: 1621794411} - {fileID: 731212245} + - {fileID: 358762027} - {fileID: 2009818432} - {fileID: 103723704} - {fileID: 602093298} @@ -5130,6 +5131,92 @@ MonoBehaviour: m_PersistentCalls: m_Calls: [] m_IsOn: 0 +--- !u!1 &358762026 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 358762027} + - component: {fileID: 358762028} + m_Layer: 5 + m_Name: UseCustomMToorMaterial + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &358762027 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 358762026} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 2090176800} + - {fileID: 1405688945} + m_Father: {fileID: 339774397} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &358762028 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 358762026} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9085046f02f69544eb97fd06b6048fe2, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Highlighted + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 2090176801} + toggleTransition: 1 + graphic: {fileID: 379278027} + m_Group: {fileID: 0} + onValueChanged: + m_PersistentCalls: + m_Calls: [] + m_IsOn: 0 --- !u!1 &364098868 GameObject: m_ObjectHideFlags: 0 @@ -5464,6 +5551,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 377012217} m_CullTransparentMesh: 1 +--- !u!1 &379278025 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 379278026} + - component: {fileID: 379278028} + - component: {fileID: 379278027} + m_Layer: 5 + m_Name: Checkmark + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &379278026 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 379278025} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 2090176800} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 20, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &379278027 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 379278025} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10901, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &379278028 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 379278025} + m_CullTransparentMesh: 0 --- !u!1 &381534432 GameObject: m_ObjectHideFlags: 0 @@ -5651,7 +5813,9 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: Use CustomMaterial + m_Text: 'Use CustomPbrMaterial + +' --- !u!222 &390989033 CanvasRenderer: m_ObjectHideFlags: 0 @@ -12326,7 +12490,7 @@ GameObject: - component: {fileID: 731212245} - component: {fileID: 731212246} m_Layer: 5 - m_Name: UseCustomMaterial + m_Name: UseCustomPbrMaterial m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -23821,6 +23985,87 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 28} m_Pivot: {x: 0.5, y: 1} +--- !u!1 &1405688944 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1405688945} + - component: {fileID: 1405688947} + - component: {fileID: 1405688946} + m_Layer: 5 + m_Name: Label + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1405688945 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1405688944} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 358762027} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 9, y: -0.5} + m_SizeDelta: {x: -28, y: -3} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1405688946 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1405688944} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 'Use CustomMToonMaterial + +' +--- !u!222 &1405688947 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1405688944} + m_CullTransparentMesh: 0 --- !u!1 &1406385458 GameObject: m_ObjectHideFlags: 0 @@ -30646,7 +30891,8 @@ MonoBehaviour: type: 3} m_mtoonMaterialAlphaBlend: {fileID: -876546973899608171, guid: 6b60fe85d745eda4281e3278fcb0657c, type: 3} - m_useCustomMaterial: {fileID: 731212246} + m_useCustomPbrMaterial: {fileID: 731212246} + m_useCustomMToonMaterial: {fileID: 358762028} m_openModel: {fileID: 2009818433} m_openMotion: {fileID: 168425996} m_pastePose: {fileID: 1307084564} @@ -35733,6 +35979,82 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2085434813} m_CullTransparentMesh: 1 +--- !u!1 &2090176799 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2090176800} + - component: {fileID: 2090176802} + - component: {fileID: 2090176801} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2090176800 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2090176799} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 379278026} + m_Father: {fileID: 358762027} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 10, y: -10} + m_SizeDelta: {x: 20, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2090176801 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2090176799} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &2090176802 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2090176799} + m_CullTransparentMesh: 0 --- !u!1 &2092455692 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs index 87193c97e..fdce9a9ad 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using UniGLTF; using UniGLTF.SpringBoneJobs.Blittables; using UnityEngine; +using UnityEngine.Rendering; using UnityEngine.UI; namespace UniVRM10.VRM10Viewer @@ -34,7 +35,9 @@ namespace UniVRM10.VRM10Viewer [Header("UI")] [SerializeField] - Toggle m_useCustomMaterial = default; + Toggle m_useCustomPbrMaterial = default; + [SerializeField] + Toggle m_useCustomMToonMaterial = default; [SerializeField] Button m_openModel = default; @@ -378,7 +381,8 @@ namespace UniVRM10.VRM10Viewer { var map = new ObjectMap(gameObject); Root = map.Objects["Root"]; - m_useCustomMaterial = map.Get("CustomMaterial"); + m_useCustomPbrMaterial = map.Get("CustomPbrMaterial"); + m_useCustomMToonMaterial = map.Get("CustomMToonMaterial"); m_openModel = map.Get