From 9356a6f7785929484402b2157e3ce54682c8c2dc Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 13 Mar 2023 15:55:49 +0900 Subject: [PATCH] copy Samples to Samples~ --- Assets/VRM/Samples~/SimpleViewer/ViewerUI.cs | 5 +- .../Samples~/VRM10RuntimeExporterSample.meta | 8 + .../RuntimeExporterSample.unity | 459 +++++++++++ .../RuntimeExporterSample.unity.meta | 8 + .../VRM10.Samples.VRM10RuntimeExporter.asmdef | 21 + ...0.Samples.VRM10RuntimeExporter.asmdef.meta | 7 + .../VRM10FileDialogForWindows.cs | 118 +++ .../VRM10FileDialogForWindows.cs.meta | 11 + .../VRM10RuntimeExporter.cs | 168 ++++ .../VRM10RuntimeExporter.cs.meta | 12 + .../VRM10FileDialogForWindows.cs.meta | 2 +- .../VRM10/Samples~/VRM10Viewer/VRM10Loaded.cs | 115 +-- .../VRM10/Samples~/VRM10Viewer/VRM10Motion.cs | 227 ++++++ .../Samples~/VRM10Viewer/VRM10Motion.cs.meta | 11 + .../Samples~/VRM10Viewer/VRM10Retarget.cs | 31 + .../VRM10Viewer/VRM10Retarget.cs.meta | 11 + .../Samples~/VRM10Viewer/VRM10Viewer.unity | 743 +++++++++++++++++- .../Samples~/VRM10Viewer/VRM10ViewerUI.cs | 159 ++-- 18 files changed, 1927 insertions(+), 189 deletions(-) create mode 100644 Assets/VRM10/Samples~/VRM10RuntimeExporterSample.meta create mode 100644 Assets/VRM10/Samples~/VRM10RuntimeExporterSample/RuntimeExporterSample.unity create mode 100644 Assets/VRM10/Samples~/VRM10RuntimeExporterSample/RuntimeExporterSample.unity.meta create mode 100644 Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10.Samples.VRM10RuntimeExporter.asmdef create mode 100644 Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10.Samples.VRM10RuntimeExporter.asmdef.meta create mode 100644 Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10FileDialogForWindows.cs create mode 100644 Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10FileDialogForWindows.cs.meta create mode 100644 Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs create mode 100644 Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs.meta create mode 100644 Assets/VRM10/Samples~/VRM10Viewer/VRM10Motion.cs create mode 100644 Assets/VRM10/Samples~/VRM10Viewer/VRM10Motion.cs.meta create mode 100644 Assets/VRM10/Samples~/VRM10Viewer/VRM10Retarget.cs create mode 100644 Assets/VRM10/Samples~/VRM10Viewer/VRM10Retarget.cs.meta diff --git a/Assets/VRM/Samples~/SimpleViewer/ViewerUI.cs b/Assets/VRM/Samples~/SimpleViewer/ViewerUI.cs index 893d31ead6..04942584aa 100644 --- a/Assets/VRM/Samples~/SimpleViewer/ViewerUI.cs +++ b/Assets/VRM/Samples~/SimpleViewer/ViewerUI.cs @@ -226,7 +226,10 @@ private void LoadMotion(string path, string source) context.Parse(path, source); context.Load(); m_src = context.Root.GetComponent(); - m_src.GetComponent().enabled = false; + if (m_src == null) + { + throw new ArgumentNullException(); + } m_loaded?.EnableBvh(m_src); } diff --git a/Assets/VRM10/Samples~/VRM10RuntimeExporterSample.meta b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample.meta new file mode 100644 index 0000000000..dea631cc6c --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 61f4d3ff38ea91949962c79cf36ac422 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/RuntimeExporterSample.unity b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/RuntimeExporterSample.unity new file mode 100644 index 0000000000..27e1252262 --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/RuntimeExporterSample.unity @@ -0,0 +1,459 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &1186819954 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1186819956} + - component: {fileID: 1186819955} + m_Layer: 0 + m_Name: VRM10RuntimeExporter + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1186819955 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1186819954} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5dc760ebc4dd80f4faf25812fbf931ce, type: 3} + m_Name: + m_EditorClassIdentifier: + m_meta: + Name: + Version: + Authors: [] + CopyrightInformation: + ContactInformation: + References: [] + ThirdPartyLicenses: + Thumbnail: {fileID: 0} + AvatarPermission: 0 + ViolentUsage: 0 + SexualUsage: 0 + CommercialUsage: 0 + PoliticalOrReligiousUsage: 0 + AntisocialOrHateUsage: 0 + CreditNotation: 0 + Redistribution: 0 + Modification: 0 + OtherLicenseUrl: +--- !u!4 &1186819956 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1186819954} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1538405295 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1538405299} + - component: {fileID: 1538405298} + - component: {fileID: 1538405297} + - component: {fileID: 1538405296} + m_Layer: 0 + m_Name: Plane + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!64 &1538405296 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1538405295} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 4 + m_Convex: 0 + m_CookingOptions: 30 + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &1538405297 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1538405295} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1538405298 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1538405295} + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1538405299 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1538405295} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1760773430 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1760773432} + - component: {fileID: 1760773431} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1760773431 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1760773430} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1760773432 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1760773430} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &2092896552 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2092896555} + - component: {fileID: 2092896554} + - component: {fileID: 2092896553} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &2092896553 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2092896552} + m_Enabled: 1 +--- !u!20 &2092896554 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2092896552} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &2092896555 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2092896552} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/RuntimeExporterSample.unity.meta b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/RuntimeExporterSample.unity.meta new file mode 100644 index 0000000000..fecf504c59 --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/RuntimeExporterSample.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8459de2b98e9aa84688fe0aad1861d62 +timeCreated: 1531915246 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10.Samples.VRM10RuntimeExporter.asmdef b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10.Samples.VRM10RuntimeExporter.asmdef new file mode 100644 index 0000000000..82076b5285 --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10.Samples.VRM10RuntimeExporter.asmdef @@ -0,0 +1,21 @@ +{ + "name": "VRM10.Samples.VRM10RuntimeExporter", + "rootNamespace": "", + "references": [ + "GUID:da3e51d19d51a544fa14d43fee843098", + "GUID:60c8346e00a8ddd4cafc5a02eceeec57", + "GUID:0aaf403bd13871a44b7127aef2695ff8", + "GUID:8d76e605759c3f64a957d63ef96ada7c", + "GUID:e47c917724578cc43b5506c17a27e9a0", + "GUID:2ef84b520212e174a94668c7a0862d3b" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10.Samples.VRM10RuntimeExporter.asmdef.meta b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10.Samples.VRM10RuntimeExporter.asmdef.meta new file mode 100644 index 0000000000..d6530b2285 --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10.Samples.VRM10RuntimeExporter.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2031d1ee1a8124243b13de4d9bde58e9 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10FileDialogForWindows.cs b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10FileDialogForWindows.cs new file mode 100644 index 0000000000..79895fe2b4 --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10FileDialogForWindows.cs @@ -0,0 +1,118 @@ +#if UNITY_STANDALONE_WIN +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +#endif + + +namespace UniVRM10.RuntimeExporterSample +{ + public static class VRM10FileDialogForWindows + { +#if UNITY_STANDALONE_WIN + #region GetOpenFileName + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public class OpenFileName + { + public int structSize = 0; + public IntPtr dlgOwner = IntPtr.Zero; + public IntPtr instance = IntPtr.Zero; + public String filter = null; + public String customFilter = null; + public int maxCustFilter = 0; + public int filterIndex = 0; + public String file = null; + public int maxFile = 0; + public String fileTitle = null; + public int maxFileTitle = 0; + public String initialDir = null; + public String title = null; + public int flags = 0; + public short fileOffset = 0; + public short fileExtension = 0; + public String defExt = null; + public IntPtr custData = IntPtr.Zero; + public IntPtr hook = IntPtr.Zero; + public String templateName = null; + public IntPtr reservedPtr = IntPtr.Zero; + public int reservedInt = 0; + public int flagsEx = 0; + } + + [DllImport("Comdlg32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)] + public static extern bool GetOpenFileName([In, Out] OpenFileName ofn); + /* + public static bool GetOpenFileName1([In, Out] OpenFileName ofn) + { + return GetOpenFileName(ofn); + } + */ + + [DllImport("Comdlg32.dll", SetLastError = true, CharSet = CharSet.Auto)] + private static extern bool GetSaveFileName([In, Out] OpenFileName ofn); + + static string Filter(params string[] filters) + { + return string.Join("\0", filters) + "\0"; + } + public static string FileDialog(string title, params string[] extensions) + { + OpenFileName ofn = new OpenFileName(); + ofn.structSize = Marshal.SizeOf(ofn); + + var filters = new List(); + filters.Add("All Files"); filters.Add("*.*"); + foreach (var ext in extensions) + { + filters.Add(ext); filters.Add("*" + ext); + } + ofn.filter = Filter(filters.ToArray()); + ofn.filterIndex = 2; + ofn.file = new string(new char[256]); + ofn.maxFile = ofn.file.Length; + ofn.fileTitle = new string(new char[64]); + ofn.maxFileTitle = ofn.fileTitle.Length; + ofn.initialDir = UnityEngine.Application.dataPath; + ofn.title = title; + //ofn.defExt = "PNG"; + ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR + if (!GetOpenFileName(ofn)) + { + return null; + } + + return ofn.file; + } + public static string SaveDialog(string title, string path) + { + var extension = Path.GetExtension(path); + OpenFileName ofn = new OpenFileName(); + ofn.structSize = Marshal.SizeOf(ofn); + ofn.filter = Filter("All Files", "*.*", extension, "*" + extension); + ofn.filterIndex = 2; + var chars = new char[256]; + var it = Path.GetFileName(path).GetEnumerator(); + for (int i = 0; i < chars.Length && it.MoveNext(); ++i) + { + chars[i] = it.Current; + } + ofn.file = new string(chars); + ofn.maxFile = ofn.file.Length; + ofn.fileTitle = new string(new char[64]); + ofn.maxFileTitle = ofn.fileTitle.Length; + ofn.initialDir = Path.GetDirectoryName(path); + ofn.title = title; + //ofn.defExt = "PNG"; + ofn.flags = 0x00000002 | 0x00000004; // OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; + if (!GetSaveFileName(ofn)) + { + return null; + } + + return ofn.file; + } + #endregion +#endif + } +} diff --git a/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10FileDialogForWindows.cs.meta b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10FileDialogForWindows.cs.meta new file mode 100644 index 0000000000..5e250cd578 --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10FileDialogForWindows.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aa442bd5bf48b664a9cf7aa4d522c4a5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs new file mode 100644 index 0000000000..17b6c9f642 --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs @@ -0,0 +1,168 @@ +using System.IO; +using UniGLTF; +using UnityEngine; +using VRMShaders; + +namespace UniVRM10.RuntimeExporterSample +{ + public class VRM10RuntimeExporter : MonoBehaviour + { + [SerializeField] + VRM10ObjectMeta m_meta = new VRM10ObjectMeta(); + + GameObject m_model; + + void OnGUI() + { + if (GUILayout.Button("Load")) + { + Load(); + } + + GUI.enabled = m_model != null; + + // if (GUILayout.Button("Add custom blend shape")) + // { + // AddBlendShapeClip(m_model); + // } + + if (GUILayout.Button("Export")) + { + Export(m_model); + } + } + + async void Load() + { +#if UNITY_STANDALONE_WIN + var path = VRM10FileDialogForWindows.FileDialog("open VRM", ".vrm"); +#elif UNITY_EDITOR + var path = UnityEditor.EditorUtility.OpenFilePanel("Open VRM", "", "vrm"); +#else + var path = Application.dataPath + "/default.vrm"; +#endif + if (string.IsNullOrEmpty(path)) + { + return; + } + + var vrm10 = await Vrm10.LoadPathAsync(path); + var loaded = vrm10.GetComponent(); + loaded.ShowMeshes(); + loaded.EnableUpdateWhenOffscreen(); + + if (m_model != null) + { + GameObject.Destroy(m_model.gameObject); + } + + m_model = loaded.gameObject; + } + + // static void AddBlendShapeClip(GameObject go) + // { + // // get or create blendshape proxy + // var proxy = go.GetComponent(); + // if (proxy == null) + // { + // proxy = go.AddComponent(); + // } + // + // // get or create blendshapeavatar + // var avatar = proxy.BlendShapeAvatar; + // if (avatar == null) + // { + // avatar = ScriptableObject.CreateInstance(); + // proxy.BlendShapeAvatar = avatar; + // } + // + // // add blendshape clip to avatar.Clips + // var clip = ScriptableObject.CreateInstance(); + // var name = $"custom#{avatar.Clips.Count}"; + // Debug.Log($"Add {name}"); + // // unity asset name + // clip.name = name; + // // vrm export name + // clip.BlendShapeName = name; + // clip.Preset = BlendShapePreset.Unknown; + // + // clip.IsBinary = false; + // clip.Values = new BlendShapeBinding[] + // { + // new BlendShapeBinding + // { + // RelativePath = "mesh/face", // target Renderer relative path from root + // Index = 0, // BlendShapeIndex in SkinnedMeshRenderer + // Weight = 75f // BlendShape weight, range is [0-100] + // }, + // }; + // clip.MaterialValues = new MaterialValueBinding[] + // { + // new MaterialValueBinding + // { + // MaterialName = "Alicia_body", // target_material_name + // ValueName = "_Color", // target_material_property_name, + // BaseValue = new Vector4(1, 1, 1, 1), // Target value when the Weight value of BlendShapeClip is 0 + // TargetValue = new Vector4(0, 0, 0, 1), // Target value when the Weight value of BlendShapeClip is 1 + // }, + // }; + // avatar.Clips.Add(clip); + // + // // done + // } + + + void Export(GameObject model) + { + //#if UNITY_STANDALONE_WIN +#if false + var path = FileDialogForWindows.SaveDialog("save VRM", Application.dataPath + "/export.vrm"); +#else + var path = Application.dataPath + "/../export.vrm"; +#endif + if (string.IsNullOrEmpty(path)) + { + return; + } + + var bytes = ExportSimple(model, m_meta); + + File.WriteAllBytes(path, bytes); + Debug.LogFormat("export to {0}", path); + } + + static byte[] ExportSimple(GameObject root, VRM10ObjectMeta meta) + { + using (var arrayManager = new NativeArrayManager()) + { + var converter = new UniVRM10.ModelExporter(); + var model = converter.Export(arrayManager, root); + + // 右手系に変換 + Debug.Log($"convert to right handed coordinate..."); + model.ConvertCoordinate(VrmLib.Coordinates.Vrm1, ignoreVrm: false); + + // export vrm-1.0 + var exporter = new UniVRM10.Vrm10Exporter(new RuntimeTextureSerializer(), new GltfExportSettings + { + + }); + exporter.Export(root, model, converter, new VrmLib.ExportArgs + { + }, meta); + + return exporter.Storage.ToGlbBytes(); + } + + // var vrm = VRMExporter.Export(new UniGLTF.GltfExportSettings(), model, new RuntimeTextureSerializer()); + // var bytes = vrm.ToGlbBytes(); + // return bytes; + throw new System.NotImplementedException(); + } + + void OnExported(UniGLTF.glTF vrm) + { + Debug.LogFormat("exported"); + } + } +} diff --git a/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs.meta b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs.meta new file mode 100644 index 0000000000..ccf67e89c9 --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10RuntimeExporterSample/VRM10RuntimeExporter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5dc760ebc4dd80f4faf25812fbf931ce +timeCreated: 1531915350 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10/Samples~/VRM10Viewer/VRM10FileDialogForWindows.cs.meta b/Assets/VRM10/Samples~/VRM10Viewer/VRM10FileDialogForWindows.cs.meta index 5e250cd578..a992ef8423 100644 --- a/Assets/VRM10/Samples~/VRM10Viewer/VRM10FileDialogForWindows.cs.meta +++ b/Assets/VRM10/Samples~/VRM10Viewer/VRM10FileDialogForWindows.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: aa442bd5bf48b664a9cf7aa4d522c4a5 +guid: e79c316c74b94c84188456df8b51b292 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/VRM10/Samples~/VRM10Viewer/VRM10Loaded.cs b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Loaded.cs index 861c2e783f..c2e2198dc5 100644 --- a/Assets/VRM10/Samples~/VRM10Viewer/VRM10Loaded.cs +++ b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Loaded.cs @@ -9,6 +9,7 @@ class Loaded : IDisposable { RuntimeGltfInstance m_instance; Vrm10Instance m_controller; + public Vrm10RuntimeControlRig ControlRig => m_controller.Runtime.ControlRig; VRM10AIUEO m_lipSync; bool m_enableLipSyncValue; @@ -69,8 +70,8 @@ public Loaded(RuntimeGltfInstance instance, Transform lookAtTarget) m_blink = instance.gameObject.AddComponent(); m_autoExpression = instance.gameObject.AddComponent(); - m_controller.LookAtTargetType = VRM10ObjectLookAt.LookAtTargetTypes.CalcYawPitchToGaze; - m_controller.Gaze = lookAtTarget; + m_controller.LookAtTargetType = VRM10ObjectLookAt.LookAtTargetTypes.SpecifiedTransform; + m_controller.LookAtTarget = lookAtTarget; } } @@ -87,115 +88,5 @@ public void Dispose() // destroy GameObject GameObject.Destroy(m_instance.gameObject); } - - /// - /// from v0.103 - /// - /// - public void UpdateControlRigExplicit(Animator src) - { - var controlRig = m_controller.Runtime.ControlRig; - - foreach (HumanBodyBones bone in CachedEnum.GetValues()) - { - if (bone == HumanBodyBones.LastBone) - { - continue; - } - - var controlRigBone = controlRig.GetBoneTransform(bone); - if (controlRigBone == null) - { - continue; - } - - var bvhBone = src.GetBoneTransform(bone); - if (bvhBone != null) - { - // set normalized pose - controlRigBone.localRotation = bvhBone.localRotation; - } - - if (bone == HumanBodyBones.Hips) - { - controlRigBone.localPosition = bvhBone.localPosition * controlRig.InitialHipsHeight; - } - } - } - - /// - /// from v0.104 - /// - public void UpdateControlRigImplicit(Animator src) - { - var dst = m_controller.GetComponent(); - - foreach (HumanBodyBones bone in CachedEnum.GetValues()) - { - if (bone == HumanBodyBones.LastBone) - { - continue; - } - - var boneTransform = dst.GetBoneTransform(bone); - if (boneTransform == null) - { - continue; - } - - var bvhBone = src.GetBoneTransform(bone); - if (bvhBone != null) - { - // set normalized pose - boneTransform.localRotation = bvhBone.localRotation; - } - - if (bone == HumanBodyBones.Hips) - { - // TODO: hips position scaling ? - boneTransform.localPosition = bvhBone.localPosition; - } - } - } - - /// - /// from v0.108 - /// - public void UpdateControlRigImplicit(UniHumanoid.Humanoid src) - { - var dst = m_controller.GetComponent(); - - foreach (HumanBodyBones bone in CachedEnum.GetValues()) - { - if (bone == HumanBodyBones.LastBone) - { - continue; - } - - var boneTransform = dst.GetBoneTransform(bone); - if (boneTransform == null) - { - continue; - } - - var bvhBone = src.GetBoneTransform(bone); - if (bvhBone != null) - { - // set normalized pose - boneTransform.localRotation = bvhBone.localRotation; - if (bone == HumanBodyBones.Hips) - { - // TODO: hips position scaling ? - boneTransform.localPosition = bvhBone.localPosition; - } - } - } - } - - public void TPoseControlRig() - { - var controlRig = m_controller.Runtime.ControlRig; - controlRig.EnforceTPose(); - } } } diff --git a/Assets/VRM10/Samples~/VRM10Viewer/VRM10Motion.cs b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Motion.cs new file mode 100644 index 0000000000..fc49d1ab1a --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Motion.cs @@ -0,0 +1,227 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using UniGLTF; +using UniHumanoid; +using UniJSON; +using UnityEngine; +using VRMShaders; + +namespace UniVRM10.VRM10Viewer +{ + public interface IMotion : IDisposable + { + (INormalizedPoseProvider, ITPoseProvider) ControlRig { get; } + void ShowBoxMan(bool enable); + } + + public class BvhMotion : IMotion + { + UniHumanoid.BvhImporterContext m_context; + public Transform Root => m_context?.Root.transform; + public SkinnedMeshRenderer m_boxMan; + public SkinnedMeshRenderer BoxMan => m_boxMan; + (INormalizedPoseProvider, ITPoseProvider) m_controlRig; + (INormalizedPoseProvider, ITPoseProvider) IMotion.ControlRig => m_controlRig; + public BvhMotion(UniHumanoid.BvhImporterContext context) + { + m_context = context; + var provider = new AnimatorPoseProvider(m_context.Root.transform, m_context.Root.GetComponent()); + m_controlRig = (provider, provider); + + // create SkinnedMesh for bone visualize + var animator = m_context.Root.GetComponent(); + m_boxMan = SkeletonMeshUtility.CreateRenderer(animator); + var material = new Material(Shader.Find("Standard")); + BoxMan.sharedMaterial = material; + var mesh = BoxMan.sharedMesh; + mesh.name = "box-man"; + } + + public static BvhMotion LoadBvhFromText(string source, string path = "tmp.bvh") + { + var context = new UniHumanoid.BvhImporterContext(); + context.Parse(path, source); + context.Load(); + return new BvhMotion(context); + } + public static BvhMotion LoadBvhFromPath(string path) + { + return LoadBvhFromText(File.ReadAllText(path), path); + } + + public void ShowBoxMan(bool enable) + { + m_boxMan.enabled = enable; + } + + public void Dispose() + { + GameObject.Destroy(m_context.Root); + } + } + + public class VrmAnimation : IMotion + { + UniGLTF.RuntimeGltfInstance m_instance; + public SkinnedMeshRenderer m_boxMan; + public SkinnedMeshRenderer BoxMan => m_boxMan; + (INormalizedPoseProvider, ITPoseProvider) m_controlRig; + (INormalizedPoseProvider, ITPoseProvider) IMotion.ControlRig => m_controlRig; + public VrmAnimation(UniGLTF.RuntimeGltfInstance instance) + { + m_instance = instance; + if (instance.GetComponent() is Animation animation) + { + animation.Play(); + } + + var humanoid = instance.gameObject.AddComponent(); + humanoid.AssignBonesFromAnimator(); + + var provider = new InitRotationPoseProvider(instance.transform, humanoid); + m_controlRig = (provider, provider); + + // create SkinnedMesh for bone visualize + var animator = instance.GetComponent(); + m_boxMan = SkeletonMeshUtility.CreateRenderer(animator); + var material = new Material(Shader.Find("Standard")); + BoxMan.sharedMaterial = material; + var mesh = BoxMan.sharedMesh; + mesh.name = "box-man"; + } + + public void ShowBoxMan(bool enable) + { + m_boxMan.enabled = enable; + } + + public void Dispose() + { + GameObject.Destroy(m_boxMan.gameObject); + } + + static int? GetNodeIndex(UniGLTF.Extensions.VRMC_vrm_animation.Humanoid humanoid, HumanBodyBones bone) + { + switch (bone) + { + case HumanBodyBones.Hips: return humanoid.HumanBones.Hips?.Node; + case HumanBodyBones.LeftUpperLeg: return humanoid.HumanBones.LeftUpperLeg?.Node; + case HumanBodyBones.RightUpperLeg: return humanoid.HumanBones.RightUpperLeg?.Node; + case HumanBodyBones.LeftLowerLeg: return humanoid.HumanBones.LeftLowerLeg?.Node; + case HumanBodyBones.RightLowerLeg: return humanoid.HumanBones.RightLowerLeg?.Node; + case HumanBodyBones.LeftFoot: return humanoid.HumanBones.LeftFoot?.Node; + case HumanBodyBones.RightFoot: return humanoid.HumanBones.RightFoot?.Node; + case HumanBodyBones.Spine: return humanoid.HumanBones.Spine?.Node; + case HumanBodyBones.Chest: return humanoid.HumanBones.Chest?.Node; + case HumanBodyBones.Neck: return humanoid.HumanBones.Neck?.Node; + case HumanBodyBones.Head: return humanoid.HumanBones.Head?.Node; + case HumanBodyBones.LeftShoulder: return humanoid.HumanBones.LeftShoulder?.Node; + case HumanBodyBones.RightShoulder: return humanoid.HumanBones.RightShoulder?.Node; + case HumanBodyBones.LeftUpperArm: return humanoid.HumanBones.LeftUpperArm?.Node; + case HumanBodyBones.RightUpperArm: return humanoid.HumanBones.RightUpperArm?.Node; + case HumanBodyBones.LeftLowerArm: return humanoid.HumanBones.LeftLowerArm?.Node; + case HumanBodyBones.RightLowerArm: return humanoid.HumanBones.RightLowerArm?.Node; + case HumanBodyBones.LeftHand: return humanoid.HumanBones.LeftHand?.Node; + case HumanBodyBones.RightHand: return humanoid.HumanBones.RightHand?.Node; + case HumanBodyBones.LeftToes: return humanoid.HumanBones.LeftToes?.Node; + case HumanBodyBones.RightToes: return humanoid.HumanBones.RightToes?.Node; + // case HumanBodyBones.LeftEye: return humanoid.HumanBones.LeftEye?.Node; + // case HumanBodyBones.RightEye: return humanoid.HumanBones.RightEye?.Node; + case HumanBodyBones.Jaw: return humanoid.HumanBones.Jaw?.Node; + case HumanBodyBones.LeftThumbProximal: return humanoid.HumanBones.LeftThumbMetacarpal?.Node; // Metacarpal + case HumanBodyBones.LeftThumbIntermediate: return humanoid.HumanBones.LeftThumbProximal?.Node; // Proximal + case HumanBodyBones.LeftThumbDistal: return humanoid.HumanBones.LeftThumbDistal?.Node; + case HumanBodyBones.LeftIndexProximal: return humanoid.HumanBones.LeftIndexProximal?.Node; + case HumanBodyBones.LeftIndexIntermediate: return humanoid.HumanBones.LeftIndexIntermediate?.Node; + case HumanBodyBones.LeftIndexDistal: return humanoid.HumanBones.LeftIndexDistal?.Node; + case HumanBodyBones.LeftMiddleProximal: return humanoid.HumanBones.LeftMiddleProximal?.Node; + case HumanBodyBones.LeftMiddleIntermediate: return humanoid.HumanBones.LeftMiddleIntermediate?.Node; + case HumanBodyBones.LeftMiddleDistal: return humanoid.HumanBones.LeftMiddleDistal?.Node; + case HumanBodyBones.LeftRingProximal: return humanoid.HumanBones.LeftRingProximal?.Node; + case HumanBodyBones.LeftRingIntermediate: return humanoid.HumanBones.LeftRingIntermediate?.Node; + case HumanBodyBones.LeftRingDistal: return humanoid.HumanBones.LeftRingDistal?.Node; + case HumanBodyBones.LeftLittleProximal: return humanoid.HumanBones.LeftLittleProximal?.Node; + case HumanBodyBones.LeftLittleIntermediate: return humanoid.HumanBones.LeftLittleIntermediate?.Node; + case HumanBodyBones.LeftLittleDistal: return humanoid.HumanBones.LeftLittleDistal?.Node; + case HumanBodyBones.RightThumbProximal: return humanoid.HumanBones.RightThumbMetacarpal?.Node; // Metacarpal + case HumanBodyBones.RightThumbIntermediate: return humanoid.HumanBones.RightThumbProximal?.Node; // Proximal + case HumanBodyBones.RightThumbDistal: return humanoid.HumanBones.RightThumbDistal?.Node; + case HumanBodyBones.RightIndexProximal: return humanoid.HumanBones.RightIndexProximal?.Node; + case HumanBodyBones.RightIndexIntermediate: return humanoid.HumanBones.RightIndexIntermediate?.Node; + case HumanBodyBones.RightIndexDistal: return humanoid.HumanBones.RightIndexDistal?.Node; + case HumanBodyBones.RightMiddleProximal: return humanoid.HumanBones.RightMiddleProximal?.Node; + case HumanBodyBones.RightMiddleIntermediate: return humanoid.HumanBones.RightMiddleIntermediate?.Node; + case HumanBodyBones.RightMiddleDistal: return humanoid.HumanBones.RightMiddleDistal?.Node; + case HumanBodyBones.RightRingProximal: return humanoid.HumanBones.RightRingProximal?.Node; + case HumanBodyBones.RightRingIntermediate: return humanoid.HumanBones.RightRingIntermediate?.Node; + case HumanBodyBones.RightRingDistal: return humanoid.HumanBones.RightRingDistal?.Node; + case HumanBodyBones.RightLittleProximal: return humanoid.HumanBones.RightLittleProximal?.Node; + case HumanBodyBones.RightLittleIntermediate: return humanoid.HumanBones.RightLittleIntermediate?.Node; + case HumanBodyBones.RightLittleDistal: return humanoid.HumanBones.RightLittleDistal?.Node; + case HumanBodyBones.UpperChest: return humanoid.HumanBones.UpperChest?.Node; + } + return default; + } + + static Dictionary GetHumanMap(GltfData data, IReadOnlyList nodes) + { + var humanMap = new Dictionary(); + + + if (data.GLTF.extensions is UniGLTF.glTFExtensionImport extensions) + { + foreach (var kv in extensions.ObjectItems()) + { + if (kv.Key.GetString() == "VRMC_vrm_animation") + { + var animation = UniGLTF.Extensions.VRMC_vrm_animation.GltfDeserializer.Deserialize(kv.Value); + foreach (HumanBodyBones bone in UniGLTF.Utils.CachedEnum.GetValues()) + { + // Debug.Log($"{bone} => {index}"); + var node = GetNodeIndex(animation.Humanoid, bone); + if (node.HasValue) + { + humanMap.Add(bone, nodes[node.Value]); + } + } + } + } + } + return humanMap; + } + + public static async Task LoadVrmAnimationFromPathAsync(string path) + { + // + // GetHumanoid Mapping + // + using (GltfData data = new AutoGltfFileParser(path).Parse()) + using (var loader = new UniGLTF.ImporterContext(data)) + { + loader.InvertAxis = Axes.X; + // loader.PositionScaling = 0.01f; + var instance = await loader.LoadAsync(new ImmediateCaller()); + var humanMap = GetHumanMap(data, loader.Nodes); + if (humanMap.Count == 0) + { + throw new ArgumentException("fail to load VRMC_vrm_animation"); + } + var description = AvatarDescription.Create(humanMap); + + // + // avatar + // + var avatar = description.CreateAvatar(instance.Root.transform); + avatar.name = "Avatar"; + // AvatarDescription = description; + var animator = instance.gameObject.AddComponent(); + animator.avatar = avatar; + + return new VrmAnimation(instance); + } + } + } +} diff --git a/Assets/VRM10/Samples~/VRM10Viewer/VRM10Motion.cs.meta b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Motion.cs.meta new file mode 100644 index 0000000000..a3c573986d --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Motion.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 08f06b12436bf594b9982c6a8ec71374 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10/Samples~/VRM10Viewer/VRM10Retarget.cs b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Retarget.cs new file mode 100644 index 0000000000..2d91fb3e60 --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Retarget.cs @@ -0,0 +1,31 @@ +using UnityEngine; + +namespace UniVRM10.VRM10Viewer +{ + public static class VRM10Retarget + { + public static void Retarget((INormalizedPoseProvider Pose, ITPoseProvider TPose) source, (INormalizedPoseApplicable Pose, ITPoseProvider TPose) sink) + { + foreach (var (head, parent) in sink.TPose.EnumerateBoneParentPairs()) + { + var q = source.Pose.GetNormalizedLocalRotation(head, parent); + sink.Pose.SetNormalizedLocalRotation(head, q); + } + + // scaling hips position + var scaling = sink.TPose.GetWorldTransform(HumanBodyBones.LeftUpperLeg).Value.Translation.y / source.TPose.GetWorldTransform(HumanBodyBones.LeftUpperLeg).Value.Translation.y; + var delta = source.Pose.GetRawHipsPosition() - source.TPose.GetWorldTransform(HumanBodyBones.Hips).Value.Translation; + sink.Pose.SetRawHipsPosition(sink.TPose.GetWorldTransform(HumanBodyBones.Hips).Value.Translation + delta * scaling); + } + + public static void EnforceTPose((INormalizedPoseApplicable Pose, ITPoseProvider TPose) sink) + { + foreach (var (bone, parent) in sink.TPose.EnumerateBoneParentPairs()) + { + sink.Pose.SetNormalizedLocalRotation(bone, Quaternion.identity); + } + + sink.Pose.SetRawHipsPosition(sink.TPose.GetWorldTransform(HumanBodyBones.Hips).Value.Translation); + } + } +} diff --git a/Assets/VRM10/Samples~/VRM10Viewer/VRM10Retarget.cs.meta b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Retarget.cs.meta new file mode 100644 index 0000000000..51e773495a --- /dev/null +++ b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Retarget.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 49423dc9e9a224545a90221f41d975c8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10/Samples~/VRM10Viewer/VRM10Viewer.unity b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Viewer.unity index 15284a9298..ec6186e619 100644 --- a/Assets/VRM10/Samples~/VRM10Viewer/VRM10Viewer.unity +++ b/Assets/VRM10/Samples~/VRM10Viewer/VRM10Viewer.unity @@ -230,7 +230,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 339774397} - m_RootOrder: 11 + m_RootOrder: 13 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -394,6 +394,127 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 154330167} m_CullTransparentMesh: 0 +--- !u!1 &168425994 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 168425995} + - component: {fileID: 168425998} + - component: {fileID: 168425997} + - component: {fileID: 168425996} + m_Layer: 5 + m_Name: OpenMotion + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &168425995 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 168425994} + 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_Children: + - {fileID: 1923525315} + m_Father: {fileID: 339774397} + m_RootOrder: 2 + 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: 162, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &168425996 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 168425994} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, 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: 168425997} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &168425997 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 168425994} + 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 &168425998 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 168425994} + m_CullTransparentMesh: 0 --- !u!1 &175751362 GameObject: m_ObjectHideFlags: 0 @@ -841,7 +962,7 @@ RectTransform: m_Children: - {fileID: 800895692} m_Father: {fileID: 644517400} - m_RootOrder: 6 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -920,7 +1041,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 644517400} - m_RootOrder: 7 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1097,10 +1218,12 @@ RectTransform: m_Children: - {fileID: 1621794411} - {fileID: 2009818432} - - {fileID: 1557052150} + - {fileID: 168425995} - {fileID: 224350191} - {fileID: 1791103379} - {fileID: 1311520909} + - {fileID: 1557052150} + - {fileID: 1767706907} - {fileID: 974864191} - {fileID: 597950322} - {fileID: 935566651} @@ -1181,6 +1304,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 339774396} m_CullTransparentMesh: 0 +--- !u!1 &427963460 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 427963461} + - component: {fileID: 427963463} + - component: {fileID: 427963462} + m_Layer: 5 + m_Name: Copyright (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &427963461 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 427963460} + 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_Children: [] + m_Father: {fileID: 1434602809} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 50, y: 0} + m_SizeDelta: {x: -100, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &427963462 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 427963460} + 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: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: copyright +--- !u!222 &427963463 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 427963460} + m_CullTransparentMesh: 0 --- !u!1 &450042403 GameObject: m_ObjectHideFlags: 0 @@ -1595,7 +1797,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 339774397} - m_RootOrder: 7 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1675,7 +1877,7 @@ RectTransform: - {fileID: 154330168} - {fileID: 1954133885} m_Father: {fileID: 339774397} - m_RootOrder: 13 + m_RootOrder: 15 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1761,7 +1963,7 @@ RectTransform: - {fileID: 2010083454} - {fileID: 1081455630} m_Father: {fileID: 339774397} - m_RootOrder: 9 + m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1816,6 +2018,85 @@ MonoBehaviour: m_PersistentCalls: m_Calls: [] m_IsOn: 1 +--- !u!1 &642985707 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 642985708} + - component: {fileID: 642985710} + - component: {fileID: 642985709} + m_Layer: 5 + m_Name: Label + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &642985708 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 642985707} + 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_Children: [] + m_Father: {fileID: 1767706907} + m_RootOrder: 1 + 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 &642985709 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 642985707} + 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: ShowBoxMan +--- !u!222 &642985710 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 642985707} + m_CullTransparentMesh: 1 --- !u!1 &644517399 GameObject: m_ObjectHideFlags: 0 @@ -1850,6 +2131,7 @@ RectTransform: - {fileID: 1636340564} - {fileID: 2105159132} - {fileID: 827174941} + - {fileID: 1434602809} - {fileID: 1922159876} - {fileID: 806723449} - {fileID: 284921871} @@ -1966,7 +2248,7 @@ RectTransform: m_Children: - {fileID: 852999695} m_Father: {fileID: 644517400} - m_RootOrder: 11 + m_RootOrder: 12 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2230,7 +2512,7 @@ RectTransform: m_Children: - {fileID: 1181308132} m_Father: {fileID: 644517400} - m_RootOrder: 5 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2279,7 +2561,83 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 806723448} m_CullTransparentMesh: 0 ---- !u!1 &827174940 +--- !u!1 &826167455 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 826167456} + - component: {fileID: 826167458} + - component: {fileID: 826167457} + m_Layer: 5 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &826167456 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 826167455} + 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_Children: + - {fileID: 1987265555} + m_Father: {fileID: 1767706907} + m_RootOrder: 0 + 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 &826167457 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 826167455} + 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 &826167458 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 826167455} + m_CullTransparentMesh: 1 +--- !u!1 &827174940 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -2547,7 +2905,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 644517400} - m_RootOrder: 14 + m_RootOrder: 15 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2627,7 +2985,7 @@ RectTransform: m_Children: - {fileID: 933018278} m_Father: {fileID: 644517400} - m_RootOrder: 10 + m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2786,7 +3144,7 @@ RectTransform: m_Children: - {fileID: 1242458543} m_Father: {fileID: 644517400} - m_RootOrder: 9 + m_RootOrder: 10 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2914,7 +3272,7 @@ RectTransform: - {fileID: 175751363} - {fileID: 1904789319} m_Father: {fileID: 339774397} - m_RootOrder: 8 + m_RootOrder: 10 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -2951,7 +3309,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 339774397} - m_RootOrder: 6 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -3031,7 +3389,7 @@ RectTransform: m_Children: - {fileID: 1476033061} m_Father: {fileID: 644517400} - m_RootOrder: 15 + m_RootOrder: 16 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -3740,7 +4098,7 @@ RectTransform: m_Children: - {fileID: 1289294208} m_Father: {fileID: 644517400} - m_RootOrder: 12 + m_RootOrder: 13 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -3974,7 +4332,7 @@ RectTransform: m_Children: - {fileID: 1104290797} m_Father: {fileID: 644517400} - m_RootOrder: 16 + m_RootOrder: 17 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -4114,7 +4472,7 @@ GameObject: - component: {fileID: 1268276257} - component: {fileID: 1268276256} m_Layer: 5 - m_Name: Version + m_Name: VrmVersion m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -4623,6 +4981,86 @@ MonoBehaviour: blendDistance: 0 weight: 1 priority: 0 +--- !u!1 &1434602808 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1434602809} + - component: {fileID: 1434602811} + - component: {fileID: 1434602810} + m_Layer: 5 + m_Name: Copyright + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1434602809 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1434602808} + 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_Children: + - {fileID: 427963461} + m_Father: {fileID: 644517400} + m_RootOrder: 4 + 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: 297, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1434602810 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1434602808} + 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: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: copyright +--- !u!222 &1434602811 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1434602808} + m_CullTransparentMesh: 0 --- !u!1 &1438613463 GameObject: m_ObjectHideFlags: 0 @@ -4654,7 +5092,7 @@ RectTransform: - {fileID: 452923209} - {fileID: 2090837017} m_Father: {fileID: 339774397} - m_RootOrder: 12 + m_RootOrder: 14 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -4818,7 +5256,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 339774397} - m_RootOrder: 2 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -5076,7 +5514,7 @@ RectTransform: m_Children: - {fileID: 1322834810} m_Father: {fileID: 644517400} - m_RootOrder: 8 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -5235,7 +5673,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 644517400} - m_RootOrder: 13 + m_RootOrder: 14 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -5363,6 +5801,92 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1767669910} m_CullTransparentMesh: 0 +--- !u!1 &1767706906 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1767706907} + - component: {fileID: 1767706908} + m_Layer: 5 + m_Name: ShowBoxMan + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1767706907 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1767706906} + 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_Children: + - {fileID: 826167456} + - {fileID: 642985708} + m_Father: {fileID: 339774397} + m_RootOrder: 7 + 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: 160, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1767706908 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1767706906} + 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: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 826167457} + toggleTransition: 1 + graphic: {fileID: 1987265556} + m_Group: {fileID: 0} + onValueChanged: + m_PersistentCalls: + m_Calls: [] + m_IsOn: 1 --- !u!1 &1767738853 GameObject: m_ObjectHideFlags: 0 @@ -5394,7 +5918,7 @@ RectTransform: - {fileID: 62367395} - {fileID: 1037763549} m_Father: {fileID: 339774397} - m_RootOrder: 10 + m_RootOrder: 12 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -5563,20 +6087,21 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_version: {fileID: 1268276256} - m_open: {fileID: 2009818433} + m_openModel: {fileID: 2009818433} + m_openMotion: {fileID: 168425996} + m_showBoxMan: {fileID: 1767706908} m_enableLipSync: {fileID: 935566650} m_enableAutoBlink: {fileID: 634488422} m_enableAutoExpression: {fileID: 1767738855} m_useUrpMaterial: {fileID: 1438613465} m_useAsync: {fileID: 602093299} - m_src: {fileID: 0} m_target: {fileID: 802105000} - Root: {fileID: 0} m_motion: {fileID: 4900000, guid: 08df5151e71aed748b13547492fb8b9a, type: 3} m_texts: m_textModelTitle: {fileID: 1111491925} m_textModelVersion: {fileID: 1045380263} m_textModelAuthor: {fileID: 854014595} + m_textModelCopyright: {fileID: 427963462} m_textModelContact: {fileID: 587234270} m_textModelReference: {fileID: 1181308133} m_thumbnail: {fileID: 800895694} @@ -5863,7 +6388,7 @@ RectTransform: m_Children: - {fileID: 587234269} m_Father: {fileID: 644517400} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -5912,6 +6437,87 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1922159875} m_CullTransparentMesh: 0 +--- !u!1 &1923525314 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1923525315} + - component: {fileID: 1923525317} + - component: {fileID: 1923525316} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1923525315 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1923525314} + 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_Children: [] + m_Father: {fileID: 168425995} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1923525316 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1923525314} + 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: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 'Open Motion + +' +--- !u!222 &1923525317 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1923525314} + m_CullTransparentMesh: 0 --- !u!1 &1954133884 GameObject: m_ObjectHideFlags: 0 @@ -6061,7 +6667,9 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: Open + m_Text: 'Open Model + +' --- !u!222 &1963417401 CanvasRenderer: m_ObjectHideFlags: 0 @@ -6070,6 +6678,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1963417398} m_CullTransparentMesh: 0 +--- !u!1 &1987265554 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1987265555} + - component: {fileID: 1987265557} + - component: {fileID: 1987265556} + m_Layer: 5 + m_Name: Checkmark + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1987265555 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1987265554} + 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_Children: [] + m_Father: {fileID: 826167456} + m_RootOrder: 0 + 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 &1987265556 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1987265554} + 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 &1987265557 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1987265554} + m_CullTransparentMesh: 1 --- !u!1 &2009818431 GameObject: m_ObjectHideFlags: 0 @@ -6083,7 +6766,7 @@ GameObject: - component: {fileID: 2009818434} - component: {fileID: 2009818433} m_Layer: 5 - m_Name: Open + m_Name: OpenModel m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 diff --git a/Assets/VRM10/Samples~/VRM10Viewer/VRM10ViewerUI.cs b/Assets/VRM10/Samples~/VRM10Viewer/VRM10ViewerUI.cs index 4d8a5d34a4..187d636e71 100644 --- a/Assets/VRM10/Samples~/VRM10Viewer/VRM10ViewerUI.cs +++ b/Assets/VRM10/Samples~/VRM10Viewer/VRM10ViewerUI.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Threading; using UniGLTF; -using UniHumanoid; using UnityEngine; using UnityEngine.UI; using VRMShaders; @@ -12,12 +11,18 @@ namespace UniVRM10.VRM10Viewer { public class VRM10ViewerUI : MonoBehaviour { - [Header("UI")] [SerializeField] Text m_version = default; + [Header("UI")] [SerializeField] - Button m_open = default; + Button m_openModel = default; + + [SerializeField] + Button m_openMotion = default; + + [SerializeField] + Toggle m_showBoxMan = default; [SerializeField] Toggle m_enableLipSync = default; @@ -34,31 +39,42 @@ public class VRM10ViewerUI : MonoBehaviour [SerializeField] Toggle m_useAsync = default; - [Header("Runtime")] - [SerializeField] - Animator m_src = default; - [SerializeField] GameObject m_target = default; [SerializeField] + TextAsset m_motion; + GameObject Root = default; - [SerializeField] - TextAsset m_motion; + IMotion m_src = default; + public IMotion Motion + { + get { return m_src; } + set + { + if (m_src != null) + { + m_src.Dispose(); + } + m_src = value; + } + } private CancellationTokenSource _cancellationTokenSource; [Serializable] class TextFields { - [SerializeField, Header("Info")] + [SerializeField] Text m_textModelTitle = default; [SerializeField] Text m_textModelVersion = default; [SerializeField] Text m_textModelAuthor = default; [SerializeField] + Text m_textModelCopyright = default; + [SerializeField] Text m_textModelContact = default; [SerializeField] Text m_textModelReference = default; @@ -81,11 +97,35 @@ class TextFields [SerializeField] Text m_textDistributionOther = default; + public void Reset() + { + var texts = GameObject.FindObjectsOfType(); + m_textModelTitle = texts.First(x => x.name == "Title (1)"); + m_textModelVersion = texts.First(x => x.name == "Version (1)"); + m_textModelAuthor = texts.First(x => x.name == "Author (1)"); + m_textModelCopyright = texts.First(x => x.name == "Copyright (1)"); + m_textModelContact = texts.First(x => x.name == "Contact (1)"); + m_textModelReference = texts.First(x => x.name == "Reference (1)"); + + m_textPermissionAllowed = texts.First(x => x.name == "AllowedUser (1)"); + m_textPermissionViolent = texts.First(x => x.name == "Violent (1)"); + m_textPermissionSexual = texts.First(x => x.name == "Sexual (1)"); + m_textPermissionCommercial = texts.First(x => x.name == "Commercial (1)"); + m_textPermissionOther = texts.First(x => x.name == "Other (1)"); + + m_textDistributionLicense = texts.First(x => x.name == "LicenseType (1)"); + m_textDistributionOther = texts.First(x => x.name == "OtherLicense (1)"); + + var images = GameObject.FindObjectsOfType(); + m_thumbnail = images.First(x => x.name == "RawImage"); + } + public void Start() { m_textModelTitle.text = ""; m_textModelVersion.text = ""; m_textModelAuthor.text = ""; + m_textModelCopyright.text = ""; m_textModelContact.text = ""; m_textModelReference.text = ""; @@ -108,12 +148,13 @@ public void UpdateMeta(Texture2D thumbnail, UniGLTF.Extensions.VRMC_vrm.Meta met m_textModelTitle.text = meta.Name; m_textModelVersion.text = meta.Version; m_textModelAuthor.text = meta.Authors[0]; + m_textModelCopyright.text = meta.CopyrightInformation; m_textModelContact.text = meta.ContactInformation; if (meta.References != null && meta.References.Count > 0) { m_textModelReference.text = meta.References[0]; } - // m_textPermissionAllowed.text = meta.AllowedUser.ToString(); + m_textPermissionAllowed.text = meta.AvatarPermission.ToString(); m_textPermissionViolent.text = meta.AllowExcessivelyViolentUsage.ToString(); m_textPermissionSexual.text = meta.AllowExcessivelySexualUsage.ToString(); m_textPermissionCommercial.text = meta.CommercialUsage.ToString(); @@ -155,6 +196,16 @@ class UIFields [SerializeField] ToggleGroup ToggleMotion = default; + public void Reset() + { + var toggles = GameObject.FindObjectsOfType(); + ToggleMotionTPose = toggles.First(x => x.name == "TPose"); + ToggleMotionBVH = toggles.First(x => x.name == "BVH"); + + var groups = GameObject.FindObjectsOfType(); + ToggleMotion = groups.First(x => x.name == "_Motion_"); + } + public bool IsBvhEnabled { get => ToggleMotion.ActiveToggles().FirstOrDefault() == ToggleMotionBVH; @@ -171,17 +222,22 @@ public bool IsBvhEnabled private void Reset() { var buttons = GameObject.FindObjectsOfType