diff --git a/Assets/VRM/UniHumanoid.meta b/Assets/MeshUtility/UniHumanoid.meta similarity index 100% rename from Assets/VRM/UniHumanoid.meta rename to Assets/MeshUtility/UniHumanoid.meta diff --git a/Assets/VRM/UniHumanoid/Editor.meta b/Assets/MeshUtility/UniHumanoid/Editor.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Editor.meta rename to Assets/MeshUtility/UniHumanoid/Editor.meta diff --git a/Assets/VRM/UniHumanoid/Editor/BoneMappingEditor.cs b/Assets/MeshUtility/UniHumanoid/Editor/BoneMappingEditor.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/BoneMappingEditor.cs rename to Assets/MeshUtility/UniHumanoid/Editor/BoneMappingEditor.cs diff --git a/Assets/VRM/UniHumanoid/Editor/BoneMappingEditor.cs.meta b/Assets/MeshUtility/UniHumanoid/Editor/BoneMappingEditor.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/BoneMappingEditor.cs.meta rename to Assets/MeshUtility/UniHumanoid/Editor/BoneMappingEditor.cs.meta diff --git a/Assets/VRM/UniHumanoid/Editor/HumanPoseTransferEditor.cs b/Assets/MeshUtility/UniHumanoid/Editor/HumanPoseTransferEditor.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/HumanPoseTransferEditor.cs rename to Assets/MeshUtility/UniHumanoid/Editor/HumanPoseTransferEditor.cs diff --git a/Assets/VRM/UniHumanoid/Editor/HumanPoseTransferEditor.cs.meta b/Assets/MeshUtility/UniHumanoid/Editor/HumanPoseTransferEditor.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/HumanPoseTransferEditor.cs.meta rename to Assets/MeshUtility/UniHumanoid/Editor/HumanPoseTransferEditor.cs.meta diff --git a/Assets/VRM/UniHumanoid/Editor/MuscleInspectorEditor.cs b/Assets/MeshUtility/UniHumanoid/Editor/MuscleInspectorEditor.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/MuscleInspectorEditor.cs rename to Assets/MeshUtility/UniHumanoid/Editor/MuscleInspectorEditor.cs diff --git a/Assets/VRM/UniHumanoid/Editor/MuscleInspectorEditor.cs.meta b/Assets/MeshUtility/UniHumanoid/Editor/MuscleInspectorEditor.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/MuscleInspectorEditor.cs.meta rename to Assets/MeshUtility/UniHumanoid/Editor/MuscleInspectorEditor.cs.meta diff --git a/Assets/VRM/UniHumanoid/Editor/Tests.meta b/Assets/MeshUtility/UniHumanoid/Editor/Tests.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/Tests.meta rename to Assets/MeshUtility/UniHumanoid/Editor/Tests.meta diff --git a/Assets/VRM/UniHumanoid/Editor/Tests/BvhLoaderTests.cs b/Assets/MeshUtility/UniHumanoid/Editor/Tests/BvhLoaderTests.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/Tests/BvhLoaderTests.cs rename to Assets/MeshUtility/UniHumanoid/Editor/Tests/BvhLoaderTests.cs diff --git a/Assets/VRM/UniHumanoid/Editor/Tests/BvhLoaderTests.cs.meta b/Assets/MeshUtility/UniHumanoid/Editor/Tests/BvhLoaderTests.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/Tests/BvhLoaderTests.cs.meta rename to Assets/MeshUtility/UniHumanoid/Editor/Tests/BvhLoaderTests.cs.meta diff --git a/Assets/VRM/UniHumanoid/Editor/Tests/UniHumanoid.Editor.Tests.asmdef b/Assets/MeshUtility/UniHumanoid/Editor/Tests/UniHumanoid.Editor.Tests.asmdef similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/Tests/UniHumanoid.Editor.Tests.asmdef rename to Assets/MeshUtility/UniHumanoid/Editor/Tests/UniHumanoid.Editor.Tests.asmdef diff --git a/Assets/VRM/UniHumanoid/Editor/Tests/UniHumanoid.Editor.Tests.asmdef.meta b/Assets/MeshUtility/UniHumanoid/Editor/Tests/UniHumanoid.Editor.Tests.asmdef.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/Tests/UniHumanoid.Editor.Tests.asmdef.meta rename to Assets/MeshUtility/UniHumanoid/Editor/Tests/UniHumanoid.Editor.Tests.asmdef.meta diff --git a/Assets/VRM/UniHumanoid/Editor/UniHumanoid.Editor.asmdef b/Assets/MeshUtility/UniHumanoid/Editor/UniHumanoid.Editor.asmdef similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/UniHumanoid.Editor.asmdef rename to Assets/MeshUtility/UniHumanoid/Editor/UniHumanoid.Editor.asmdef diff --git a/Assets/VRM/UniHumanoid/Editor/UniHumanoid.Editor.asmdef.meta b/Assets/MeshUtility/UniHumanoid/Editor/UniHumanoid.Editor.asmdef.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/UniHumanoid.Editor.asmdef.meta rename to Assets/MeshUtility/UniHumanoid/Editor/UniHumanoid.Editor.asmdef.meta diff --git a/Assets/VRM/UniHumanoid/Editor/bvhAssetPostprocessor.cs b/Assets/MeshUtility/UniHumanoid/Editor/bvhAssetPostprocessor.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/bvhAssetPostprocessor.cs rename to Assets/MeshUtility/UniHumanoid/Editor/bvhAssetPostprocessor.cs diff --git a/Assets/VRM/UniHumanoid/Editor/bvhAssetPostprocessor.cs.meta b/Assets/MeshUtility/UniHumanoid/Editor/bvhAssetPostprocessor.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Editor/bvhAssetPostprocessor.cs.meta rename to Assets/MeshUtility/UniHumanoid/Editor/bvhAssetPostprocessor.cs.meta diff --git a/Assets/VRM/UniGLTF/LICENSE.md b/Assets/MeshUtility/UniHumanoid/LICENSE.md similarity index 100% rename from Assets/VRM/UniGLTF/LICENSE.md rename to Assets/MeshUtility/UniHumanoid/LICENSE.md diff --git a/Assets/VRM/UniHumanoid/LICENSE.md.meta b/Assets/MeshUtility/UniHumanoid/LICENSE.md.meta similarity index 100% rename from Assets/VRM/UniHumanoid/LICENSE.md.meta rename to Assets/MeshUtility/UniHumanoid/LICENSE.md.meta diff --git a/Assets/VRM/UniHumanoid/PoseModifier.meta b/Assets/MeshUtility/UniHumanoid/PoseModifier.meta similarity index 100% rename from Assets/VRM/UniHumanoid/PoseModifier.meta rename to Assets/MeshUtility/UniHumanoid/PoseModifier.meta diff --git a/Assets/VRM/UniHumanoid/PoseModifier/HandPose.cs b/Assets/MeshUtility/UniHumanoid/PoseModifier/HandPose.cs similarity index 100% rename from Assets/VRM/UniHumanoid/PoseModifier/HandPose.cs rename to Assets/MeshUtility/UniHumanoid/PoseModifier/HandPose.cs diff --git a/Assets/VRM/UniHumanoid/PoseModifier/HandPose.cs.meta b/Assets/MeshUtility/UniHumanoid/PoseModifier/HandPose.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/PoseModifier/HandPose.cs.meta rename to Assets/MeshUtility/UniHumanoid/PoseModifier/HandPose.cs.meta diff --git a/Assets/VRM/UniHumanoid/PoseModifier/HandRig.cs b/Assets/MeshUtility/UniHumanoid/PoseModifier/HandRig.cs similarity index 100% rename from Assets/VRM/UniHumanoid/PoseModifier/HandRig.cs rename to Assets/MeshUtility/UniHumanoid/PoseModifier/HandRig.cs diff --git a/Assets/VRM/UniHumanoid/PoseModifier/HandRig.cs.meta b/Assets/MeshUtility/UniHumanoid/PoseModifier/HandRig.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/PoseModifier/HandRig.cs.meta rename to Assets/MeshUtility/UniHumanoid/PoseModifier/HandRig.cs.meta diff --git a/Assets/VRM/UniHumanoid/PoseModifier/IPoseModifier.cs b/Assets/MeshUtility/UniHumanoid/PoseModifier/IPoseModifier.cs similarity index 100% rename from Assets/VRM/UniHumanoid/PoseModifier/IPoseModifier.cs rename to Assets/MeshUtility/UniHumanoid/PoseModifier/IPoseModifier.cs diff --git a/Assets/VRM/UniHumanoid/PoseModifier/IPoseModifier.cs.meta b/Assets/MeshUtility/UniHumanoid/PoseModifier/IPoseModifier.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/PoseModifier/IPoseModifier.cs.meta rename to Assets/MeshUtility/UniHumanoid/PoseModifier/IPoseModifier.cs.meta diff --git a/Assets/VRM/UniHumanoid/README.md b/Assets/MeshUtility/UniHumanoid/README.md similarity index 100% rename from Assets/VRM/UniHumanoid/README.md rename to Assets/MeshUtility/UniHumanoid/README.md diff --git a/Assets/VRM/UniHumanoid/README.md.meta b/Assets/MeshUtility/UniHumanoid/README.md.meta similarity index 100% rename from Assets/VRM/UniHumanoid/README.md.meta rename to Assets/MeshUtility/UniHumanoid/README.md.meta diff --git a/Assets/VRM/UniHumanoid/Resources.meta b/Assets/MeshUtility/UniHumanoid/Resources.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Resources.meta rename to Assets/MeshUtility/UniHumanoid/Resources.meta diff --git a/Assets/VRM/UniHumanoid/Resources/T-Pose.pose.asset b/Assets/MeshUtility/UniHumanoid/Resources/T-Pose.pose.asset similarity index 100% rename from Assets/VRM/UniHumanoid/Resources/T-Pose.pose.asset rename to Assets/MeshUtility/UniHumanoid/Resources/T-Pose.pose.asset diff --git a/Assets/VRM/UniHumanoid/Resources/T-Pose.pose.asset.meta b/Assets/MeshUtility/UniHumanoid/Resources/T-Pose.pose.asset.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Resources/T-Pose.pose.asset.meta rename to Assets/MeshUtility/UniHumanoid/Resources/T-Pose.pose.asset.meta diff --git a/Assets/VRM/UniHumanoid/Scenes.meta b/Assets/MeshUtility/UniHumanoid/Scenes.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scenes.meta rename to Assets/MeshUtility/UniHumanoid/Scenes.meta diff --git a/Assets/VRM/UniHumanoid/Scenes/HumanBuilderTest.cs b/Assets/MeshUtility/UniHumanoid/Scenes/HumanBuilderTest.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scenes/HumanBuilderTest.cs rename to Assets/MeshUtility/UniHumanoid/Scenes/HumanBuilderTest.cs diff --git a/Assets/VRM/UniHumanoid/Scenes/HumanBuilderTest.cs.meta b/Assets/MeshUtility/UniHumanoid/Scenes/HumanBuilderTest.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scenes/HumanBuilderTest.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scenes/HumanBuilderTest.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scenes/PoseTransfer.unity b/Assets/MeshUtility/UniHumanoid/Scenes/PoseTransfer.unity similarity index 100% rename from Assets/VRM/UniHumanoid/Scenes/PoseTransfer.unity rename to Assets/MeshUtility/UniHumanoid/Scenes/PoseTransfer.unity diff --git a/Assets/VRM/UniHumanoid/Scenes/PoseTransfer.unity.meta b/Assets/MeshUtility/UniHumanoid/Scenes/PoseTransfer.unity.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scenes/PoseTransfer.unity.meta rename to Assets/MeshUtility/UniHumanoid/Scenes/PoseTransfer.unity.meta diff --git a/Assets/VRM/UniHumanoid/Scenes/RuntimeBvhLoader.cs b/Assets/MeshUtility/UniHumanoid/Scenes/RuntimeBvhLoader.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scenes/RuntimeBvhLoader.cs rename to Assets/MeshUtility/UniHumanoid/Scenes/RuntimeBvhLoader.cs diff --git a/Assets/VRM/UniHumanoid/Scenes/RuntimeBvhLoader.cs.meta b/Assets/MeshUtility/UniHumanoid/Scenes/RuntimeBvhLoader.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scenes/RuntimeBvhLoader.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scenes/RuntimeBvhLoader.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scenes/RuntimeBvhLoader.unity b/Assets/MeshUtility/UniHumanoid/Scenes/RuntimeBvhLoader.unity similarity index 100% rename from Assets/VRM/UniHumanoid/Scenes/RuntimeBvhLoader.unity rename to Assets/MeshUtility/UniHumanoid/Scenes/RuntimeBvhLoader.unity diff --git a/Assets/VRM/UniHumanoid/Scenes/RuntimeBvhLoader.unity.meta b/Assets/MeshUtility/UniHumanoid/Scenes/RuntimeBvhLoader.unity.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scenes/RuntimeBvhLoader.unity.meta rename to Assets/MeshUtility/UniHumanoid/Scenes/RuntimeBvhLoader.unity.meta diff --git a/Assets/VRM/UniHumanoid/Scenes/target.mat b/Assets/MeshUtility/UniHumanoid/Scenes/target.mat similarity index 100% rename from Assets/VRM/UniHumanoid/Scenes/target.mat rename to Assets/MeshUtility/UniHumanoid/Scenes/target.mat diff --git a/Assets/VRM/UniHumanoid/Scenes/target.mat.meta b/Assets/MeshUtility/UniHumanoid/Scenes/target.mat.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scenes/target.mat.meta rename to Assets/MeshUtility/UniHumanoid/Scenes/target.mat.meta diff --git a/Assets/VRM/UniHumanoid/Scripts.meta b/Assets/MeshUtility/UniHumanoid/Scripts.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts.meta rename to Assets/MeshUtility/UniHumanoid/Scripts.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/AnimationClipUtility.cs b/Assets/MeshUtility/UniHumanoid/Scripts/AnimationClipUtility.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/AnimationClipUtility.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/AnimationClipUtility.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/AnimationClipUtility.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/AnimationClipUtility.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/AnimationClipUtility.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/AnimationClipUtility.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/AvatarDescription.cs b/Assets/MeshUtility/UniHumanoid/Scripts/AvatarDescription.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/AvatarDescription.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/AvatarDescription.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/AvatarDescription.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/AvatarDescription.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/AvatarDescription.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/AvatarDescription.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/BoneGizmoDrawer.cs b/Assets/MeshUtility/UniHumanoid/Scripts/BoneGizmoDrawer.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/BoneGizmoDrawer.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/BoneGizmoDrawer.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/BoneGizmoDrawer.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/BoneGizmoDrawer.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/BoneGizmoDrawer.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/BoneGizmoDrawer.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/BoneMapping.cs b/Assets/MeshUtility/UniHumanoid/Scripts/BoneMapping.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/BoneMapping.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/BoneMapping.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/BoneMapping.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/BoneMapping.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/BoneMapping.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/BoneMapping.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/BvhBone.cs b/Assets/MeshUtility/UniHumanoid/Scripts/BvhBone.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/BvhBone.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/BvhBone.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/BvhBone.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/BvhBone.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/BvhBone.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/BvhBone.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/Extensions.meta b/Assets/MeshUtility/UniHumanoid/Scripts/Extensions.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/Extensions.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/Extensions.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/Extensions/EnumExtensions.cs b/Assets/MeshUtility/UniHumanoid/Scripts/Extensions/EnumExtensions.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/Extensions/EnumExtensions.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/Extensions/EnumExtensions.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/Extensions/EnumExtensions.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/Extensions/EnumExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/Extensions/EnumExtensions.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/Extensions/EnumExtensions.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/Format.meta b/Assets/MeshUtility/UniHumanoid/Scripts/Format.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/Format.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/Format.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/Format/Bvh.cs b/Assets/MeshUtility/UniHumanoid/Scripts/Format/Bvh.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/Format/Bvh.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/Format/Bvh.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/Format/Bvh.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/Format/Bvh.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/Format/Bvh.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/Format/Bvh.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/HumanPoseClip.cs b/Assets/MeshUtility/UniHumanoid/Scripts/HumanPoseClip.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/HumanPoseClip.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/HumanPoseClip.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/HumanPoseClip.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/HumanPoseClip.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/HumanPoseClip.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/HumanPoseClip.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/HumanPoseTransfer.cs b/Assets/MeshUtility/UniHumanoid/Scripts/HumanPoseTransfer.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/HumanPoseTransfer.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/HumanPoseTransfer.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/HumanPoseTransfer.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/HumanPoseTransfer.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/HumanPoseTransfer.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/HumanPoseTransfer.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/IBone.cs b/Assets/MeshUtility/UniHumanoid/Scripts/IBone.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IBone.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/IBone.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/IBone.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/IBone.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IBone.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/IBone.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/IO.meta b/Assets/MeshUtility/UniHumanoid/Scripts/IO.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/IO.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/IO/BvhAnimationClip.cs b/Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhAnimationClip.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO/BvhAnimationClip.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhAnimationClip.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/IO/BvhAnimationClip.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhAnimationClip.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO/BvhAnimationClip.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhAnimationClip.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/IO/BvhImporter.cs b/Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhImporter.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO/BvhImporter.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhImporter.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/IO/BvhImporter.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhImporter.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO/BvhImporter.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhImporter.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/IO/BvhImporterContext.cs b/Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhImporterContext.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO/BvhImporterContext.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhImporterContext.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/IO/BvhImporterContext.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhImporterContext.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO/BvhImporterContext.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/IO/BvhImporterContext.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/IO/Extensions.meta b/Assets/MeshUtility/UniHumanoid/Scripts/IO/Extensions.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO/Extensions.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/IO/Extensions.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/IO/Extensions/BvhExtensions.cs b/Assets/MeshUtility/UniHumanoid/Scripts/IO/Extensions/BvhExtensions.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO/Extensions/BvhExtensions.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/IO/Extensions/BvhExtensions.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/IO/Extensions/BvhExtensions.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/IO/Extensions/BvhExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO/Extensions/BvhExtensions.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/IO/Extensions/BvhExtensions.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/IO/Extensions/UnityExtensions.cs b/Assets/MeshUtility/UniHumanoid/Scripts/IO/Extensions/UnityExtensions.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO/Extensions/UnityExtensions.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/IO/Extensions/UnityExtensions.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/IO/Extensions/UnityExtensions.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/IO/Extensions/UnityExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/IO/Extensions/UnityExtensions.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/IO/Extensions/UnityExtensions.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/MuscleDebug.cs b/Assets/MeshUtility/UniHumanoid/Scripts/MuscleDebug.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/MuscleDebug.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/MuscleDebug.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/MuscleDebug.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/MuscleDebug.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/MuscleDebug.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/MuscleDebug.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/MuscleInspector.cs b/Assets/MeshUtility/UniHumanoid/Scripts/MuscleInspector.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/MuscleInspector.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/MuscleInspector.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/MuscleInspector.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/MuscleInspector.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/MuscleInspector.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/MuscleInspector.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/Skeleton.cs b/Assets/MeshUtility/UniHumanoid/Scripts/Skeleton.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/Skeleton.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/Skeleton.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/Skeleton.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/Skeleton.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/Skeleton.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/Skeleton.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/SkeletonEstimator.cs b/Assets/MeshUtility/UniHumanoid/Scripts/SkeletonEstimator.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/SkeletonEstimator.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/SkeletonEstimator.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/SkeletonEstimator.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/SkeletonEstimator.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/SkeletonEstimator.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/SkeletonEstimator.cs.meta diff --git a/Assets/VRM/UniHumanoid/Scripts/SkeletonMeshUtility.cs b/Assets/MeshUtility/UniHumanoid/Scripts/SkeletonMeshUtility.cs similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/SkeletonMeshUtility.cs rename to Assets/MeshUtility/UniHumanoid/Scripts/SkeletonMeshUtility.cs diff --git a/Assets/VRM/UniHumanoid/Scripts/SkeletonMeshUtility.cs.meta b/Assets/MeshUtility/UniHumanoid/Scripts/SkeletonMeshUtility.cs.meta similarity index 100% rename from Assets/VRM/UniHumanoid/Scripts/SkeletonMeshUtility.cs.meta rename to Assets/MeshUtility/UniHumanoid/Scripts/SkeletonMeshUtility.cs.meta diff --git a/Assets/VRM/UniHumanoid/UniHumanoid.asmdef b/Assets/MeshUtility/UniHumanoid/UniHumanoid.asmdef similarity index 100% rename from Assets/VRM/UniHumanoid/UniHumanoid.asmdef rename to Assets/MeshUtility/UniHumanoid/UniHumanoid.asmdef diff --git a/Assets/VRM/UniHumanoid/UniHumanoid.asmdef.meta b/Assets/MeshUtility/UniHumanoid/UniHumanoid.asmdef.meta similarity index 100% rename from Assets/VRM/UniHumanoid/UniHumanoid.asmdef.meta rename to Assets/MeshUtility/UniHumanoid/UniHumanoid.asmdef.meta diff --git a/Assets/VRM/UniHumanoid/doc.meta b/Assets/MeshUtility/UniHumanoid/doc.meta similarity index 100% rename from Assets/VRM/UniHumanoid/doc.meta rename to Assets/MeshUtility/UniHumanoid/doc.meta diff --git a/Assets/VRM/UniHumanoid/doc/BoneMappingGizmo.png b/Assets/MeshUtility/UniHumanoid/doc/BoneMappingGizmo.png similarity index 100% rename from Assets/VRM/UniHumanoid/doc/BoneMappingGizmo.png rename to Assets/MeshUtility/UniHumanoid/doc/BoneMappingGizmo.png diff --git a/Assets/VRM/UniHumanoid/doc/BoneMappingGizmo.png.meta b/Assets/MeshUtility/UniHumanoid/doc/BoneMappingGizmo.png.meta similarity index 100% rename from Assets/VRM/UniHumanoid/doc/BoneMappingGizmo.png.meta rename to Assets/MeshUtility/UniHumanoid/doc/BoneMappingGizmo.png.meta diff --git a/Assets/VRM/UniHumanoid/doc/BoneMappingInspector.png b/Assets/MeshUtility/UniHumanoid/doc/BoneMappingInspector.png similarity index 100% rename from Assets/VRM/UniHumanoid/doc/BoneMappingInspector.png rename to Assets/MeshUtility/UniHumanoid/doc/BoneMappingInspector.png diff --git a/Assets/VRM/UniHumanoid/doc/BoneMappingInspector.png.meta b/Assets/MeshUtility/UniHumanoid/doc/BoneMappingInspector.png.meta similarity index 100% rename from Assets/VRM/UniHumanoid/doc/BoneMappingInspector.png.meta rename to Assets/MeshUtility/UniHumanoid/doc/BoneMappingInspector.png.meta diff --git a/Assets/VRM/UniHumanoid/doc/assets.png b/Assets/MeshUtility/UniHumanoid/doc/assets.png similarity index 100% rename from Assets/VRM/UniHumanoid/doc/assets.png rename to Assets/MeshUtility/UniHumanoid/doc/assets.png diff --git a/Assets/VRM/UniHumanoid/doc/assets.png.meta b/Assets/MeshUtility/UniHumanoid/doc/assets.png.meta similarity index 100% rename from Assets/VRM/UniHumanoid/doc/assets.png.meta rename to Assets/MeshUtility/UniHumanoid/doc/assets.png.meta diff --git a/Assets/VRM/UniHumanoid/doc/bvh_bonemapping.png b/Assets/MeshUtility/UniHumanoid/doc/bvh_bonemapping.png similarity index 100% rename from Assets/VRM/UniHumanoid/doc/bvh_bonemapping.png rename to Assets/MeshUtility/UniHumanoid/doc/bvh_bonemapping.png diff --git a/Assets/VRM/UniHumanoid/doc/bvh_bonemapping.png.meta b/Assets/MeshUtility/UniHumanoid/doc/bvh_bonemapping.png.meta similarity index 100% rename from Assets/VRM/UniHumanoid/doc/bvh_bonemapping.png.meta rename to Assets/MeshUtility/UniHumanoid/doc/bvh_bonemapping.png.meta diff --git a/Assets/VRM/UniHumanoid/doc/bvh_gameobject.png b/Assets/MeshUtility/UniHumanoid/doc/bvh_gameobject.png similarity index 100% rename from Assets/VRM/UniHumanoid/doc/bvh_gameobject.png rename to Assets/MeshUtility/UniHumanoid/doc/bvh_gameobject.png diff --git a/Assets/VRM/UniHumanoid/doc/bvh_gameobject.png.meta b/Assets/MeshUtility/UniHumanoid/doc/bvh_gameobject.png.meta similarity index 100% rename from Assets/VRM/UniHumanoid/doc/bvh_gameobject.png.meta rename to Assets/MeshUtility/UniHumanoid/doc/bvh_gameobject.png.meta diff --git a/Assets/VRM/UniHumanoid/doc/bvh_prefab.png b/Assets/MeshUtility/UniHumanoid/doc/bvh_prefab.png similarity index 100% rename from Assets/VRM/UniHumanoid/doc/bvh_prefab.png rename to Assets/MeshUtility/UniHumanoid/doc/bvh_prefab.png diff --git a/Assets/VRM/UniHumanoid/doc/bvh_prefab.png.meta b/Assets/MeshUtility/UniHumanoid/doc/bvh_prefab.png.meta similarity index 100% rename from Assets/VRM/UniHumanoid/doc/bvh_prefab.png.meta rename to Assets/MeshUtility/UniHumanoid/doc/bvh_prefab.png.meta diff --git a/Assets/VRM/UniHumanoid/doc/humanoid.gif b/Assets/MeshUtility/UniHumanoid/doc/humanoid.gif similarity index 100% rename from Assets/VRM/UniHumanoid/doc/humanoid.gif rename to Assets/MeshUtility/UniHumanoid/doc/humanoid.gif diff --git a/Assets/VRM/UniHumanoid/doc/humanoid.gif.meta b/Assets/MeshUtility/UniHumanoid/doc/humanoid.gif.meta similarity index 100% rename from Assets/VRM/UniHumanoid/doc/humanoid.gif.meta rename to Assets/MeshUtility/UniHumanoid/doc/humanoid.gif.meta diff --git a/Assets/VRM/UniHumanoid/doc/humanpose_transfer.png b/Assets/MeshUtility/UniHumanoid/doc/humanpose_transfer.png similarity index 100% rename from Assets/VRM/UniHumanoid/doc/humanpose_transfer.png rename to Assets/MeshUtility/UniHumanoid/doc/humanpose_transfer.png diff --git a/Assets/VRM/UniHumanoid/doc/humanpose_transfer.png.meta b/Assets/MeshUtility/UniHumanoid/doc/humanpose_transfer.png.meta similarity index 100% rename from Assets/VRM/UniHumanoid/doc/humanpose_transfer.png.meta rename to Assets/MeshUtility/UniHumanoid/doc/humanpose_transfer.png.meta diff --git a/Assets/VRM/UniHumanoid/doc/humanpose_transfer_inspector.png b/Assets/MeshUtility/UniHumanoid/doc/humanpose_transfer_inspector.png similarity index 100% rename from Assets/VRM/UniHumanoid/doc/humanpose_transfer_inspector.png rename to Assets/MeshUtility/UniHumanoid/doc/humanpose_transfer_inspector.png diff --git a/Assets/VRM/UniHumanoid/doc/humanpose_transfer_inspector.png.meta b/Assets/MeshUtility/UniHumanoid/doc/humanpose_transfer_inspector.png.meta similarity index 100% rename from Assets/VRM/UniHumanoid/doc/humanpose_transfer_inspector.png.meta rename to Assets/MeshUtility/UniHumanoid/doc/humanpose_transfer_inspector.png.meta diff --git a/Assets/VRM/UniHumanoid/doc/mesh.png b/Assets/MeshUtility/UniHumanoid/doc/mesh.png similarity index 100% rename from Assets/VRM/UniHumanoid/doc/mesh.png rename to Assets/MeshUtility/UniHumanoid/doc/mesh.png diff --git a/Assets/VRM/UniHumanoid/doc/mesh.png.meta b/Assets/MeshUtility/UniHumanoid/doc/mesh.png.meta similarity index 100% rename from Assets/VRM/UniHumanoid/doc/mesh.png.meta rename to Assets/MeshUtility/UniHumanoid/doc/mesh.png.meta diff --git a/Assets/UniGLTF.meta b/Assets/UniGLTF.meta new file mode 100644 index 000000000..a98b2017b --- /dev/null +++ b/Assets/UniGLTF.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4502ffceb7ee07441a884e5033f953a7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniVRM/DevOnly/Editor.meta b/Assets/UniGLTF/Editor.meta similarity index 77% rename from Assets/VRM/UniVRM/DevOnly/Editor.meta rename to Assets/UniGLTF/Editor.meta index d6b1a6a2f..a4da2f93d 100644 --- a/Assets/VRM/UniVRM/DevOnly/Editor.meta +++ b/Assets/UniGLTF/Editor.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 06ab989f8674a4fadb6cc64b1becb4c4 +guid: 029873273c773e74cb950a5c2c13dc06 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/VRM/UniGLTF/Editor/UniGLTF.Editor.asmdef b/Assets/UniGLTF/Editor/UniGLTF.Editor.asmdef similarity index 82% rename from Assets/VRM/UniGLTF/Editor/UniGLTF.Editor.asmdef rename to Assets/UniGLTF/Editor/UniGLTF.Editor.asmdef index 61ff6c4bf..d1fb540d7 100644 --- a/Assets/VRM/UniGLTF/Editor/UniGLTF.Editor.asmdef +++ b/Assets/UniGLTF/Editor/UniGLTF.Editor.asmdef @@ -1,9 +1,7 @@ { "name": "UniGLTF.Editor", "references": [ - "VRM", - "ShaderProperty.Runtime", - "UniJSON" + "UniGLTF" ], "optionalUnityReferences": [], "includePlatforms": [ diff --git a/Assets/VRM/UniGLTF/Editor/UniGLTF.Editor.asmdef.meta b/Assets/UniGLTF/Editor/UniGLTF.Editor.asmdef.meta similarity index 76% rename from Assets/VRM/UniGLTF/Editor/UniGLTF.Editor.asmdef.meta rename to Assets/UniGLTF/Editor/UniGLTF.Editor.asmdef.meta index 99c08a858..9f9d919f2 100644 --- a/Assets/VRM/UniGLTF/Editor/UniGLTF.Editor.asmdef.meta +++ b/Assets/UniGLTF/Editor/UniGLTF.Editor.asmdef.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cabd88168fd8c5448ab52737c175806a +guid: 5f875fdc81c40184c8333b9d63c6ddd5 AssemblyDefinitionImporter: externalObjects: {} userData: diff --git a/Assets/UniGLTF/Editor/UniGLTF.meta b/Assets/UniGLTF/Editor/UniGLTF.meta new file mode 100644 index 000000000..8fc209831 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 49ba4a8fd4ec2da469b762ac51575175 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/ImporterMenu.cs b/Assets/UniGLTF/Editor/UniGLTF/ImporterMenu.cs similarity index 100% rename from Assets/VRM/UniGLTF/Editor/ImporterMenu.cs rename to Assets/UniGLTF/Editor/UniGLTF/ImporterMenu.cs diff --git a/Assets/VRM/UniGLTF/Editor/ImporterMenu.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/ImporterMenu.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/ImporterMenu.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/ImporterMenu.cs.meta diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization.meta new file mode 100644 index 000000000..fe9b42c1b --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6a093db8d07544d42bed3e98cef01b41 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/ArraySerialization.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ArraySerialization.cs new file mode 100644 index 000000000..4865924d8 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ArraySerialization.cs @@ -0,0 +1,82 @@ +using System; +using System.IO; + +namespace UniGLTF +{ + public class ArraySerialization : CollectionSerializationBase + { + IValueSerialization m_inner; + + public ArraySerialization(Type t, IValueSerialization inner) + { + ValueType = t; + m_inner = inner; + } + + public override void GenerateDeserializer(StreamWriter writer, string callName) + { + var itemCallName = callName + "_ITEM"; + + writer.Write(@" +public static $0 $2(ListTreeNode parsed) +{ + var value = new $1[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = $3; + } + return value; +} +" +.Replace("$0", JsonSchemaAttribute.GetTypeName(ValueType)) +.Replace("$1", m_inner.ValueType.Name) +.Replace("$2", callName) +.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "x")) +); + + if (!m_inner.IsInline) + { + m_inner.GenerateDeserializer(writer, itemCallName); + } + } + + public override string CreateSerializationCondition(string argName, JsonSchemaAttribute t) + { + int min = 0; + if (t != null) + { + min = t.MinItems; + } + + return $"{argName}!=null&&{argName}.Length>={min}"; + } + + public override void GenerateSerializer(StreamWriter writer, string callName) + { + var itemCallName = callName + "_ITEM"; + writer.Write($@" +public static void {callName}(JsonFormatter f, {m_inner.ValueType.Name}[] value) +{{ + f.BeginList(); + + foreach(var item in value) + {{ + " +); + + writer.Write($"{m_inner.GenerateSerializerCall(itemCallName, "item")};\n"); + + writer.Write(@" + } + f.EndList(); +} +"); + + if (!m_inner.IsInline) + { + m_inner.GenerateSerializer(writer, itemCallName); + } + } + } +} diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/CollectionSerialization.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ArraySerialization.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Serialization/CollectionSerialization.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/ArraySerialization.cs.meta diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/CollectionSerializationBase.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/CollectionSerializationBase.cs new file mode 100644 index 000000000..fe5ada3cc --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/CollectionSerializationBase.cs @@ -0,0 +1,35 @@ +using System; +using System.IO; + +namespace UniGLTF +{ + public abstract class CollectionSerializationBase : IValueSerialization + { + public Type ValueType + { + get; + protected set; + } + + public bool IsInline + { + get { return false; } + } + + public abstract void GenerateDeserializer(StreamWriter writer, string callName); + + public string GenerateDeserializerCall(string callName, string argName) + { + return $"{callName}({argName})"; + } + + public abstract string CreateSerializationCondition(string argName, JsonSchemaAttribute t); + + public abstract void GenerateSerializer(StreamWriter writer, string callName); + + public string GenerateSerializerCall(string callName, string argName) + { + return $"{callName}(f, {argName})"; + } + } +} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/SerializerTypes.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/CollectionSerializationBase.cs.meta similarity index 83% rename from Assets/VRM/UniGLTF/Scripts/Format/SerializerTypes.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/CollectionSerializationBase.cs.meta index 6ff72b756..95c784b1d 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/SerializerTypes.cs.meta +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/CollectionSerializationBase.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2b17414c7f3ba564083dbcebda778633 +guid: 52a81be56b0149144aa0836e59d9bc3b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/DeserializerGenerator.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/DeserializerGenerator.cs new file mode 100644 index 000000000..891a3e827 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/DeserializerGenerator.cs @@ -0,0 +1,60 @@ +using System.IO; +using System.Reflection; +using System.Text; +using UnityEditor; +using UnityEngine; + +namespace UniGLTF +{ + /// + /// Generate deserializer from ListTreeNode to glTF using type reflection + /// + public static class DeserializerGenerator + { + public const BindingFlags FIELD_FLAGS = BindingFlags.Instance | BindingFlags.Public; + + const string Begin = @"using UniJSON; +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace UniGLTF { + +public static class GltfDeserializer +{ + +"; + + const string End = @" +} // GltfDeserializer +} // UniGLTF +"; + + static string OutPath + { + get + { + return Path.Combine(UnityEngine.Application.dataPath, + "UniGLTF/UniGLTF/Scripts/IO/GltfDeserializer.g.cs"); + } + } + + [MenuItem(UniGLTFVersion.MENU + "/GLTF: Generate Deserializer")] + static void GenerateSerializer() + { + var info = new ObjectSerialization(typeof(glTF), "gltf", "Deserialize_"); + Debug.Log(info); + + using (var s = File.Open(OutPath, FileMode.Create)) + using (var w = new StreamWriter(s, new UTF8Encoding(false))) + { + w.Write(Begin); + info.GenerateDeserializer(w, "Deserialize"); + w.Write(End); + } + + Debug.LogFormat("write: {0}", OutPath); + UnityPath.FromFullpath(OutPath).ImportAsset(); + } + } +} diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/DeserializerGenerator.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/DeserializerGenerator.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Serialization/DeserializerGenerator.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/DeserializerGenerator.cs.meta diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/EnumSerialization.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/EnumSerialization.cs new file mode 100644 index 000000000..b95410c17 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/EnumSerialization.cs @@ -0,0 +1,79 @@ +using System; +using System.IO; + +namespace UniGLTF +{ + public class EnumSerialization : IValueSerialization + { + Type m_type; + EnumSerializationType m_serializationType; + + public Type ValueType + { + get { return m_type; } + } + + public bool IsInline + { + get { return true; } + } + + public override string ToString() + { + return ValueType.ToString(); + } + + + public EnumSerialization(Type t, EnumSerializationType serializationType) + { + m_type = t; + m_serializationType = serializationType; + } + + public void GenerateDeserializer(StreamWriter writer, string callName) + { + throw new System.NotImplementedException(); + } + + public string GenerateDeserializerCall(string callName, string argName) + { + switch (m_serializationType) + { + case EnumSerializationType.AsInt: + return string.Format("({0}){1}.GetInt32()", m_type.Name, argName); + + case EnumSerializationType.AsLowerString: + // (ProjectionType)Enum.Parse(typeof(ProjectionType), kv.Value.GetString(), true) + return $"({m_type.Name})Enum.Parse(typeof({m_type.Name}), {argName}.GetString(), true)"; + + default: + throw new NotImplementedException(); + } + } + + public string CreateSerializationCondition(string argName, JsonSchemaAttribute t) + { + return "true"; + } + + public void GenerateSerializer(StreamWriter writer, string callName) + { + throw new NotImplementedException(); + } + + public string GenerateSerializerCall(string callName, string argName) + { + switch (m_serializationType) + { + case EnumSerializationType.AsInt: + return $"f.Value((int){argName})"; + + case EnumSerializationType.AsLowerString: + return $"f.Value({argName}.ToString().ToLower())"; + + default: + throw new NotImplementedException(); + } + } + } +} diff --git a/Assets/VRM/UniGLTF/Editor/UniGLTFVersionMenu.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/EnumSerialization.cs.meta similarity index 71% rename from Assets/VRM/UniGLTF/Editor/UniGLTFVersionMenu.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/EnumSerialization.cs.meta index ce8f77c74..546a5bf9c 100644 --- a/Assets/VRM/UniGLTF/Editor/UniGLTFVersionMenu.cs.meta +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/EnumSerialization.cs.meta @@ -1,7 +1,5 @@ fileFormatVersion: 2 -guid: 49d23365a29018d4cb142227a01e662d -timeCreated: 1522130550 -licenseType: Free +guid: 135bb9bd3d924ea4abe8fc6219355a6b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/ExtensionSerialization.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ExtensionSerialization.cs new file mode 100644 index 000000000..e38592271 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ExtensionSerialization.cs @@ -0,0 +1,37 @@ +using System; +using System.IO; + +namespace UniGLTF +{ + public class ExtensionSerialization : IValueSerialization + { + public Type ValueType => typeof(object); + + public bool IsInline => true; + + public void GenerateDeserializer(StreamWriter writer, string callName) + { + throw new System.NotImplementedException(); + } + + public string GenerateDeserializerCall(string callName, string argName) + { + return $"new glTFExtensionImport({argName})"; + } + + public string CreateSerializationCondition(string argName, JsonSchemaAttribute t) + { + return $"{argName}!=null"; + } + + public void GenerateSerializer(StreamWriter writer, string callName) + { + throw new NotImplementedException(); + } + + public string GenerateSerializerCall(string callName, string argName) + { + return $"{argName}.Serialize(f)"; + } + } +} diff --git a/Assets/VRM/UniGLTF/Scripts/Extensions/JsonParserExtensions.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ExtensionSerialization.cs.meta similarity index 71% rename from Assets/VRM/UniGLTF/Scripts/Extensions/JsonParserExtensions.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/ExtensionSerialization.cs.meta index 6aa0b19a6..bd4cf7200 100644 --- a/Assets/VRM/UniGLTF/Scripts/Extensions/JsonParserExtensions.cs.meta +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ExtensionSerialization.cs.meta @@ -1,7 +1,5 @@ fileFormatVersion: 2 -guid: d0a724a200cc85b4887efa87292c6626 -timeCreated: 1515608626 -licenseType: Free +guid: 827d441621713194c88a8c94b7b1c2f0 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/FieldSerializationInfo.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/FieldSerializationInfo.cs similarity index 70% rename from Assets/VRM/UniGLTF/Editor/Serialization/FieldSerializationInfo.cs rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/FieldSerializationInfo.cs index f0236d6d4..9e9c86ffa 100644 --- a/Assets/VRM/UniGLTF/Editor/Serialization/FieldSerializationInfo.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/FieldSerializationInfo.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -26,18 +26,20 @@ namespace UniGLTF private set; } + readonly string m_prefix; + public string FunctionName { get { - return "Deserialize_" + Path + return m_prefix + Path .Replace("/", "_") .Replace("[]", "_") ; } } - JsonSchemaAttribute m_attr; + public readonly JsonSchemaAttribute Attribute; public IValueSerialization Serialization { @@ -45,32 +47,33 @@ namespace UniGLTF private set; } - public FieldSerializationInfo(FieldInfo fi, string path) + public FieldSerializationInfo(FieldInfo fi, string path, string prefix) { + m_prefix = prefix; m_fi = fi; Path = path + "/" + fi.Name; - m_attr = fi.GetCustomAttributes(true).FirstOrDefault(x => x.GetType() == typeof(JsonSchemaAttribute)) as JsonSchemaAttribute; + Attribute = fi.GetCustomAttributes(true).FirstOrDefault(x => x.GetType() == typeof(JsonSchemaAttribute)) as JsonSchemaAttribute; - Serialization = GetSerialization(m_fi.FieldType, Path, m_attr); + Serialization = GetSerialization(m_fi.FieldType, Path, Attribute, prefix); } - static IValueSerialization GetSerialization(Type t, string path, JsonSchemaAttribute attr) + static IValueSerialization GetSerialization(Type t, string path, JsonSchemaAttribute attr, string prefix) { if (t.IsArray) { return new ArraySerialization(t, - GetSerialization(t.GetElementType(), path + "[]", attr)); + GetSerialization(t.GetElementType(), path + "[]", attr, prefix)); } else if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(List<>)) { return new ListSerialization(t, - GetSerialization(t.GetGenericArguments()[0], path + "[]", attr)); + GetSerialization(t.GetGenericArguments()[0], path + "[]", attr, prefix)); } else if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Dictionary<,>) && t.GetGenericArguments()[0] == typeof(string)) { return new StringKeyDictionarySerialization(t, - GetSerialization(t.GetGenericArguments()[1], path, attr)); + GetSerialization(t.GetGenericArguments()[1], path, attr, prefix)); } // GetCollectionType(fi.FieldType, out suffix, out t); @@ -124,10 +127,14 @@ namespace UniGLTF } else if (t.IsEnum) { - return new EnumIntSerialization(t, attr.EnumSerializationType); + return new EnumSerialization(t, attr.EnumSerializationType); + } + else if (t == typeof(glTFExtension)) + { + return new ExtensionSerialization(); } - return new ObjectSerialization(t, path); + return new ObjectSerialization(t, path, prefix); } public override string ToString() @@ -136,17 +143,26 @@ namespace UniGLTF var typeName = BaseJsonSchemaAttribute.GetTypeName(m_fi.FieldType); - if (m_attr != null) - { - sb.AppendLine(string.Format("{0}: {1}", Path, m_attr.GetInfo(m_fi))); - } - else - { - sb.AppendLine(string.Format("{0}: {1}", Path, typeName)); - } + // if (m_attr != null) + // { + // sb.AppendLine(string.Format("{0}: {1}", Path, m_attr.GetInfo(m_fi))); + // } + // else + // { + // sb.AppendLine(string.Format("{0}: {1}", Path, typeName)); + // } + // sb.Append(Serialization.ToString()); + // if (m_attr != null) + // { + // sb.Append(string.Format("{0}: {1}", Path, m_attr.GetInfo(m_fi))); + // } + // else + // { + // sb.Append(string.Format("{0}: {1}", Path, typeName)); + // } + sb.Append(string.Format("{0}: {1}", Path, Serialization)); - sb.Append(Serialization.ToString()); return sb.ToString(); } } -} \ No newline at end of file +} diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/FieldSerializationInfo.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/FieldSerializationInfo.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Serialization/FieldSerializationInfo.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/FieldSerializationInfo.cs.meta diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/IValueSerialization.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/IValueSerialization.cs similarity index 58% rename from Assets/VRM/UniGLTF/Editor/Serialization/IValueSerialization.cs rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/IValueSerialization.cs index dba6d82b9..b5bccbf0d 100644 --- a/Assets/VRM/UniGLTF/Editor/Serialization/IValueSerialization.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/IValueSerialization.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; namespace UniGLTF @@ -13,5 +13,11 @@ namespace UniGLTF string GenerateDeserializerCall(string callName, string argName); void GenerateDeserializer(StreamWriter writer, string callName); + + string CreateSerializationCondition(string argName, JsonSchemaAttribute t); + + string GenerateSerializerCall(string callName, string argName); + + void GenerateSerializer(StreamWriter writer, string callName); } } diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/IValueSerialization.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/IValueSerialization.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Serialization/IValueSerialization.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/IValueSerialization.cs.meta diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/ListSerialization.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ListSerialization.cs new file mode 100644 index 000000000..a749148a0 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ListSerialization.cs @@ -0,0 +1,84 @@ +using System; +using System.IO; + +namespace UniGLTF +{ + public class ListSerialization : CollectionSerializationBase + { + IValueSerialization m_inner; + + public ListSerialization(Type t, IValueSerialization inner) + { + ValueType = t; + m_inner = inner; + } + + public override string ToString() + { + return m_inner.ToString(); + } + + public override void GenerateDeserializer(StreamWriter writer, string callName) + { + var itemCallName = callName + "_ITEM"; + writer.Write(@" +public static $0 $2(ListTreeNode parsed) +{ + var value = new List<$1>(); + foreach(var x in parsed.ArrayItems()) + { + value.Add($3); + } + return value; +}" +.Replace("$0", JsonSchemaAttribute.GetTypeName(ValueType)) +.Replace("$1", m_inner.ValueType.Name) +.Replace("$2", callName) +.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "x")) +); + + if (!m_inner.IsInline) + { + m_inner.GenerateDeserializer(writer, itemCallName); + } + } + + public override string CreateSerializationCondition(string argName, JsonSchemaAttribute t) + { + int min = 0; + if (t != null) + { + min = t.MinItems; + } + + return $"{argName}!=null&&{argName}.Count>={min}"; + } + + public override void GenerateSerializer(StreamWriter writer, string callName) + { + var itemCallName = callName + "_ITEM"; + writer.Write($@" +public static void {callName}(JsonFormatter f, List<{m_inner.ValueType.Name}> value) +{{ + f.BeginList(); + + foreach(var item in value) + {{ + " +); + + writer.Write($"{m_inner.GenerateSerializerCall(itemCallName, "item")};\n"); + + writer.Write(@" + } + f.EndList(); +} +"); + + if (!m_inner.IsInline) + { + m_inner.GenerateSerializer(writer, itemCallName); + } + } + } +} diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/ListSerialization.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ListSerialization.cs.meta new file mode 100644 index 000000000..b42f7e040 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ListSerialization.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d23c57f5d8b3314fba9c1b9de18e5e6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/ObjectSerialization.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ObjectSerialization.cs new file mode 100644 index 000000000..1b3937c51 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ObjectSerialization.cs @@ -0,0 +1,141 @@ +using System; +using System.IO; +using System.Linq; +using System.Text; + +namespace UniGLTF +{ + public class ObjectSerialization : CollectionSerializationBase + { + string m_path; + FieldSerializationInfo[] m_fsi; + + public ObjectSerialization(Type t, string path, string prefix) + { + ValueType = t; + m_path = path; + m_fsi = t.GetFields(DeserializerGenerator.FIELD_FLAGS) + .Where(x => + { + if (x.IsLiteral && !x.IsInitOnly) + { + // const + return false; + } + return true; + }) + .Select(x => + { + return new FieldSerializationInfo(x, path, prefix); + }).ToArray(); + } + + public override string ToString() + { + var sb = new StringBuilder(); + foreach (var x in m_fsi) + { + sb.Append(x.ToString() + "\n"); + } + return sb.ToString(); + } + + public override void GenerateDeserializer(StreamWriter writer, string parentName) + { + writer.Write(@" +public static $0 $2(ListTreeNode parsed) +{ + var value = new $0(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); +" +.Replace("$0", ValueType.Name) +.Replace("$2", parentName) +); + + foreach (var f in m_fsi) + { + writer.Write(@" + if(key==""$0""){ + value.$0 = $1; + continue; + } +" +.Replace("$0", f.Name) +.Replace("$1", f.Serialization.GenerateDeserializerCall(f.FunctionName, "kv.Value")) +); + } + + writer.Write(@" + } + return value; +} +"); + + foreach (var f in m_fsi) + { + if (!f.Serialization.IsInline) + { + f.Serialization.GenerateDeserializer(writer, f.FunctionName); + } + } + } + + public override string CreateSerializationCondition(string argName, JsonSchemaAttribute t) + { + return $"{argName}!=null"; + } + + /// + /// シリアライザーのコード生成 + /// + /// ObjectのFieldのみ値によって、出力するか否かの判定が必用。 + /// + /// 例: 空文字列は出力しない + /// + /// + /// + /// + public override void GenerateSerializer(StreamWriter writer, string callName) + { + writer.Write($@" +public static void {callName}(JsonFormatter f, {ValueType.Name} value) +{{ + f.BeginMap(); + +" +); + + foreach (var f in m_fsi) + { + var valueName = $"value.{f.Name}"; + var condition = ""; + if (f.Attribute != null && f.Attribute.SerializationConditions != null) + { + condition = "&&" + string.Join("&&", f.Attribute.SerializationConditions); + } + writer.Write($@" + if({f.Serialization.CreateSerializationCondition(valueName, f.Attribute)}{condition}){{ + f.Key(""{f.Name}""); + {f.Serialization.GenerateSerializerCall(f.FunctionName, valueName)}; + }} +"); + } + + writer.Write(@" + f.EndMap(); +} +"); + + foreach (var f in m_fsi) + { + if (!f.Serialization.IsInline) + { + f.Serialization.GenerateSerializer(writer, f.FunctionName); + } + } + } + } +} diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/ObjectSerialization.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/ObjectSerialization.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Serialization/ObjectSerialization.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/ObjectSerialization.cs.meta diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/PrimitiveSerialization.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/PrimitiveSerialization.cs similarity index 65% rename from Assets/VRM/UniGLTF/Editor/Serialization/PrimitiveSerialization.cs rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/PrimitiveSerialization.cs index 33d879a95..d9d61cc42 100644 --- a/Assets/VRM/UniGLTF/Editor/Serialization/PrimitiveSerialization.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/PrimitiveSerialization.cs @@ -1,4 +1,5 @@ -using System; +using System; +using System.Collections.Generic; using System.IO; namespace UniGLTF @@ -18,9 +19,60 @@ namespace UniGLTF } public abstract string GenerateDeserializerCall(string callName, string argName); + + public virtual string CreateSerializationCondition(string argName, JsonSchemaAttribute t) + { + return "true"; + } + + public void GenerateSerializer(StreamWriter writer, string callName) + { + throw new NotImplementedException(); + } + + public string GenerateSerializerCall(string callName, string argName) + { + return $"f.Value({argName})"; + } + + public override string ToString() + { + return ValueType.ToString(); + } } - public class Int8Serialization : PrimitiveSerializationBase + public abstract class NumberSerializationBase : PrimitiveSerializationBase + { + public override string CreateSerializationCondition(string argName, JsonSchemaAttribute attr) + { + if (attr == null) + { + return "true"; + } + + var sb = new List(); + if (!double.IsNaN(attr.Minimum)) + { + if (attr.ExclusiveMinimum) + { + sb.Add($"{argName}>{attr.Minimum}"); // to int + } + else + { + sb.Add($"{argName}>={attr.Minimum}"); // to int + } + } + + if (sb.Count > 0) + { + return string.Join("&&", sb); + } + + return "true"; + } + } + + public class Int8Serialization : NumberSerializationBase { public override Type ValueType { @@ -33,7 +85,7 @@ namespace UniGLTF } } - public class Int16Serialization : PrimitiveSerializationBase + public class Int16Serialization : NumberSerializationBase { public override Type ValueType { @@ -46,7 +98,7 @@ namespace UniGLTF } } - public class Int32Serialization : PrimitiveSerializationBase + public class Int32Serialization : NumberSerializationBase { public override Type ValueType { @@ -59,7 +111,7 @@ namespace UniGLTF } } - public class Int64Serialization : PrimitiveSerializationBase + public class Int64Serialization : NumberSerializationBase { public override Type ValueType { @@ -72,7 +124,7 @@ namespace UniGLTF } } - public class UInt8Serialization : PrimitiveSerializationBase + public class UInt8Serialization : NumberSerializationBase { public override Type ValueType { @@ -85,7 +137,7 @@ namespace UniGLTF } } - public class UInt16Serialization : PrimitiveSerializationBase + public class UInt16Serialization : NumberSerializationBase { public override Type ValueType { @@ -98,7 +150,7 @@ namespace UniGLTF } } - public class UInt32Serialization : PrimitiveSerializationBase + public class UInt32Serialization : NumberSerializationBase { public override Type ValueType { @@ -111,7 +163,7 @@ namespace UniGLTF } } - public class UInt64Serialization : PrimitiveSerializationBase + public class UInt64Serialization : NumberSerializationBase { public override Type ValueType { @@ -124,7 +176,7 @@ namespace UniGLTF } } - public class SingleSerialization : PrimitiveSerializationBase + public class SingleSerialization : NumberSerializationBase { public override Type ValueType { @@ -137,7 +189,7 @@ namespace UniGLTF } } - public class DoubleSerialization : PrimitiveSerializationBase + public class DoubleSerialization : NumberSerializationBase { public override Type ValueType { @@ -174,38 +226,10 @@ namespace UniGLTF { return argName + ".GetString()"; } - } - public class EnumIntSerialization : PrimitiveSerializationBase - { - Type m_type; - UniJSON.EnumSerializationType m_serializationType; - - public override Type ValueType + public override string CreateSerializationCondition(string argName, JsonSchemaAttribute t) { - get { return m_type; } - } - - public EnumIntSerialization(Type t, UniJSON.EnumSerializationType serializationType) - { - m_type = t; - m_serializationType = serializationType; - } - - public override string GenerateDeserializerCall(string callName, string argName) - { - switch (m_serializationType) - { - case UniJSON.EnumSerializationType.AsInt: - return string.Format("({0}){1}.GetInt32()", m_type.Name, argName); - - case UniJSON.EnumSerializationType.AsLowerString: - // (ProjectionType)Enum.Parse(typeof(ProjectionType), kv.Value.GetString(), true) - return $"({m_type.Name})Enum.Parse(typeof({m_type.Name}), {argName}.GetString(), true)"; - - default: - throw new NotImplementedException(); - } + return $"!string.IsNullOrEmpty({argName})"; } } -} \ No newline at end of file +} diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/PrimitiveSerialization.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/PrimitiveSerialization.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Serialization/PrimitiveSerialization.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/PrimitiveSerialization.cs.meta diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/SerializerGenerator.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/SerializerGenerator.cs new file mode 100644 index 000000000..3366b4897 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/SerializerGenerator.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using UniJSON; +using UnityEditor; +using UnityEngine; + +namespace UniGLTF +{ + public static class SerializerGenerator + { + const BindingFlags FIELD_FLAGS = BindingFlags.Instance | BindingFlags.Public; + + const string Begin = @"using System; +using System.Collections.Generic; +using UniJSON; + +namespace UniGLTF { + + static public class GltfSerializer + { + +"; + + const string End = @" + } // class +} // namespace +"; + + static string OutPath + { + get + { + return Path.Combine(UnityEngine.Application.dataPath, + "UniGLTF/UniGLTF/Scripts/IO/GltfSerializer.g.cs"); + } + } + + [MenuItem(UniGLTFVersion.MENU + "/GLTF: Generate Serializer")] + static void GenerateSerializer() + { + var info = new ObjectSerialization(typeof(glTF), "gltf", "Serialize_"); + Debug.Log(info); + + using (var s = File.Open(OutPath, FileMode.Create)) + using (var w = new StreamWriter(s, new UTF8Encoding(false))) + { + w.Write(Begin); + info.GenerateSerializer(w, "Serialize"); + w.Write(End); + } + + Debug.LogFormat("write: {0}", OutPath); + UnityPath.FromFullpath(OutPath).ImportAsset(); + } + } +} diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/SerializerGenerator.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/Serialization/SerializerGenerator.cs.meta diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/StringKeyDictionarySerialization.cs b/Assets/UniGLTF/Editor/UniGLTF/Serialization/StringKeyDictionarySerialization.cs new file mode 100644 index 000000000..e09987807 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/StringKeyDictionarySerialization.cs @@ -0,0 +1,70 @@ +using System; +using System.IO; + +namespace UniGLTF +{ + public class StringKeyDictionarySerialization : CollectionSerializationBase + { + IValueSerialization m_inner; + + public StringKeyDictionarySerialization(Type t, IValueSerialization inner) + { + ValueType = t; + m_inner = inner; + } + + public override void GenerateDeserializer(StreamWriter writer, string callName) + { + var itemCallName = callName + "_ITEM"; + writer.Write(@" + +public static $0 $2(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), $3); + } + return value; +} +" +.Replace("$0", JsonSchemaAttribute.GetTypeName(ValueType)) +.Replace("$1", m_inner.ValueType.Name) +.Replace("$2", callName) +.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "kv.Value")) +); + + if (!m_inner.IsInline) + { + m_inner.GenerateDeserializer(writer, itemCallName); + } + } + + public override string CreateSerializationCondition(string argName, JsonSchemaAttribute t) + { + return $"{argName}!=null&&{argName}.Count>0"; + } + + public override void GenerateSerializer(StreamWriter writer, string callName) + { + var itemCallName = callName + "_ITEM"; + writer.Write($@" +public static void {callName}(JsonFormatter f, Dictionary value) +{{ + f.BeginMap(); + foreach(var kv in value) + {{ + f.Key(kv.Key); + {m_inner.GenerateSerializerCall(itemCallName, "kv.Value")}; + }} + f.EndMap(); +}} +"); + + if (!m_inner.IsInline) + { + m_inner.GenerateSerializer(writer, itemCallName); + } + } + } +} diff --git a/Assets/UniGLTF/Editor/UniGLTF/Serialization/StringKeyDictionarySerialization.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/Serialization/StringKeyDictionarySerialization.cs.meta new file mode 100644 index 000000000..ade982611 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/Serialization/StringKeyDictionarySerialization.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 760fc2dffd8f64544ab2c6a16fea7d79 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/gltfAssetPostprocessor.cs b/Assets/UniGLTF/Editor/UniGLTF/gltfAssetPostprocessor.cs similarity index 100% rename from Assets/VRM/UniGLTF/Editor/gltfAssetPostprocessor.cs rename to Assets/UniGLTF/Editor/UniGLTF/gltfAssetPostprocessor.cs diff --git a/Assets/VRM/UniGLTF/Editor/gltfAssetPostprocessor.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/gltfAssetPostprocessor.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/gltfAssetPostprocessor.cs.meta rename to Assets/UniGLTF/Editor/UniGLTF/gltfAssetPostprocessor.cs.meta diff --git a/Assets/VRM/UniHumanoid/LICENSE.md b/Assets/UniGLTF/LICENSE.md similarity index 100% rename from Assets/VRM/UniHumanoid/LICENSE.md rename to Assets/UniGLTF/LICENSE.md diff --git a/Assets/VRM/UniGLTF/LICENSE.md.meta b/Assets/UniGLTF/LICENSE.md.meta similarity index 100% rename from Assets/VRM/UniGLTF/LICENSE.md.meta rename to Assets/UniGLTF/LICENSE.md.meta diff --git a/Assets/VRM/UniGLTF/README.md b/Assets/UniGLTF/README.md similarity index 100% rename from Assets/VRM/UniGLTF/README.md rename to Assets/UniGLTF/README.md diff --git a/Assets/VRM/UniGLTF/README.md.meta b/Assets/UniGLTF/README.md.meta similarity index 100% rename from Assets/VRM/UniGLTF/README.md.meta rename to Assets/UniGLTF/README.md.meta diff --git a/Assets/UniGLTF/Runtime.meta b/Assets/UniGLTF/Runtime.meta new file mode 100644 index 000000000..e1dc237b4 --- /dev/null +++ b/Assets/UniGLTF/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7ac4e9067f1803545a72992037897161 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler.meta similarity index 62% rename from Assets/VRM/UniGLTF/Scripts.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler.meta index 18a2d6bef..0d4cf3d12 100644 --- a/Assets/VRM/UniGLTF/Scripts.meta +++ b/Assets/UniGLTF/Runtime/DepthFirstScheduler.meta @@ -1,8 +1,6 @@ fileFormatVersion: 2 -guid: d0989add64612874d9cb36855d07677d +guid: 59e97de25dbef7844afdb7923e5497df folderAsset: yes -timeCreated: 1517139165 -licenseType: Free DefaultImporter: externalObjects: {} userData: diff --git a/Assets/VRM/DepthFirstScheduler/Functor.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Functor.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Functor.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Functor.cs diff --git a/Assets/VRM/DepthFirstScheduler/Functor.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Functor.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Functor.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Functor.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/IEnumeratorExtensions.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/IEnumeratorExtensions.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/IEnumeratorExtensions.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/IEnumeratorExtensions.cs diff --git a/Assets/VRM/DepthFirstScheduler/IEnumeratorExtensions.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/IEnumeratorExtensions.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/IEnumeratorExtensions.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/IEnumeratorExtensions.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/LockQueue.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/LockQueue.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/LockQueue.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/LockQueue.cs diff --git a/Assets/VRM/DepthFirstScheduler/LockQueue.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/LockQueue.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/LockQueue.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/LockQueue.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/MainThreadDispatcher.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/MainThreadDispatcher.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/MainThreadDispatcher.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/MainThreadDispatcher.cs diff --git a/Assets/VRM/DepthFirstScheduler/MainThreadDispatcher.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/MainThreadDispatcher.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/MainThreadDispatcher.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/MainThreadDispatcher.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/MonitorQueue.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/MonitorQueue.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/MonitorQueue.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/MonitorQueue.cs diff --git a/Assets/VRM/DepthFirstScheduler/MonitorQueue.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/MonitorQueue.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/MonitorQueue.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/MonitorQueue.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/Schedulable.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Schedulable.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Schedulable.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Schedulable.cs diff --git a/Assets/VRM/DepthFirstScheduler/Schedulable.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Schedulable.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Schedulable.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Schedulable.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/Scheduler.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Scheduler.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler.cs diff --git a/Assets/VRM/DepthFirstScheduler/Scheduler.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Scheduler.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/Scheduler.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler.meta similarity index 77% rename from Assets/VRM/DepthFirstScheduler/Scheduler.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler.meta index efdb87bad..b816b6019 100644 --- a/Assets/VRM/DepthFirstScheduler/Scheduler.meta +++ b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0700fb042f010694782d238049678651 +guid: 6c7a6e7b95b40f74fa32896e23dbac93 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/VRM/DepthFirstScheduler/Scheduler/CurrentThreadScheduler.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/CurrentThreadScheduler.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Scheduler/CurrentThreadScheduler.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/CurrentThreadScheduler.cs diff --git a/Assets/VRM/DepthFirstScheduler/Scheduler/CurrentThreadScheduler.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/CurrentThreadScheduler.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Scheduler/CurrentThreadScheduler.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/CurrentThreadScheduler.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/Scheduler/StepScheduler.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/StepScheduler.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Scheduler/StepScheduler.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/StepScheduler.cs diff --git a/Assets/VRM/DepthFirstScheduler/Scheduler/StepScheduler.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/StepScheduler.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Scheduler/StepScheduler.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/StepScheduler.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/Scheduler/ThreadPoolScheduler.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/ThreadPoolScheduler.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Scheduler/ThreadPoolScheduler.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/ThreadPoolScheduler.cs diff --git a/Assets/VRM/DepthFirstScheduler/Scheduler/ThreadPoolScheduler.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/ThreadPoolScheduler.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Scheduler/ThreadPoolScheduler.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/ThreadPoolScheduler.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/Scheduler/ThreadScheduler.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/ThreadScheduler.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Scheduler/ThreadScheduler.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/ThreadScheduler.cs diff --git a/Assets/VRM/DepthFirstScheduler/Scheduler/ThreadScheduler.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/ThreadScheduler.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Scheduler/ThreadScheduler.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Scheduler/ThreadScheduler.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/TaskChain.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/TaskChain.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/TaskChain.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/TaskChain.cs diff --git a/Assets/VRM/DepthFirstScheduler/TaskChain.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/TaskChain.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/TaskChain.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/TaskChain.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/Unit.cs b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Unit.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Unit.cs rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Unit.cs diff --git a/Assets/VRM/DepthFirstScheduler/Unit.cs.meta b/Assets/UniGLTF/Runtime/DepthFirstScheduler/Unit.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Unit.cs.meta rename to Assets/UniGLTF/Runtime/DepthFirstScheduler/Unit.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Extensions.meta b/Assets/UniGLTF/Runtime/Extensions.meta similarity index 62% rename from Assets/VRM/UniGLTF/Scripts/Extensions.meta rename to Assets/UniGLTF/Runtime/Extensions.meta index 6765ba93c..798ac2da8 100644 --- a/Assets/VRM/UniGLTF/Scripts/Extensions.meta +++ b/Assets/UniGLTF/Runtime/Extensions.meta @@ -1,8 +1,6 @@ fileFormatVersion: 2 -guid: bb1523b753d4a6444935951652053804 +guid: 055f2c0f1f2ae4749bf5c744fe497b81 folderAsset: yes -timeCreated: 1514252348 -licenseType: Free DefaultImporter: externalObjects: {} userData: diff --git a/Assets/VRM/UniGLTF/Scripts/Extensions/ArrayExtensions.cs b/Assets/UniGLTF/Runtime/Extensions/ArrayExtensions.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Extensions/ArrayExtensions.cs rename to Assets/UniGLTF/Runtime/Extensions/ArrayExtensions.cs diff --git a/Assets/VRM/UniGLTF/Scripts/Extensions/ArrayExtensions.cs.meta b/Assets/UniGLTF/Runtime/Extensions/ArrayExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Extensions/ArrayExtensions.cs.meta rename to Assets/UniGLTF/Runtime/Extensions/ArrayExtensions.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Extensions/StringExtensions.cs b/Assets/UniGLTF/Runtime/Extensions/StringExtensions.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Extensions/StringExtensions.cs rename to Assets/UniGLTF/Runtime/Extensions/StringExtensions.cs diff --git a/Assets/VRM/UniGLTF/Scripts/Extensions/StringExtensions.cs.meta b/Assets/UniGLTF/Runtime/Extensions/StringExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Extensions/StringExtensions.cs.meta rename to Assets/UniGLTF/Runtime/Extensions/StringExtensions.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Extensions/UnityExtensions.cs b/Assets/UniGLTF/Runtime/Extensions/UnityExtensions.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Extensions/UnityExtensions.cs rename to Assets/UniGLTF/Runtime/Extensions/UnityExtensions.cs diff --git a/Assets/VRM/UniGLTF/Scripts/Extensions/UnityExtensions.cs.meta b/Assets/UniGLTF/Runtime/Extensions/UnityExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Extensions/UnityExtensions.cs.meta rename to Assets/UniGLTF/Runtime/Extensions/UnityExtensions.cs.meta diff --git a/Assets/UniGLTF/Runtime/Extensions/glTFExtensions.cs b/Assets/UniGLTF/Runtime/Extensions/glTFExtensions.cs new file mode 100644 index 000000000..7551e18e6 --- /dev/null +++ b/Assets/UniGLTF/Runtime/Extensions/glTFExtensions.cs @@ -0,0 +1,431 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; +using System.IO; +using UniJSON; + +namespace UniGLTF +{ + [Serializable, StructLayout(LayoutKind.Sequential, Pack = 1)] + struct UShort4 + { + public ushort x; + public ushort y; + public ushort z; + public ushort w; + + public UShort4(ushort _x, ushort _y, ushort _z, ushort _w) + { + x = _x; + y = _y; + z = _z; + w = _w; + } + } + + public static class glTFExtensions + { + struct ComponentVec + { + public glComponentType ComponentType; + public int ElementCount; + + public ComponentVec(glComponentType componentType, int elementCount) + { + ComponentType = componentType; + ElementCount = elementCount; + } + } + + static Dictionary ComponentTypeMap = new Dictionary + { + { typeof(Vector2), new ComponentVec(glComponentType.FLOAT, 2) }, + { typeof(Vector3), new ComponentVec(glComponentType.FLOAT, 3) }, + { typeof(Vector4), new ComponentVec(glComponentType.FLOAT, 4) }, + { typeof(UShort4), new ComponentVec(glComponentType.UNSIGNED_SHORT, 4) }, + { typeof(Matrix4x4), new ComponentVec(glComponentType.FLOAT, 16) }, + { typeof(Color), new ComponentVec(glComponentType.FLOAT, 4) }, + }; + + static glComponentType GetComponentType() + { + var cv = default(ComponentVec); + if (ComponentTypeMap.TryGetValue(typeof(T), out cv)) + { + return cv.ComponentType; + } + else if (typeof(T) == typeof(uint)) + { + return glComponentType.UNSIGNED_INT; + } + else if (typeof(T) == typeof(float)) + { + return glComponentType.FLOAT; + } + else + { + throw new NotImplementedException(typeof(T).Name); + } + } + + static string GetAccessorType() + { + var cv = default(ComponentVec); + if (ComponentTypeMap.TryGetValue(typeof(T), out cv)) + { + switch (cv.ElementCount) + { + case 2: return "VEC2"; + case 3: return "VEC3"; + case 4: return "VEC4"; + case 16: return "MAT4"; + default: throw new Exception(); + } + } + else + { + return "SCALAR"; + } + } + + static int GetAccessorElementCount() + { + var cv = default(ComponentVec); + if (ComponentTypeMap.TryGetValue(typeof(T), out cv)) + { + return cv.ElementCount; + } + else + { + return 1; + } + } + + public static int ExtendBufferAndGetAccessorIndex(this glTF gltf, int bufferIndex, T[] array, + glBufferTarget target = glBufferTarget.NONE) where T : struct + { + return gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, new ArraySegment(array), target); + } + + public static int ExtendBufferAndGetAccessorIndex(this glTF gltf, int bufferIndex, + ArraySegment array, + glBufferTarget target = glBufferTarget.NONE) where T : struct + { + if (array.Count == 0) + { + return -1; + } + var viewIndex = ExtendBufferAndGetViewIndex(gltf, bufferIndex, array, target); + + // index buffer's byteStride is unnecessary + gltf.bufferViews[viewIndex].byteStride = 0; + + var accessorIndex = gltf.accessors.Count; + gltf.accessors.Add(new glTFAccessor + { + bufferView = viewIndex, + byteOffset = 0, + componentType = GetComponentType(), + type = GetAccessorType(), + count = array.Count, + }); + return accessorIndex; + } + + public static int ExtendBufferAndGetViewIndex(this glTF gltf, int bufferIndex, + T[] array, + glBufferTarget target = glBufferTarget.NONE) where T : struct + { + return ExtendBufferAndGetViewIndex(gltf, bufferIndex, new ArraySegment(array), target); + } + + public static int ExtendBufferAndGetViewIndex(this glTF gltf, int bufferIndex, + ArraySegment array, + glBufferTarget target = glBufferTarget.NONE) where T : struct + { + if (array.Count == 0) + { + return -1; + } + var view = gltf.buffers[bufferIndex].Append(array, target); + var viewIndex = gltf.bufferViews.Count; + gltf.bufferViews.Add(view); + return viewIndex; + } + + public static int ExtendSparseBufferAndGetAccessorIndex(this glTF gltf, int bufferIndex, + int accessorCount, + T[] sparseValues, int[] sparseIndices, int sparseViewIndex, + glBufferTarget target = glBufferTarget.NONE) where T : struct + { + return ExtendSparseBufferAndGetAccessorIndex(gltf, bufferIndex, + accessorCount, + new ArraySegment(sparseValues), sparseIndices, sparseViewIndex, + target); + } + + public static int ExtendSparseBufferAndGetAccessorIndex(this glTF gltf, int bufferIndex, + int accessorCount, + ArraySegment sparseValues, int[] sparseIndices, int sparseIndicesViewIndex, + glBufferTarget target = glBufferTarget.NONE) where T : struct + { + if (sparseValues.Count == 0) + { + return -1; + } + var sparseValuesViewIndex = ExtendBufferAndGetViewIndex(gltf, bufferIndex, sparseValues, target); + var accessorIndex = gltf.accessors.Count; + gltf.accessors.Add(new glTFAccessor + { + byteOffset = 0, + componentType = GetComponentType(), + type = GetAccessorType(), + count = accessorCount, + + sparse = new glTFSparse + { + count = sparseIndices.Length, + indices = new glTFSparseIndices + { + bufferView = sparseIndicesViewIndex, + componentType = glComponentType.UNSIGNED_INT + }, + values = new glTFSparseValues + { + bufferView = sparseValuesViewIndex, + } + } + }); + return accessorIndex; + } + + public static int AddBuffer(this glTF self, IBytesBuffer bytesBuffer) + { + var index = self.buffers.Count; + self.buffers.Add(new glTFBuffer(bytesBuffer)); + return index; + } + + static T[] GetAttrib(this glTF self, int count, int byteOffset, glTFBufferView view) where T : struct + { + var attrib = new T[count]; + var segment = self.buffers[view.buffer].GetBytes(); + var bytes = new ArraySegment(segment.Array, segment.Offset + view.byteOffset + byteOffset, count * view.byteStride); + bytes.MarshalCopyTo(attrib); + return attrib; + } + + static T[] GetAttrib(this glTF self, glTFAccessor accessor, glTFBufferView view) where T : struct + { + return self.GetAttrib(accessor.count, accessor.byteOffset, view); + } + + static IEnumerable _GetIndices(this glTF self, glTFAccessor accessor, out int count) + { + count = accessor.count; + var view = self.bufferViews[accessor.bufferView]; + switch ((glComponentType)accessor.componentType) + { + case glComponentType.UNSIGNED_BYTE: + { + return self.GetAttrib(accessor, view).Select(x => (int)(x)); + } + + case glComponentType.UNSIGNED_SHORT: + { + return self.GetAttrib(accessor, view).Select(x => (int)(x)); + } + + case glComponentType.UNSIGNED_INT: + { + return self.GetAttrib(accessor, view).Select(x => (int)(x)); + } + } + throw new NotImplementedException("GetIndices: unknown componenttype: " + accessor.componentType); + } + + static IEnumerable _GetIndices(this glTF self, glTFBufferView view, int count, int byteOffset, glComponentType componentType) + { + switch (componentType) + { + case glComponentType.UNSIGNED_BYTE: + { + return self.GetAttrib(count, byteOffset, view).Select(x => (int)(x)); + } + + case glComponentType.UNSIGNED_SHORT: + { + return self.GetAttrib(count, byteOffset, view).Select(x => (int)(x)); + } + + case glComponentType.UNSIGNED_INT: + { + return self.GetAttrib(count, byteOffset, view).Select(x => (int)(x)); + } + } + throw new NotImplementedException("GetIndices: unknown componenttype: " + componentType); + } + + public static int[] GetIndices(this glTF self, int accessorIndex) + { + int count; + var result = self._GetIndices(self.accessors[accessorIndex], out count); + var indices = new int[count]; + + // flip triangles + var it = result.GetEnumerator(); + { + for (int i = 0; i < count; i += 3) + { + it.MoveNext(); indices[i + 2] = it.Current; + it.MoveNext(); indices[i + 1] = it.Current; + it.MoveNext(); indices[i] = it.Current; + } + } + + return indices; + } + + public static T[] GetArrayFromAccessor(this glTF self, int accessorIndex) where T : struct + { + var vertexAccessor = self.accessors[accessorIndex]; + + if (vertexAccessor.count <= 0) return new T[] { }; + + var result = (vertexAccessor.bufferView != -1) + ? self.GetAttrib(vertexAccessor, self.bufferViews[vertexAccessor.bufferView]) + : new T[vertexAccessor.count] + ; + + var sparse = vertexAccessor.sparse; + if (sparse != null && sparse.count > 0) + { + // override sparse values + var indices = self._GetIndices(self.bufferViews[sparse.indices.bufferView], sparse.count, sparse.indices.byteOffset, sparse.indices.componentType); + var values = self.GetAttrib(sparse.count, sparse.values.byteOffset, self.bufferViews[sparse.values.bufferView]); + + var it = indices.GetEnumerator(); + for (int i = 0; i < sparse.count; ++i) + { + it.MoveNext(); + result[it.Current] = values[i]; + } + } + return result; + } + + public static ArraySegment GetImageBytes(this glTF self, IStorage storage, int imageIndex, out string textureName) + { + var image = self.images[imageIndex]; + if (string.IsNullOrEmpty(image.uri)) + { + // + // use buffer view (GLB) + // + //m_imageBytes = ToArray(byteSegment); + textureName = !string.IsNullOrEmpty(image.name) ? image.name : string.Format("{0:00}#GLB", imageIndex); + return self.GetViewBytes(image.bufferView); + } + else + { + if (image.uri.StartsWith("data:")) + { + textureName = !string.IsNullOrEmpty(image.name) ? image.name : string.Format("{0:00}#Base64Embedded", imageIndex); + } + else + { + textureName = !string.IsNullOrEmpty(image.name) ? image.name : Path.GetFileNameWithoutExtension(image.uri); + } + return storage.Get(image.uri); + } + } + + static Utf8String s_extensions = Utf8String.From("extensions"); + + static bool UsedExtension(this glTF self, string key) + { + if (self.extensionsUsed.Contains(key)) + { + return true; + } + + return false; + } + + static void Traverse(this glTF self, ListTreeNode node, JsonFormatter f, Utf8String parentKey) + { + if (node.IsMap()) + { + f.BeginMap(); + foreach (var kv in node.ObjectItems()) + { + if (parentKey == s_extensions) + { + if (!self.UsedExtension(kv.Key.GetString())) + { + continue; + } + } + f.Key(kv.Key.GetUtf8String()); + self.Traverse(kv.Value, f, kv.Key.GetUtf8String()); + } + f.EndMap(); + } + else if (node.IsArray()) + { + f.BeginList(); + foreach (var x in node.ArrayItems()) + { + self.Traverse(x, f, default(Utf8String)); + } + f.EndList(); + } + else + { + f.Value(node); + } + } + + static string RemoveUnusedExtensions(this glTF self, string json) + { + var f = new JsonFormatter(); + self.Traverse(JsonParser.Parse(json), f, default(Utf8String)); + return f.ToString(); + } + + public static byte[] ToGlbBytes(this glTF self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize(f, self); + + var json = f.ToString().ParseAsJson().ToString(" "); + + self.RemoveUnusedExtensions(json); + + return Glb.ToBytes(json, self.buffers[0].GetBytes()); + } + + public static (string, List) ToGltf(this glTF self, string gltfPath) + { + var f = new JsonFormatter(); + + // fix buffer path + if (self.buffers.Count == 1) + { + var withoutExt = Path.GetFileNameWithoutExtension(gltfPath); + self.buffers[0].uri = $"{withoutExt}.bin"; + } + else + { + throw new NotImplementedException(); + } + + GltfSerializer.Serialize(f, self); + var json = f.ToString().ParseAsJson().ToString(" "); + self.RemoveUnusedExtensions(json); + return (json, self.buffers); + } + } +} diff --git a/Assets/VRM/UniGLTF/Scripts/Extensions/glTFExtensions.cs.meta b/Assets/UniGLTF/Runtime/Extensions/glTFExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Extensions/glTFExtensions.cs.meta rename to Assets/UniGLTF/Runtime/Extensions/glTFExtensions.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniGLTF.asmdef b/Assets/UniGLTF/Runtime/UniGLTF.asmdef new file mode 100644 index 000000000..d2f68d054 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF.asmdef @@ -0,0 +1,15 @@ +{ + "name": "UniGLTF", + "references": [ + "UniUnlit", + "ShaderProperty.Runtime" + ], + "optionalUnityReferences": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [] +} \ No newline at end of file diff --git a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTF.Editor.Tests.asmdef.meta b/Assets/UniGLTF/Runtime/UniGLTF.asmdef.meta similarity index 76% rename from Assets/VRM/UniGLTF/Editor/Tests/UniGLTF.Editor.Tests.asmdef.meta rename to Assets/UniGLTF/Runtime/UniGLTF.asmdef.meta index 812b7f5bb..dc8cecd7d 100644 --- a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTF.Editor.Tests.asmdef.meta +++ b/Assets/UniGLTF/Runtime/UniGLTF.asmdef.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: defaf82877bdaee4994325c29625b5ea +guid: 8d76e605759c3f64a957d63ef96ada7c AssemblyDefinitionImporter: externalObjects: {} userData: diff --git a/Assets/UniGLTF/Runtime/UniGLTF.meta b/Assets/UniGLTF/Runtime/UniGLTF.meta new file mode 100644 index 000000000..dd33dbdab --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 19f30725959048345880a8597d0f64c7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/.gitignore b/Assets/UniGLTF/Runtime/UniGLTF/.gitignore similarity index 100% rename from Assets/VRM/UniGLTF/.gitignore rename to Assets/UniGLTF/Runtime/UniGLTF/.gitignore diff --git a/Assets/VRM/UniGLTF/Scripts/Format.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format.meta similarity index 62% rename from Assets/VRM/UniGLTF/Scripts/Format.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format.meta index 31f52eefb..fad5d7900 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format.meta +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format.meta @@ -1,8 +1,6 @@ fileFormatVersion: 2 -guid: 91b71b4caaefeae4fa5ca31908b35a86 +guid: 1a7363b164d829d46929d702fcdd070e folderAsset: yes -timeCreated: 1516616861 -licenseType: Free DefaultImporter: externalObjects: {} userData: diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/ArraySegmentByteBuffer.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/ArraySegmentByteBuffer.cs new file mode 100644 index 000000000..bdd66ae95 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/ArraySegmentByteBuffer.cs @@ -0,0 +1,35 @@ +using System; +using System.IO; + + +namespace UniGLTF +{ + /// + /// for glb chunk buffer read + /// + public class ArraySegmentByteBuffer : IBytesBuffer + { + ArraySegment m_bytes; + + public ArraySegmentByteBuffer(ArraySegment bytes) + { + m_bytes = bytes; + } + + public string Uri + { + get; + private set; + } + + public glTFBufferView Extend(ArraySegment array, glBufferTarget target) where T : struct + { + throw new NotImplementedException(); + } + + public ArraySegment GetBytes() + { + return m_bytes; + } + } +} diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/ArraySegmentByteBuffer.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/ArraySegmentByteBuffer.cs.meta new file mode 100644 index 000000000..3236a085e --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/ArraySegmentByteBuffer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f857b8b7ca45b1746af90c7fb86b2398 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras.meta new file mode 100644 index 000000000..56e9b6368 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a6d955aaf077fca4bb609014ed1e088e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/KHR_materials_unlit.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/KHR_materials_unlit.cs new file mode 100644 index 000000000..e412515bc --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/KHR_materials_unlit.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using UniJSON; + +namespace UniGLTF +{ + [Serializable] + public class glTF_KHR_materials_unlit + { + public const string ExtensionName = "KHR_materials_unlit"; + + public static readonly Utf8String ExtensionNameUtf8 = Utf8String.From(ExtensionName); + + static readonly byte[] Raw = new byte[] { (byte)'{', (byte)'}' }; + + public static glTFMaterial CreateDefault() + { + return new glTFMaterial + { + pbrMetallicRoughness = new glTFPbrMetallicRoughness + { + baseColorFactor = new float[] { 1.0f, 1.0f, 1.0f, 1.0f }, + roughnessFactor = 0.9f, + metallicFactor = 0.0f, + }, + extensions = new glTFExtensionExport().Add(ExtensionName, new ArraySegment(Raw)) + }; + } + + public static bool IsEnable(glTFMaterial m) + { + if (m.extensions is glTFExtensionImport imported) + { + foreach (var kv in imported.ObjectItems()) + { + if (kv.Key.GetUtf8String() == ExtensionNameUtf8) + { + return kv.Value.Value.ValueType == ValueNodeType.Object; + } + } + } + + return false; + } + + public static glTFExtension Serialize() + { + return new glTFExtensionExport().Add(ExtensionName, new ArraySegment(Raw)); + } + } +} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_materials_unlit.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/KHR_materials_unlit.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_materials_unlit.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/KHR_materials_unlit.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/KHR_texture_transform.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/KHR_texture_transform.cs new file mode 100644 index 000000000..e90ed8d8d --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/KHR_texture_transform.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniJSON; + +namespace UniGLTF +{ + [Serializable] + public class glTF_KHR_texture_transform + { + public const string ExtensionName = "KHR_texture_transform"; + + public static readonly Utf8String ExtensionNameUt8 = Utf8String.From(ExtensionName); + + + [JsonSchema(MinItems = 2, MaxItems = 2)] + public float[] offset = new float[2] { 0.0f, 0.0f }; + + public float rotation; + + [JsonSchema(MinItems = 2, MaxItems = 2)] + public float[] scale = new float[2] { 1.0f, 1.0f }; + + [ItemJsonSchema(Minimum = 0)] + public int texCoord; + + static IEnumerable DeserializeFloat2(ListTreeNode json) + { + if (json.Value.ValueType == ValueNodeType.Array) + { + foreach (var a in json.ArrayItems()) + { + yield return a.GetSingle(); + } + } + } + + static glTF_KHR_texture_transform Deserialize(ListTreeNode json) + { + var t = new glTF_KHR_texture_transform(); + + if (json.Value.ValueType == ValueNodeType.Object) + { + foreach (var kv in json.ObjectItems()) + { + var key = kv.Key.GetString(); + switch (key) + { + case nameof(offset): + t.offset = DeserializeFloat2(kv.Value).ToArray(); + break; + + case nameof(rotation): + t.rotation = kv.Value.GetSingle(); + break; + + case nameof(scale): + t.scale = DeserializeFloat2(kv.Value).ToArray(); + break; + + case nameof(texCoord): + t.texCoord = kv.Value.GetInt32(); + break; + + default: + throw new NotImplementedException(); + } + } + } + + return t; + } + + public static bool TryGet(glTFTextureInfo info, out glTF_KHR_texture_transform t) + { + if (info.extras is glTFExtensionImport imported) + { + foreach (var kv in imported.ObjectItems()) + { + if (kv.Key.GetUtf8String() == ExtensionNameUt8) + { + t = Deserialize(kv.Value); + return true; + } + } + } + + t = default; + return false; + } + + public static void Serialize(glTFTextureInfo info, (float, float) offset, (float, float) scale) + { + var f = new JsonFormatter(); + f.BeginMap(); + + f.Key("offset"); + f.BeginList(); + f.Value(offset.Item1); + f.Value(offset.Item2); + f.EndList(); + + f.Key("scale"); + f.BeginList(); + f.Value(scale.Item1); + f.Value(scale.Item2); + f.EndList(); + + f.EndMap(); + + glTFExtensionExport.GetOrCreate(ref info.extensions).Add(ExtensionName, f.GetStore().Bytes); + } + } +} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_texture_transform.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/KHR_texture_transform.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_texture_transform.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/KHR_texture_transform.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltfExtension.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltfExtension.cs new file mode 100644 index 000000000..29e68f014 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltfExtension.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections.Generic; +using System.Text; +using UniJSON; + +namespace UniGLTF +{ + /// + /// Extension または Extras に使う + /// + public abstract class glTFExtension + { + // NO BOM + static Encoding Utf8 = new UTF8Encoding(false); + + /// + /// for unit test + /// + /// parse exported value + /// + public virtual glTFExtensionImport Deserialize() + { + throw new NotImplementedException(); + } + + public virtual void Serialize(JsonFormatter f) + { + throw new NotImplementedException(); + } + } + + /// + /// Export(Serialize)用 + /// + /// 実体は、 + /// + /// Dictionary> + /// + /// key: json object のキー名 + /// value: utf8 エンコーディング済みのJSON + /// + /// + public class glTFExtensionExport : glTFExtension + { + readonly Dictionary> m_serialized; + + public glTFExtensionExport() + { + m_serialized = new Dictionary>(); + } + + public override string ToString() + { + var f = new JsonFormatter(); + Serialize(f); + var bytes = f.GetStoreBytes(); + return "export: " + Encoding.UTF8.GetString(bytes.Array, bytes.Offset, bytes.Count); + } + + public glTFExtensionExport Add(string key, ArraySegment raw) + { + m_serialized.Add(key, raw); + return this; + } + + public override void Serialize(JsonFormatter f) + { + f.BeginMap(); + if (m_serialized != null) + { + foreach (var kv in m_serialized) + { + f.Key(kv.Key); + f.Raw(kv.Value); + } + } + f.EndMap(); + } + + public static glTFExtensionExport GetOrCreate(ref glTFExtension extension) + { + if (extension is glTFExtensionExport exported) + { + // get + return exported; + } + + if (extension != null) + { + // glTFExtensionImport ? + throw new NotImplementedException(); + } + + // or create + exported = new glTFExtensionExport(); + extension = exported; + return exported; + } + + /// + /// for unit test + /// + /// parse exported value + /// + public override glTFExtensionImport Deserialize() + { + var f = new JsonFormatter(); + f.GenSerialize(this); + var b = f.GetStoreBytes(); + var json = Encoding.UTF8.GetString(b.Array, b.Offset, b.Count); + return new glTFExtensionImport(json.ParseAsJson()); + } + } + + /// + /// Import(Deserialize)用 + /// + /// パース済みの JSONの部分 を保持する + /// + /// ListTreeNode がJsonの部分を参照できる。 + /// + /// + public class glTFExtensionImport : glTFExtension + { + readonly ListTreeNode m_json; + public glTFExtensionImport(ListTreeNode json) + { + m_json = json; + } + + public override string ToString() + { + var bytes = m_json.Value.Bytes; + return "import: " + Encoding.UTF8.GetString(bytes.Array, bytes.Offset, bytes.Count); + } + + public IEnumerable, ListTreeNode>> ObjectItems() + { + if (m_json.Value.ValueType == ValueNodeType.Object) + { + foreach (var kv in m_json.ObjectItems()) + { + yield return kv; + } + } + } + + public override void Serialize(JsonFormatter f) + { + f.Raw(m_json.Value.Bytes); + } + } + + public static class GltfExtensionFormatterExtensions + { + /// + /// Json化 + /// + /// + /// + public static void GenSerialize(this JsonFormatter f, glTFExtension v) + { + if (v != null) + { + v.Serialize(f); + return; + } + + throw new NotImplementedException(); + } + } +} diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltfExtension.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltfExtension.cs.meta new file mode 100644 index 000000000..dfa4355a7 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltfExtension.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d078ffd4a6179da48af7c4290beeb140 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltf_mesh_extras_targetNames.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltf_mesh_extras_targetNames.cs new file mode 100644 index 000000000..54697959d --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltf_mesh_extras_targetNames.cs @@ -0,0 +1,101 @@ +using System.Collections.Generic; +using UniJSON; + +namespace UniGLTF +{ + /// + /// work around + /// + /// https://github.com/KhronosGroup/glTF/issues/1036 + /// + /// * meshes[].primitives[].extras.targetNames + /// * meshes[].extras.targetNames + /// + /// + public static class gltf_mesh_extras_targetNames + { + public const string ExtraName = "targetNames"; + + public static readonly Utf8String ExtraNameUtf8 = Utf8String.From(ExtraName); + + static List Deserialize(ListTreeNode json) + { + var targetNames = new List(); + if (json.Value.ValueType == ValueNodeType.Array) + { + foreach (var name in json.ArrayItems()) + { + targetNames.Add(name.GetString()); + } + } + return targetNames; + } + + public static bool TryGet(glTFMesh mesh, out List targetNames) + { + if (mesh.extras is glTFExtensionImport meshExtras) + { + foreach (var kv in meshExtras.ObjectItems()) + { + if (kv.Key.GetUtf8String() == ExtraNameUtf8) + { + targetNames = Deserialize(kv.Value); + return true; + } + } + } + + // use first primitive + if (mesh.primitives.Count > 0 && mesh.primitives[0].extras is glTFExtensionImport primExtras) + { + foreach (var kv in primExtras.ObjectItems()) + { + if (kv.Key.GetUtf8String() == ExtraNameUtf8) + { + targetNames = Deserialize(kv.Value); + return true; + } + } + } + + targetNames = default; + return false; + } + + public static glTFExtension Serialize(params string[] args) + { + var f = new JsonFormatter(); + f.BeginList(); + foreach (var arg in args) + { + // エスケープとかあるし + f.Value(arg); + } + f.EndList(); + + return new glTFExtensionExport().Add(ExtraName, f.GetStore().Bytes); + } + + public static void Serialize(glTFMesh gltfMesh, IEnumerable targetNames) + { + // targetNames + var f = new JsonFormatter(); + f.BeginList(); + foreach (var n in targetNames) + { + f.Value(n); + } + f.EndList(); + var targetNamesJson = f.GetStore().Bytes; + + var meshExtras = glTFExtensionExport.GetOrCreate(ref gltfMesh.extras); + meshExtras.Add(ExtraName, targetNamesJson); + + foreach (var prim in gltfMesh.primitives) + { + var primExtras = glTFExtensionExport.GetOrCreate(ref prim.extras); + primExtras.Add(ExtraName, targetNamesJson); + } + } + } +} diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltf_mesh_extras_targetNames.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltf_mesh_extras_targetNames.cs.meta new file mode 100644 index 000000000..abfe5354b --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/ExtensionsAndExtras/gltf_mesh_extras_targetNames.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c8450226c96b1454483cab736a03a337 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfDeserializer.g.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfDeserializer.g.cs new file mode 100644 index 000000000..d191df58b --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfDeserializer.g.cs @@ -0,0 +1,1726 @@ +using UniJSON; +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace UniGLTF { + +public static class GltfDeserializer +{ + + +public static glTF Deserialize(ListTreeNode parsed) +{ + var value = new glTF(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="asset"){ + value.asset = Deserialize_gltf_asset(kv.Value); + continue; + } + + if(key=="buffers"){ + value.buffers = Deserialize_gltf_buffers(kv.Value); + continue; + } + + if(key=="bufferViews"){ + value.bufferViews = Deserialize_gltf_bufferViews(kv.Value); + continue; + } + + if(key=="accessors"){ + value.accessors = Deserialize_gltf_accessors(kv.Value); + continue; + } + + if(key=="textures"){ + value.textures = Deserialize_gltf_textures(kv.Value); + continue; + } + + if(key=="samplers"){ + value.samplers = Deserialize_gltf_samplers(kv.Value); + continue; + } + + if(key=="images"){ + value.images = Deserialize_gltf_images(kv.Value); + continue; + } + + if(key=="materials"){ + value.materials = Deserialize_gltf_materials(kv.Value); + continue; + } + + if(key=="meshes"){ + value.meshes = Deserialize_gltf_meshes(kv.Value); + continue; + } + + if(key=="nodes"){ + value.nodes = Deserialize_gltf_nodes(kv.Value); + continue; + } + + if(key=="skins"){ + value.skins = Deserialize_gltf_skins(kv.Value); + continue; + } + + if(key=="scene"){ + value.scene = kv.Value.GetInt32(); + continue; + } + + if(key=="scenes"){ + value.scenes = Deserialize_gltf_scenes(kv.Value); + continue; + } + + if(key=="animations"){ + value.animations = Deserialize_gltf_animations(kv.Value); + continue; + } + + if(key=="cameras"){ + value.cameras = Deserialize_gltf_cameras(kv.Value); + continue; + } + + if(key=="extensionsUsed"){ + value.extensionsUsed = Deserialize_gltf_extensionsUsed(kv.Value); + continue; + } + + if(key=="extensionsRequired"){ + value.extensionsRequired = Deserialize_gltf_extensionsRequired(kv.Value); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFAssets Deserialize_gltf_asset(ListTreeNode parsed) +{ + var value = new glTFAssets(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="generator"){ + value.generator = kv.Value.GetString(); + continue; + } + + if(key=="version"){ + value.version = kv.Value.GetString(); + continue; + } + + if(key=="copyright"){ + value.copyright = kv.Value.GetString(); + continue; + } + + if(key=="minVersion"){ + value.minVersion = kv.Value.GetString(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_buffers(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_buffers_LIST(x)); + } + return value; +} +public static glTFBuffer Deserialize_gltf_buffers_LIST(ListTreeNode parsed) +{ + var value = new glTFBuffer(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="uri"){ + value.uri = kv.Value.GetString(); + continue; + } + + if(key=="byteLength"){ + value.byteLength = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_bufferViews(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_bufferViews_LIST(x)); + } + return value; +} +public static glTFBufferView Deserialize_gltf_bufferViews_LIST(ListTreeNode parsed) +{ + var value = new glTFBufferView(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="buffer"){ + value.buffer = kv.Value.GetInt32(); + continue; + } + + if(key=="byteOffset"){ + value.byteOffset = kv.Value.GetInt32(); + continue; + } + + if(key=="byteLength"){ + value.byteLength = kv.Value.GetInt32(); + continue; + } + + if(key=="byteStride"){ + value.byteStride = kv.Value.GetInt32(); + continue; + } + + if(key=="target"){ + value.target = (glBufferTarget)kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_accessors(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_accessors_LIST(x)); + } + return value; +} +public static glTFAccessor Deserialize_gltf_accessors_LIST(ListTreeNode parsed) +{ + var value = new glTFAccessor(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="bufferView"){ + value.bufferView = kv.Value.GetInt32(); + continue; + } + + if(key=="byteOffset"){ + value.byteOffset = kv.Value.GetInt32(); + continue; + } + + if(key=="type"){ + value.type = kv.Value.GetString(); + continue; + } + + if(key=="componentType"){ + value.componentType = (glComponentType)kv.Value.GetInt32(); + continue; + } + + if(key=="count"){ + value.count = kv.Value.GetInt32(); + continue; + } + + if(key=="max"){ + value.max = Deserialize_gltf_accessors__max(kv.Value); + continue; + } + + if(key=="min"){ + value.min = Deserialize_gltf_accessors__min(kv.Value); + continue; + } + + if(key=="normalized"){ + value.normalized = kv.Value.GetBoolean(); + continue; + } + + if(key=="sparse"){ + value.sparse = Deserialize_gltf_accessors__sparse(kv.Value); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_accessors__max(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static Single[] Deserialize_gltf_accessors__min(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static glTFSparse Deserialize_gltf_accessors__sparse(ListTreeNode parsed) +{ + var value = new glTFSparse(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="count"){ + value.count = kv.Value.GetInt32(); + continue; + } + + if(key=="indices"){ + value.indices = Deserialize_gltf_accessors__sparse_indices(kv.Value); + continue; + } + + if(key=="values"){ + value.values = Deserialize_gltf_accessors__sparse_values(kv.Value); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFSparseIndices Deserialize_gltf_accessors__sparse_indices(ListTreeNode parsed) +{ + var value = new glTFSparseIndices(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="bufferView"){ + value.bufferView = kv.Value.GetInt32(); + continue; + } + + if(key=="byteOffset"){ + value.byteOffset = kv.Value.GetInt32(); + continue; + } + + if(key=="componentType"){ + value.componentType = (glComponentType)kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFSparseValues Deserialize_gltf_accessors__sparse_values(ListTreeNode parsed) +{ + var value = new glTFSparseValues(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="bufferView"){ + value.bufferView = kv.Value.GetInt32(); + continue; + } + + if(key=="byteOffset"){ + value.byteOffset = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_textures(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_textures_LIST(x)); + } + return value; +} +public static glTFTexture Deserialize_gltf_textures_LIST(ListTreeNode parsed) +{ + var value = new glTFTexture(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="sampler"){ + value.sampler = kv.Value.GetInt32(); + continue; + } + + if(key=="source"){ + value.source = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_samplers(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_samplers_LIST(x)); + } + return value; +} +public static glTFTextureSampler Deserialize_gltf_samplers_LIST(ListTreeNode parsed) +{ + var value = new glTFTextureSampler(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="magFilter"){ + value.magFilter = (glFilter)kv.Value.GetInt32(); + continue; + } + + if(key=="minFilter"){ + value.minFilter = (glFilter)kv.Value.GetInt32(); + continue; + } + + if(key=="wrapS"){ + value.wrapS = (glWrap)kv.Value.GetInt32(); + continue; + } + + if(key=="wrapT"){ + value.wrapT = (glWrap)kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_images(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_images_LIST(x)); + } + return value; +} +public static glTFImage Deserialize_gltf_images_LIST(ListTreeNode parsed) +{ + var value = new glTFImage(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="uri"){ + value.uri = kv.Value.GetString(); + continue; + } + + if(key=="bufferView"){ + value.bufferView = kv.Value.GetInt32(); + continue; + } + + if(key=="mimeType"){ + value.mimeType = kv.Value.GetString(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_materials(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_materials_LIST(x)); + } + return value; +} +public static glTFMaterial Deserialize_gltf_materials_LIST(ListTreeNode parsed) +{ + var value = new glTFMaterial(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="pbrMetallicRoughness"){ + value.pbrMetallicRoughness = Deserialize_gltf_materials__pbrMetallicRoughness(kv.Value); + continue; + } + + if(key=="normalTexture"){ + value.normalTexture = Deserialize_gltf_materials__normalTexture(kv.Value); + continue; + } + + if(key=="occlusionTexture"){ + value.occlusionTexture = Deserialize_gltf_materials__occlusionTexture(kv.Value); + continue; + } + + if(key=="emissiveTexture"){ + value.emissiveTexture = Deserialize_gltf_materials__emissiveTexture(kv.Value); + continue; + } + + if(key=="emissiveFactor"){ + value.emissiveFactor = Deserialize_gltf_materials__emissiveFactor(kv.Value); + continue; + } + + if(key=="alphaMode"){ + value.alphaMode = kv.Value.GetString(); + continue; + } + + if(key=="alphaCutoff"){ + value.alphaCutoff = kv.Value.GetSingle(); + continue; + } + + if(key=="doubleSided"){ + value.doubleSided = kv.Value.GetBoolean(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFPbrMetallicRoughness Deserialize_gltf_materials__pbrMetallicRoughness(ListTreeNode parsed) +{ + var value = new glTFPbrMetallicRoughness(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="baseColorTexture"){ + value.baseColorTexture = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(kv.Value); + continue; + } + + if(key=="baseColorFactor"){ + value.baseColorFactor = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(kv.Value); + continue; + } + + if(key=="metallicRoughnessTexture"){ + value.metallicRoughnessTexture = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture(kv.Value); + continue; + } + + if(key=="metallicFactor"){ + value.metallicFactor = kv.Value.GetSingle(); + continue; + } + + if(key=="roughnessFactor"){ + value.roughnessFactor = kv.Value.GetSingle(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFMaterialBaseColorTextureInfo Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(ListTreeNode parsed) +{ + var value = new glTFMaterialBaseColorTextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static glTFMaterialMetallicRoughnessTextureInfo Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture(ListTreeNode parsed) +{ + var value = new glTFMaterialMetallicRoughnessTextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFMaterialNormalTextureInfo Deserialize_gltf_materials__normalTexture(ListTreeNode parsed) +{ + var value = new glTFMaterialNormalTextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="scale"){ + value.scale = kv.Value.GetSingle(); + continue; + } + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFMaterialOcclusionTextureInfo Deserialize_gltf_materials__occlusionTexture(ListTreeNode parsed) +{ + var value = new glTFMaterialOcclusionTextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="strength"){ + value.strength = kv.Value.GetSingle(); + continue; + } + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFMaterialEmissiveTextureInfo Deserialize_gltf_materials__emissiveTexture(ListTreeNode parsed) +{ + var value = new glTFMaterialEmissiveTextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.texCoord = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_materials__emissiveFactor(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static List Deserialize_gltf_meshes(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_meshes_LIST(x)); + } + return value; +} +public static glTFMesh Deserialize_gltf_meshes_LIST(ListTreeNode parsed) +{ + var value = new glTFMesh(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="primitives"){ + value.primitives = Deserialize_gltf_meshes__primitives(kv.Value); + continue; + } + + if(key=="weights"){ + value.weights = Deserialize_gltf_meshes__weights(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_meshes__primitives(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_meshes__primitives_LIST(x)); + } + return value; +} +public static glTFPrimitives Deserialize_gltf_meshes__primitives_LIST(ListTreeNode parsed) +{ + var value = new glTFPrimitives(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="mode"){ + value.mode = kv.Value.GetInt32(); + continue; + } + + if(key=="indices"){ + value.indices = kv.Value.GetInt32(); + continue; + } + + if(key=="attributes"){ + value.attributes = Deserialize_gltf_meshes__primitives__attributes(kv.Value); + continue; + } + + if(key=="material"){ + value.material = kv.Value.GetInt32(); + continue; + } + + if(key=="targets"){ + value.targets = Deserialize_gltf_meshes__primitives__targets(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFAttributes Deserialize_gltf_meshes__primitives__attributes(ListTreeNode parsed) +{ + var value = new glTFAttributes(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="POSITION"){ + value.POSITION = kv.Value.GetInt32(); + continue; + } + + if(key=="NORMAL"){ + value.NORMAL = kv.Value.GetInt32(); + continue; + } + + if(key=="TANGENT"){ + value.TANGENT = kv.Value.GetInt32(); + continue; + } + + if(key=="TEXCOORD_0"){ + value.TEXCOORD_0 = kv.Value.GetInt32(); + continue; + } + + if(key=="TEXCOORD_1"){ + value.TEXCOORD_1 = kv.Value.GetInt32(); + continue; + } + + if(key=="COLOR_0"){ + value.COLOR_0 = kv.Value.GetInt32(); + continue; + } + + if(key=="JOINTS_0"){ + value.JOINTS_0 = kv.Value.GetInt32(); + continue; + } + + if(key=="WEIGHTS_0"){ + value.WEIGHTS_0 = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_meshes__primitives__targets(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_meshes__primitives__targets_LIST(x)); + } + return value; +} +public static gltfMorphTarget Deserialize_gltf_meshes__primitives__targets_LIST(ListTreeNode parsed) +{ + var value = new gltfMorphTarget(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="POSITION"){ + value.POSITION = kv.Value.GetInt32(); + continue; + } + + if(key=="NORMAL"){ + value.NORMAL = kv.Value.GetInt32(); + continue; + } + + if(key=="TANGENT"){ + value.TANGENT = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_gltf_meshes__weights(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static List Deserialize_gltf_nodes(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_nodes_LIST(x)); + } + return value; +} +public static glTFNode Deserialize_gltf_nodes_LIST(ListTreeNode parsed) +{ + var value = new glTFNode(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="children"){ + value.children = Deserialize_gltf_nodes__children(kv.Value); + continue; + } + + if(key=="matrix"){ + value.matrix = Deserialize_gltf_nodes__matrix(kv.Value); + continue; + } + + if(key=="translation"){ + value.translation = Deserialize_gltf_nodes__translation(kv.Value); + continue; + } + + if(key=="rotation"){ + value.rotation = Deserialize_gltf_nodes__rotation(kv.Value); + continue; + } + + if(key=="scale"){ + value.scale = Deserialize_gltf_nodes__scale(kv.Value); + continue; + } + + if(key=="mesh"){ + value.mesh = kv.Value.GetInt32(); + continue; + } + + if(key=="skin"){ + value.skin = kv.Value.GetInt32(); + continue; + } + + if(key=="weights"){ + value.weights = Deserialize_gltf_nodes__weights(kv.Value); + continue; + } + + if(key=="camera"){ + value.camera = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static Int32[] Deserialize_gltf_nodes__children(ListTreeNode parsed) +{ + var value = new Int32[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetInt32(); + } + return value; +} + +public static Single[] Deserialize_gltf_nodes__matrix(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static Single[] Deserialize_gltf_nodes__translation(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static Single[] Deserialize_gltf_nodes__rotation(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static Single[] Deserialize_gltf_nodes__scale(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static Single[] Deserialize_gltf_nodes__weights(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static List Deserialize_gltf_skins(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_skins_LIST(x)); + } + return value; +} +public static glTFSkin Deserialize_gltf_skins_LIST(ListTreeNode parsed) +{ + var value = new glTFSkin(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="inverseBindMatrices"){ + value.inverseBindMatrices = kv.Value.GetInt32(); + continue; + } + + if(key=="joints"){ + value.joints = Deserialize_gltf_skins__joints(kv.Value); + continue; + } + + if(key=="skeleton"){ + value.skeleton = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static Int32[] Deserialize_gltf_skins__joints(ListTreeNode parsed) +{ + var value = new Int32[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetInt32(); + } + return value; +} + +public static List Deserialize_gltf_scenes(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_scenes_LIST(x)); + } + return value; +} +public static gltfScene Deserialize_gltf_scenes_LIST(ListTreeNode parsed) +{ + var value = new gltfScene(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="nodes"){ + value.nodes = Deserialize_gltf_scenes__nodes(kv.Value); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static Int32[] Deserialize_gltf_scenes__nodes(ListTreeNode parsed) +{ + var value = new Int32[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetInt32(); + } + return value; +} + +public static List Deserialize_gltf_animations(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_animations_LIST(x)); + } + return value; +} +public static glTFAnimation Deserialize_gltf_animations_LIST(ListTreeNode parsed) +{ + var value = new glTFAnimation(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="channels"){ + value.channels = Deserialize_gltf_animations__channels(kv.Value); + continue; + } + + if(key=="samplers"){ + value.samplers = Deserialize_gltf_animations__samplers(kv.Value); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_animations__channels(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_animations__channels_LIST(x)); + } + return value; +} +public static glTFAnimationChannel Deserialize_gltf_animations__channels_LIST(ListTreeNode parsed) +{ + var value = new glTFAnimationChannel(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="sampler"){ + value.sampler = kv.Value.GetInt32(); + continue; + } + + if(key=="target"){ + value.target = Deserialize_gltf_animations__channels__target(kv.Value); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFAnimationTarget Deserialize_gltf_animations__channels__target(ListTreeNode parsed) +{ + var value = new glTFAnimationTarget(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="node"){ + value.node = kv.Value.GetInt32(); + continue; + } + + if(key=="path"){ + value.path = kv.Value.GetString(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_animations__samplers(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_animations__samplers_LIST(x)); + } + return value; +} +public static glTFAnimationSampler Deserialize_gltf_animations__samplers_LIST(ListTreeNode parsed) +{ + var value = new glTFAnimationSampler(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="input"){ + value.input = kv.Value.GetInt32(); + continue; + } + + if(key=="interpolation"){ + value.interpolation = kv.Value.GetString(); + continue; + } + + if(key=="output"){ + value.output = kv.Value.GetInt32(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_cameras(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_gltf_cameras_LIST(x)); + } + return value; +} +public static glTFCamera Deserialize_gltf_cameras_LIST(ListTreeNode parsed) +{ + var value = new glTFCamera(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="orthographic"){ + value.orthographic = Deserialize_gltf_cameras__orthographic(kv.Value); + continue; + } + + if(key=="perspective"){ + value.perspective = Deserialize_gltf_cameras__perspective(kv.Value); + continue; + } + + if(key=="type"){ + value.type = (ProjectionType)Enum.Parse(typeof(ProjectionType), kv.Value.GetString(), true); + continue; + } + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFOrthographic Deserialize_gltf_cameras__orthographic(ListTreeNode parsed) +{ + var value = new glTFOrthographic(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="xmag"){ + value.xmag = kv.Value.GetSingle(); + continue; + } + + if(key=="ymag"){ + value.ymag = kv.Value.GetSingle(); + continue; + } + + if(key=="zfar"){ + value.zfar = kv.Value.GetSingle(); + continue; + } + + if(key=="znear"){ + value.znear = kv.Value.GetSingle(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static glTFPerspective Deserialize_gltf_cameras__perspective(ListTreeNode parsed) +{ + var value = new glTFPerspective(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="aspectRatio"){ + value.aspectRatio = kv.Value.GetSingle(); + continue; + } + + if(key=="yfov"){ + value.yfov = kv.Value.GetSingle(); + continue; + } + + if(key=="zfar"){ + value.zfar = kv.Value.GetSingle(); + continue; + } + + if(key=="znear"){ + value.znear = kv.Value.GetSingle(); + continue; + } + + if(key=="extensions"){ + value.extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.extras = new glTFExtensionImport(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_gltf_extensionsUsed(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(x.GetString()); + } + return value; +} +public static List Deserialize_gltf_extensionsRequired(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(x.GetString()); + } + return value; +} +} // GltfDeserializer +} // UniGLTF diff --git a/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfDeserializer.g.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/GltfDeserializer.g.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs new file mode 100644 index 000000000..313d10bd0 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs @@ -0,0 +1,1667 @@ +using System; +using System.Collections.Generic; +using UniJSON; + +namespace UniGLTF { + + static public class GltfSerializer + { + + +public static void Serialize(JsonFormatter f, glTF value) +{ + f.BeginMap(); + + + if(value.asset!=null){ + f.Key("asset"); + Serialize_gltf_asset(f, value.asset); + } + + if(value.buffers!=null&&value.buffers.Count>=1){ + f.Key("buffers"); + Serialize_gltf_buffers(f, value.buffers); + } + + if(value.bufferViews!=null&&value.bufferViews.Count>=1){ + f.Key("bufferViews"); + Serialize_gltf_bufferViews(f, value.bufferViews); + } + + if(value.accessors!=null&&value.accessors.Count>=1){ + f.Key("accessors"); + Serialize_gltf_accessors(f, value.accessors); + } + + if(value.textures!=null&&value.textures.Count>=1){ + f.Key("textures"); + Serialize_gltf_textures(f, value.textures); + } + + if(value.samplers!=null&&value.samplers.Count>=1){ + f.Key("samplers"); + Serialize_gltf_samplers(f, value.samplers); + } + + if(value.images!=null&&value.images.Count>=1){ + f.Key("images"); + Serialize_gltf_images(f, value.images); + } + + if(value.materials!=null&&value.materials.Count>=1){ + f.Key("materials"); + Serialize_gltf_materials(f, value.materials); + } + + if(value.meshes!=null&&value.meshes.Count>=1){ + f.Key("meshes"); + Serialize_gltf_meshes(f, value.meshes); + } + + if(value.nodes!=null&&value.nodes.Count>=1){ + f.Key("nodes"); + Serialize_gltf_nodes(f, value.nodes); + } + + if(value.skins!=null&&value.skins.Count>=1){ + f.Key("skins"); + Serialize_gltf_skins(f, value.skins); + } + + if(value.scene>=0){ + f.Key("scene"); + f.Value(value.scene); + } + + if(value.scenes!=null&&value.scenes.Count>=1){ + f.Key("scenes"); + Serialize_gltf_scenes(f, value.scenes); + } + + if(value.animations!=null&&value.animations.Count>=1){ + f.Key("animations"); + Serialize_gltf_animations(f, value.animations); + } + + if(value.cameras!=null&&value.cameras.Count>=1){ + f.Key("cameras"); + Serialize_gltf_cameras(f, value.cameras); + } + + if(value.extensionsUsed!=null&&value.extensionsUsed.Count>=1){ + f.Key("extensionsUsed"); + Serialize_gltf_extensionsUsed(f, value.extensionsUsed); + } + + if(value.extensionsRequired!=null&&value.extensionsRequired.Count>=1){ + f.Key("extensionsRequired"); + Serialize_gltf_extensionsRequired(f, value.extensionsRequired); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_asset(JsonFormatter f, glTFAssets value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.generator)){ + f.Key("generator"); + f.Value(value.generator); + } + + if(!string.IsNullOrEmpty(value.version)){ + f.Key("version"); + f.Value(value.version); + } + + if(!string.IsNullOrEmpty(value.copyright)){ + f.Key("copyright"); + f.Value(value.copyright); + } + + if(!string.IsNullOrEmpty(value.minVersion)){ + f.Key("minVersion"); + f.Value(value.minVersion); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_buffers(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_buffers_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_buffers_ITEM(JsonFormatter f, glTFBuffer value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.uri)){ + f.Key("uri"); + f.Value(value.uri); + } + + if(value.byteLength>=1){ + f.Key("byteLength"); + f.Value(value.byteLength); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + f.EndMap(); +} + +public static void Serialize_gltf_bufferViews(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_bufferViews_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_bufferViews_ITEM(JsonFormatter f, glTFBufferView value) +{ + f.BeginMap(); + + + if(value.buffer>=0){ + f.Key("buffer"); + f.Value(value.buffer); + } + + if(value.byteOffset>=0){ + f.Key("byteOffset"); + f.Value(value.byteOffset); + } + + if(value.byteLength>=1){ + f.Key("byteLength"); + f.Value(value.byteLength); + } + + if(value.byteStride>=4&&false){ + f.Key("byteStride"); + f.Value(value.byteStride); + } + + if(true&&value.target!=0){ + f.Key("target"); + f.Value((int)value.target); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + f.EndMap(); +} + +public static void Serialize_gltf_accessors(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_accessors_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_accessors_ITEM(JsonFormatter f, glTFAccessor value) +{ + f.BeginMap(); + + + if(value.bufferView>=0){ + f.Key("bufferView"); + f.Value(value.bufferView); + } + + if(value.byteOffset>=0){ + f.Key("byteOffset"); + f.Value(value.byteOffset); + } + + if(!string.IsNullOrEmpty(value.type)){ + f.Key("type"); + f.Value(value.type); + } + + if(true){ + f.Key("componentType"); + f.Value((int)value.componentType); + } + + if(value.count>=1){ + f.Key("count"); + f.Value(value.count); + } + + if(value.max!=null&&value.max.Length>=1){ + f.Key("max"); + Serialize_gltf_accessors__max(f, value.max); + } + + if(value.min!=null&&value.min.Length>=1){ + f.Key("min"); + Serialize_gltf_accessors__min(f, value.min); + } + + if(true){ + f.Key("normalized"); + f.Value(value.normalized); + } + + if(value.sparse!=null){ + f.Key("sparse"); + Serialize_gltf_accessors__sparse(f, value.sparse); + } + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_accessors__max(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_accessors__min(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_accessors__sparse(JsonFormatter f, glTFSparse value) +{ + f.BeginMap(); + + + if(value.count>=1){ + f.Key("count"); + f.Value(value.count); + } + + if(value.indices!=null){ + f.Key("indices"); + Serialize_gltf_accessors__sparse_indices(f, value.indices); + } + + if(value.values!=null){ + f.Key("values"); + Serialize_gltf_accessors__sparse_values(f, value.values); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_accessors__sparse_indices(JsonFormatter f, glTFSparseIndices value) +{ + f.BeginMap(); + + + if(value.bufferView>=0){ + f.Key("bufferView"); + f.Value(value.bufferView); + } + + if(value.byteOffset>=0){ + f.Key("byteOffset"); + f.Value(value.byteOffset); + } + + if(true){ + f.Key("componentType"); + f.Value((int)value.componentType); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_accessors__sparse_values(JsonFormatter f, glTFSparseValues value) +{ + f.BeginMap(); + + + if(value.bufferView>=0){ + f.Key("bufferView"); + f.Value(value.bufferView); + } + + if(value.byteOffset>=0){ + f.Key("byteOffset"); + f.Value(value.byteOffset); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_textures(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_textures_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_textures_ITEM(JsonFormatter f, glTFTexture value) +{ + f.BeginMap(); + + + if(value.sampler>=0){ + f.Key("sampler"); + f.Value(value.sampler); + } + + if(value.source>=0){ + f.Key("source"); + f.Value(value.source); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + f.EndMap(); +} + +public static void Serialize_gltf_samplers(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_samplers_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_samplers_ITEM(JsonFormatter f, glTFTextureSampler value) +{ + f.BeginMap(); + + + if(true){ + f.Key("magFilter"); + f.Value((int)value.magFilter); + } + + if(true){ + f.Key("minFilter"); + f.Value((int)value.minFilter); + } + + if(true){ + f.Key("wrapS"); + f.Value((int)value.wrapS); + } + + if(true){ + f.Key("wrapT"); + f.Value((int)value.wrapT); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + f.EndMap(); +} + +public static void Serialize_gltf_images(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_images_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_images_ITEM(JsonFormatter f, glTFImage value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + if(!string.IsNullOrEmpty(value.uri)){ + f.Key("uri"); + f.Value(value.uri); + } + + if(value.bufferView>=0){ + f.Key("bufferView"); + f.Value(value.bufferView); + } + + if(!string.IsNullOrEmpty(value.mimeType)){ + f.Key("mimeType"); + f.Value(value.mimeType); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_materials(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_materials_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_materials_ITEM(JsonFormatter f, glTFMaterial value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + if(value.pbrMetallicRoughness!=null){ + f.Key("pbrMetallicRoughness"); + Serialize_gltf_materials__pbrMetallicRoughness(f, value.pbrMetallicRoughness); + } + + if(value.normalTexture!=null){ + f.Key("normalTexture"); + Serialize_gltf_materials__normalTexture(f, value.normalTexture); + } + + if(value.occlusionTexture!=null){ + f.Key("occlusionTexture"); + Serialize_gltf_materials__occlusionTexture(f, value.occlusionTexture); + } + + if(value.emissiveTexture!=null){ + f.Key("emissiveTexture"); + Serialize_gltf_materials__emissiveTexture(f, value.emissiveTexture); + } + + if(value.emissiveFactor!=null&&value.emissiveFactor.Length>=3){ + f.Key("emissiveFactor"); + Serialize_gltf_materials__emissiveFactor(f, value.emissiveFactor); + } + + if(!string.IsNullOrEmpty(value.alphaMode)){ + f.Key("alphaMode"); + f.Value(value.alphaMode); + } + + if(value.alphaCutoff>=0&&value.alphaMode=="MASK"){ + f.Key("alphaCutoff"); + f.Value(value.alphaCutoff); + } + + if(true){ + f.Key("doubleSided"); + f.Value(value.doubleSided); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_materials__pbrMetallicRoughness(JsonFormatter f, glTFPbrMetallicRoughness value) +{ + f.BeginMap(); + + + if(value.baseColorTexture!=null){ + f.Key("baseColorTexture"); + Serialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(f, value.baseColorTexture); + } + + if(value.baseColorFactor!=null&&value.baseColorFactor.Length>=4){ + f.Key("baseColorFactor"); + Serialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(f, value.baseColorFactor); + } + + if(value.metallicRoughnessTexture!=null){ + f.Key("metallicRoughnessTexture"); + Serialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture(f, value.metallicRoughnessTexture); + } + + if(value.metallicFactor>=0){ + f.Key("metallicFactor"); + f.Value(value.metallicFactor); + } + + if(value.roughnessFactor>=0){ + f.Key("roughnessFactor"); + f.Value(value.roughnessFactor); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(JsonFormatter f, glTFMaterialBaseColorTextureInfo value) +{ + f.BeginMap(); + + + if(value.index>=0){ + f.Key("index"); + f.Value(value.index); + } + + if(value.texCoord>=0){ + f.Key("texCoord"); + f.Value(value.texCoord); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture(JsonFormatter f, glTFMaterialMetallicRoughnessTextureInfo value) +{ + f.BeginMap(); + + + if(value.index>=0){ + f.Key("index"); + f.Value(value.index); + } + + if(value.texCoord>=0){ + f.Key("texCoord"); + f.Value(value.texCoord); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_materials__normalTexture(JsonFormatter f, glTFMaterialNormalTextureInfo value) +{ + f.BeginMap(); + + + if(true){ + f.Key("scale"); + f.Value(value.scale); + } + + if(value.index>=0){ + f.Key("index"); + f.Value(value.index); + } + + if(value.texCoord>=0){ + f.Key("texCoord"); + f.Value(value.texCoord); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_materials__occlusionTexture(JsonFormatter f, glTFMaterialOcclusionTextureInfo value) +{ + f.BeginMap(); + + + if(value.strength>=0){ + f.Key("strength"); + f.Value(value.strength); + } + + if(value.index>=0){ + f.Key("index"); + f.Value(value.index); + } + + if(value.texCoord>=0){ + f.Key("texCoord"); + f.Value(value.texCoord); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_materials__emissiveTexture(JsonFormatter f, glTFMaterialEmissiveTextureInfo value) +{ + f.BeginMap(); + + + if(value.index>=0){ + f.Key("index"); + f.Value(value.index); + } + + if(value.texCoord>=0){ + f.Key("texCoord"); + f.Value(value.texCoord); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_materials__emissiveFactor(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_meshes(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_meshes_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_meshes_ITEM(JsonFormatter f, glTFMesh value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + if(value.primitives!=null&&value.primitives.Count>=1){ + f.Key("primitives"); + Serialize_gltf_meshes__primitives(f, value.primitives); + } + + if(value.weights!=null&&value.weights.Length>=1){ + f.Key("weights"); + Serialize_gltf_meshes__weights(f, value.weights); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_meshes__primitives(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_meshes__primitives_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_meshes__primitives_ITEM(JsonFormatter f, glTFPrimitives value) +{ + f.BeginMap(); + + + if(true){ + f.Key("mode"); + f.Value(value.mode); + } + + if(value.indices>=0){ + f.Key("indices"); + f.Value(value.indices); + } + + if(value.attributes!=null){ + f.Key("attributes"); + Serialize_gltf_meshes__primitives__attributes(f, value.attributes); + } + + if(value.material>=0){ + f.Key("material"); + f.Value(value.material); + } + + if(value.targets!=null&&value.targets.Count>=1){ + f.Key("targets"); + Serialize_gltf_meshes__primitives__targets(f, value.targets); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_meshes__primitives__attributes(JsonFormatter f, glTFAttributes value) +{ + f.BeginMap(); + + + if(value.POSITION>=0){ + f.Key("POSITION"); + f.Value(value.POSITION); + } + + if(value.NORMAL>=0){ + f.Key("NORMAL"); + f.Value(value.NORMAL); + } + + if(value.TANGENT>=0){ + f.Key("TANGENT"); + f.Value(value.TANGENT); + } + + if(value.TEXCOORD_0>=0){ + f.Key("TEXCOORD_0"); + f.Value(value.TEXCOORD_0); + } + + if(value.TEXCOORD_1>=0){ + f.Key("TEXCOORD_1"); + f.Value(value.TEXCOORD_1); + } + + if(value.COLOR_0>=0){ + f.Key("COLOR_0"); + f.Value(value.COLOR_0); + } + + if(value.JOINTS_0>=0){ + f.Key("JOINTS_0"); + f.Value(value.JOINTS_0); + } + + if(value.WEIGHTS_0>=0){ + f.Key("WEIGHTS_0"); + f.Value(value.WEIGHTS_0); + } + + f.EndMap(); +} + +public static void Serialize_gltf_meshes__primitives__targets(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_meshes__primitives__targets_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_meshes__primitives__targets_ITEM(JsonFormatter f, gltfMorphTarget value) +{ + f.BeginMap(); + + + if(value.POSITION>=0){ + f.Key("POSITION"); + f.Value(value.POSITION); + } + + if(value.NORMAL>=0){ + f.Key("NORMAL"); + f.Value(value.NORMAL); + } + + if(value.TANGENT>=0){ + f.Key("TANGENT"); + f.Value(value.TANGENT); + } + + f.EndMap(); +} + +public static void Serialize_gltf_meshes__weights(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_nodes(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_nodes_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_nodes_ITEM(JsonFormatter f, glTFNode value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + if(value.children!=null&&value.children.Length>=1){ + f.Key("children"); + Serialize_gltf_nodes__children(f, value.children); + } + + if(value.matrix!=null&&value.matrix.Length>=16){ + f.Key("matrix"); + Serialize_gltf_nodes__matrix(f, value.matrix); + } + + if(value.translation!=null&&value.translation.Length>=3){ + f.Key("translation"); + Serialize_gltf_nodes__translation(f, value.translation); + } + + if(value.rotation!=null&&value.rotation.Length>=4){ + f.Key("rotation"); + Serialize_gltf_nodes__rotation(f, value.rotation); + } + + if(value.scale!=null&&value.scale.Length>=3){ + f.Key("scale"); + Serialize_gltf_nodes__scale(f, value.scale); + } + + if(value.mesh>=0){ + f.Key("mesh"); + f.Value(value.mesh); + } + + if(value.skin>=0){ + f.Key("skin"); + f.Value(value.skin); + } + + if(value.weights!=null&&value.weights.Length>=1){ + f.Key("weights"); + Serialize_gltf_nodes__weights(f, value.weights); + } + + if(value.camera>=0){ + f.Key("camera"); + f.Value(value.camera); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_nodes__children(JsonFormatter f, Int32[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_nodes__matrix(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_nodes__translation(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_nodes__rotation(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_nodes__scale(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_nodes__weights(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_skins(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_skins_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_skins_ITEM(JsonFormatter f, glTFSkin value) +{ + f.BeginMap(); + + + if(value.inverseBindMatrices>=0){ + f.Key("inverseBindMatrices"); + f.Value(value.inverseBindMatrices); + } + + if(value.joints!=null&&value.joints.Length>=1){ + f.Key("joints"); + Serialize_gltf_skins__joints(f, value.joints); + } + + if(value.skeleton>=0){ + f.Key("skeleton"); + f.Value(value.skeleton); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + f.EndMap(); +} + +public static void Serialize_gltf_skins__joints(JsonFormatter f, Int32[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_scenes(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_scenes_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_scenes_ITEM(JsonFormatter f, gltfScene value) +{ + f.BeginMap(); + + + if(value.nodes!=null&&value.nodes.Length>=1){ + f.Key("nodes"); + Serialize_gltf_scenes__nodes(f, value.nodes); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + f.EndMap(); +} + +public static void Serialize_gltf_scenes__nodes(JsonFormatter f, Int32[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_animations(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_animations_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_animations_ITEM(JsonFormatter f, glTFAnimation value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + if(value.channels!=null&&value.channels.Count>=1){ + f.Key("channels"); + Serialize_gltf_animations__channels(f, value.channels); + } + + if(value.samplers!=null&&value.samplers.Count>=1){ + f.Key("samplers"); + Serialize_gltf_animations__samplers(f, value.samplers); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_animations__channels(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_animations__channels_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_animations__channels_ITEM(JsonFormatter f, glTFAnimationChannel value) +{ + f.BeginMap(); + + + if(value.sampler>=0){ + f.Key("sampler"); + f.Value(value.sampler); + } + + if(value.target!=null){ + f.Key("target"); + Serialize_gltf_animations__channels__target(f, value.target); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_animations__channels__target(JsonFormatter f, glTFAnimationTarget value) +{ + f.BeginMap(); + + + if(value.node>=0){ + f.Key("node"); + f.Value(value.node); + } + + if(!string.IsNullOrEmpty(value.path)){ + f.Key("path"); + f.Value(value.path); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_animations__samplers(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_animations__samplers_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_animations__samplers_ITEM(JsonFormatter f, glTFAnimationSampler value) +{ + f.BeginMap(); + + + if(value.input>=0){ + f.Key("input"); + f.Value(value.input); + } + + if(!string.IsNullOrEmpty(value.interpolation)){ + f.Key("interpolation"); + f.Value(value.interpolation); + } + + if(value.output>=0){ + f.Key("output"); + f.Value(value.output); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_cameras(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_gltf_cameras_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_gltf_cameras_ITEM(JsonFormatter f, glTFCamera value) +{ + f.BeginMap(); + + + if(value.orthographic!=null){ + f.Key("orthographic"); + Serialize_gltf_cameras__orthographic(f, value.orthographic); + } + + if(value.perspective!=null){ + f.Key("perspective"); + Serialize_gltf_cameras__perspective(f, value.perspective); + } + + if(true){ + f.Key("type"); + f.Value(value.type.ToString().ToLower()); + } + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_cameras__orthographic(JsonFormatter f, glTFOrthographic value) +{ + f.BeginMap(); + + + if(true){ + f.Key("xmag"); + f.Value(value.xmag); + } + + if(true){ + f.Key("ymag"); + f.Value(value.ymag); + } + + if(value.zfar>0){ + f.Key("zfar"); + f.Value(value.zfar); + } + + if(value.znear>=0){ + f.Key("znear"); + f.Value(value.znear); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_cameras__perspective(JsonFormatter f, glTFPerspective value) +{ + f.BeginMap(); + + + if(value.aspectRatio>0){ + f.Key("aspectRatio"); + f.Value(value.aspectRatio); + } + + if(value.yfov>0){ + f.Key("yfov"); + f.Value(value.yfov); + } + + if(value.zfar>0){ + f.Key("zfar"); + f.Value(value.zfar); + } + + if(value.znear>0){ + f.Key("znear"); + f.Value(value.znear); + } + + if(value.extensions!=null){ + f.Key("extensions"); + value.extensions.Serialize(f); + } + + if(value.extras!=null){ + f.Key("extras"); + value.extras.Serialize(f); + } + + f.EndMap(); +} + +public static void Serialize_gltf_extensionsUsed(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_gltf_extensionsRequired(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + + } // class +} // namespace diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs.meta new file mode 100644 index 000000000..ecfe3f10e --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/GltfSerializer.g.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0421d021918de864aab65cce94937b61 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/IBytesBuffer.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/IBytesBuffer.cs new file mode 100644 index 000000000..6984bb1ec --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/IBytesBuffer.cs @@ -0,0 +1,11 @@ +using System; + +namespace UniGLTF +{ + public interface IBytesBuffer + { + string Uri { get; } + ArraySegment GetBytes(); + glTFBufferView Extend(ArraySegment array, glBufferTarget target) where T : struct; + } +} diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/IBytesBuffer.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/IBytesBuffer.cs.meta new file mode 100644 index 000000000..2e4f187c0 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/IBytesBuffer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2ce69a95857efe041a1e3dd9d2e6c98b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs new file mode 100644 index 000000000..d12009ce2 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs @@ -0,0 +1,16 @@ +using System; + +namespace UniGLTF +{ + public interface IStorage + { + ArraySegment Get(string url); + + /// + /// Get original filepath if exists + /// + /// + /// + string GetPath(string url); + } +} diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs.meta new file mode 100644 index 000000000..d065e98f4 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6e3316b83a7396047839d12538e5db52 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonSchemaAttribute.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/JsonSchemaAttribute.cs similarity index 94% rename from Assets/VRM/UniJSON/Scripts/Json/JsonSchemaAttribute.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/JsonSchemaAttribute.cs index 21e13f5b9..000ac2967 100644 --- a/Assets/VRM/UniJSON/Scripts/Json/JsonSchemaAttribute.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/JsonSchemaAttribute.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Reflection; using System.Text; -namespace UniJSON +namespace UniGLTF { public enum EnumSerializationType { @@ -39,7 +39,7 @@ namespace UniJSON #endregion #region object - public ValueNodeType ValueType; + public UniJSON.ValueNodeType ValueType; public int MinProperties; public bool Required; public string[] Dependencies; @@ -51,7 +51,10 @@ namespace UniJSON public object[] EnumExcludes; #endregion - public PropertyExportFlags ExportFlags = PropertyExportFlags.Default; + // シリアライズ時の除外条件をハードコーディングする + public string[] SerializationConditions; + + // public PropertyExportFlags ExportFlags = PropertyExportFlags.Default; /// /// skip validator comparison diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/JsonSchemaAttribute.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/JsonSchemaAttribute.cs.meta new file mode 100644 index 000000000..2ee6c9d2d --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/JsonSchemaAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 648733606660ecc4d8b8b25e37c1194f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/UnityEngineCompatibility.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/UnityEngineCompatibility.cs new file mode 100644 index 000000000..3606ed0e3 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/UnityEngineCompatibility.cs @@ -0,0 +1,52 @@ +/// +/// Unity互換のためのダミー +/// + +#if UNITY_5_6_OR_NEWER +#else +using System; + +namespace UnityEngine +{ + public struct Vector2 + { + public float x; + public float y; + } + + public struct Vector3 : IEquatable + { + public float x; + public float y; + public float z; + + public static Vector3 zero => new Vector3(); + + public bool Equals(Vector3 other) + { + if (x != other.x) return false; + if (y != other.y) return false; + if (z != other.z) return false; + return true; + } + + public static bool operator ==(Vector3 lhs, Vector3 rhs) + { + return lhs.Equals(rhs); + } + + public static bool operator !=(Vector3 lhs, Vector3 rhs) + { + return !(lhs == rhs); + } + } + + public struct Vector4 + { + public float x; + public float y; + public float z; + public float w; + } +} +#endif diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/UnityEngineCompatibility.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/UnityEngineCompatibility.cs.meta new file mode 100644 index 000000000..520967fe6 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/UnityEngineCompatibility.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 967f9ca5fbe35cc42b1b5a294958ab41 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glEnum.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glEnum.cs similarity index 60% rename from Assets/VRM/UniGLTF/Scripts/Format/glEnum.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glEnum.cs index 1915c1d9d..0d943adfa 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/glEnum.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glEnum.cs @@ -17,6 +17,23 @@ namespace UniGLTF FLOAT = 5126, } + public static class glComponentTypeExtensions + { + public static int GetByteSize(this glComponentType self) + { + switch (self) + { + case glComponentType.BYTE: return 1; + case glComponentType.UNSIGNED_BYTE: return 1; + case glComponentType.SHORT: return 2; + case glComponentType.UNSIGNED_SHORT: return 2; + case glComponentType.UNSIGNED_INT: return 4; + case glComponentType.FLOAT: return 4; + default: throw new System.NotImplementedException(); + } + } + } + public enum glBufferTarget : int { NONE = 0, diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glEnum.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glEnum.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glEnum.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glEnum.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/glTF.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTF.cs new file mode 100644 index 000000000..d623afeaf --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTF.cs @@ -0,0 +1,186 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UniJSON; + + +namespace UniGLTF +{ + [Serializable] + public class gltfScene + { + [JsonSchema(MinItems = 1)] + [ItemJsonSchema(Minimum = 0)] + public int[] nodes; + + public glTFExtension extensions; + public glTFExtension extras; + public string name; + } + + [Serializable] + public class glTF : IEquatable + { + [JsonSchema(Required = true)] + public glTFAssets asset = new glTFAssets(); + + #region Buffer + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List buffers = new List(); + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List bufferViews = new List(); + public int AddBufferView(glTFBufferView view) + { + var index = bufferViews.Count; + bufferViews.Add(view); + return index; + } + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List accessors = new List(); + + public ArraySegment GetViewBytes(int bufferView) + { + var view = bufferViews[bufferView]; + var segment = buffers[view.buffer].GetBytes(); + return new ArraySegment(segment.Array, segment.Offset + view.byteOffset, view.byteLength); + } + #endregion + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List textures = new List(); + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List samplers = new List(); + public glTFTextureSampler GetSampler(int index) + { + if (samplers.Count == 0) + { + samplers.Add(new glTFTextureSampler()); // default sampler + } + + return samplers[index]; + } + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List images = new List(); + + public int GetImageIndexFromTextureIndex(int textureIndex) + { + return textures[textureIndex].source; + } + + public glTFImage GetImageFromTextureIndex(int textureIndex) + { + return images[GetImageIndexFromTextureIndex(textureIndex)]; + } + + public glTFTextureSampler GetSamplerFromTextureIndex(int textureIndex) + { + var samplerIndex = textures[textureIndex].sampler; + return GetSampler(samplerIndex); + } + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List materials = new List(); + public string GetUniqueMaterialName(int index) + { + if (materials.Any(x => string.IsNullOrEmpty(x.name)) + || materials.Select(x => x.name).Distinct().Count() != materials.Count) + { + return String.Format("{0:00}_{1}", index, materials[index].name); + } + else + { + return materials[index].name; + } + } + + public bool MaterialHasVertexColor(glTFMaterial material) + { + if (material == null) + { + return false; + } + + var materialIndex = materials.IndexOf(material); + if (materialIndex == -1) + { + return false; + } + + return MaterialHasVertexColor(materialIndex); + } + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List meshes = new List(); + + public bool MaterialHasVertexColor(int materialIndex) + { + if (materialIndex < 0 || materialIndex >= materials.Count) + { + return false; + } + + var hasVertexColor = meshes.SelectMany(x => x.primitives).Any(x => x.material == materialIndex && x.HasVertexColor); + return hasVertexColor; + } + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List nodes = new List(); + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List skins = new List(); + + [JsonSchema(Dependencies = new string[] { "scenes" }, Minimum = 0)] + public int scene; + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List scenes = new List(); + public int[] rootnodes + { + get + { + return scenes[scene].nodes; + } + } + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List animations = new List(); + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List cameras = new List(); + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List extensionsUsed = new List(); + + [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] + public List extensionsRequired = new List(); + + public glTFExtension extensions; + public glTFExtension extras; + + public override string ToString() + { + return string.Format("{0}", asset); + } + + public bool Equals(glTF other) + { + return + textures.SequenceEqual(other.textures) + && samplers.SequenceEqual(other.samplers) + && images.SequenceEqual(other.images) + && materials.SequenceEqual(other.materials) + && meshes.SequenceEqual(other.meshes) + && nodes.SequenceEqual(other.nodes) + && skins.SequenceEqual(other.skins) + && scene == other.scene + && scenes.SequenceEqual(other.scenes) + && animations.SequenceEqual(other.animations) + ; + } + } +} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTF.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glTF.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTF.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFAnimation.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFAnimation.cs similarity index 80% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFAnimation.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFAnimation.cs index 3dfc1c6fa..89460cce7 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/glTFAnimation.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFAnimation.cs @@ -2,13 +2,12 @@ using System.Linq; using System.Collections.Generic; using UniJSON; -using UnityEngine; namespace UniGLTF { [Serializable] - public class glTFAnimationTarget : JsonSerializableBase + public class glTFAnimationTarget { [JsonSchema(Minimum = 0)] public int node; @@ -17,17 +16,8 @@ namespace UniGLTF public string path; // empty schemas - public object extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => node); - if (!string.IsNullOrEmpty(path)) - { - f.KeyValue(() => path); - } - } + public glTFExtension extensions; + public glTFExtension extras; public enum Interpolations { @@ -143,7 +133,7 @@ namespace UniGLTF } [Serializable] - public class glTFAnimationChannel : JsonSerializableBase + public class glTFAnimationChannel { [JsonSchema(Required = true, Minimum = 0)] public int sampler = -1; @@ -152,18 +142,12 @@ namespace UniGLTF public glTFAnimationTarget target; // empty schemas - public object extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => sampler); - f.Key("target"); f.GLTFValue(target); - } + public glTFExtension extensions; + public glTFExtension extras; } [Serializable] - public class glTFAnimationSampler : JsonSerializableBase + public class glTFAnimationSampler { [JsonSchema(Required = true, Minimum = 0)] public int input = -1; @@ -175,22 +159,12 @@ namespace UniGLTF public int output = -1; // empty schemas - public object extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => input); - if (!string.IsNullOrEmpty(interpolation)) - { - f.KeyValue(() => interpolation); - } - f.KeyValue(() => output); - } + public glTFExtension extensions; + public glTFExtension extras; } [Serializable] - public class glTFAnimation : JsonSerializableBase + public class glTFAnimation { public string name = ""; @@ -201,19 +175,8 @@ namespace UniGLTF public List samplers = new List(); // empty schemas - public object extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - if (!string.IsNullOrEmpty(name)) - { - f.KeyValue(() => name); - } - - f.Key("channels"); f.GLTFValue(channels); - f.Key("samplers"); f.GLTFValue(samplers); - } + public glTFExtension extensions; + public glTFExtension extras; [Obsolete] public int AddChannelAndGetSampler(int nodeIndex, glTFAnimationTarget.AnimationPropertys property) diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFAnimation.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFAnimation.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFAnimation.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFAnimation.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFAssets.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFAssets.cs similarity index 62% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFAssets.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFAssets.cs index bf691fc82..b2e3e6248 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/glTFAssets.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFAssets.cs @@ -4,7 +4,7 @@ using UniJSON; namespace UniGLTF { [Serializable] - public class glTFAssets : JsonSerializableBase + public class glTFAssets { public string generator; @@ -17,14 +17,8 @@ namespace UniGLTF public string minVersion; // empty schemas - public object extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.Key("generator"); f.Value(generator); - f.Key("version"); f.Value(version); - } + public glTFExtension extensions; + public glTFExtension extras; public override string ToString() { diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFAssets.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFAssets.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFAssets.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFAssets.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFBuffer.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFBuffer.cs similarity index 55% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFBuffer.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFBuffer.cs index 14f2cd7ad..6c893b836 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/glTFBuffer.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFBuffer.cs @@ -1,27 +1,16 @@ using System; -using System.Linq; using UniJSON; namespace UniGLTF { [Serializable] - public class glTFBuffer : JsonSerializableBase + public class glTFBuffer { IBytesBuffer Storage; public void OpenStorage(IStorage storage) { Storage = new ArraySegmentByteBuffer(storage.Get(uri)); - /* - if (string.IsNullOrEmpty(uri)) - { - Storage = (glbDataBytes); - } - else - { - Storage = new UriByteBuffer(baseDir, uri); - } - */ } public glTFBuffer() @@ -40,8 +29,8 @@ namespace UniGLTF public int byteLength; // empty schemas - public object extensions; - public object extras; + public glTFExtension extensions; + public glTFExtension extras; public string name; public glTFBufferView Append(T[] array, glBufferTarget target) where T : struct @@ -59,19 +48,10 @@ namespace UniGLTF { return Storage.GetBytes(); } - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - if (!string.IsNullOrEmpty(uri)) - { - f.KeyValue(() => uri); - } - f.KeyValue(() => byteLength); - } } [Serializable] - public class glTFBufferView : JsonSerializableBase + public class glTFBufferView { [JsonSchema(Required = true, Minimum = 0)] public int buffer; @@ -82,37 +62,20 @@ namespace UniGLTF [JsonSchema(Required = true, Minimum = 1)] public int byteLength; - [JsonSchema(Minimum = 4, Maximum = 252, MultipleOf = 4)] + [JsonSchema(Minimum = 4, Maximum = 252, MultipleOf = 4, SerializationConditions = new string[] { "false" })] public int byteStride; - [JsonSchema(EnumSerializationType = EnumSerializationType.AsInt, EnumExcludes = new object[] { glBufferTarget.NONE })] + [JsonSchema(EnumSerializationType = EnumSerializationType.AsInt, EnumExcludes = new object[] { glBufferTarget.NONE }, SerializationConditions = new string[] { "value.target!=0" })] public glBufferTarget target; // empty schemas - public object extensions; - public object extras; + public glTFExtension extensions; + public glTFExtension extras; public string name; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => buffer); - f.KeyValue(() => byteOffset); - f.KeyValue(() => byteLength); - if (target != glBufferTarget.NONE) - { - f.Key("target"); f.Value((int)target); - } - /* When this is not defined, data is tightly packed. When two or more accessors use the same bufferView, this field must be defined. - if (byteStride >= 4) - { - f.KeyValue(() => byteStride); - } - */ - } } [Serializable] - public class glTFSparseIndices : JsonSerializableBase + public class glTFSparseIndices { [JsonSchema(Required = true, Minimum = 0)] public int bufferView = -1; @@ -124,19 +87,12 @@ namespace UniGLTF public glComponentType componentType; // empty schemas - public object extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => bufferView); - f.KeyValue(() => byteOffset); - f.Key("componentType"); f.Value((int)componentType); - } + public glTFExtension extensions; + public glTFExtension extras; } [Serializable] - public class glTFSparseValues : JsonSerializableBase + public class glTFSparseValues { [JsonSchema(Required = true, Minimum = 0)] public int bufferView = -1; @@ -145,18 +101,12 @@ namespace UniGLTF public int byteOffset; // empty schemas - public object extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => bufferView); - f.KeyValue(() => byteOffset); - } + public glTFExtension extensions; + public glTFExtension extras; } [Serializable] - public class glTFSparse : JsonSerializableBase + public class glTFSparse { [JsonSchema(Required = true, Minimum = 1)] public int count; @@ -168,19 +118,12 @@ namespace UniGLTF public glTFSparseValues values; // empty schemas - public object extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => count); - f.Key("indices"); f.GLTFValue(indices); - f.Key("values"); f.GLTFValue(values); - } + public glTFExtension extensions; + public glTFExtension extras; } [Serializable] - public class glTFAccessor : JsonSerializableBase + public class glTFAccessor { [JsonSchema(Minimum = 0)] public int bufferView = -1; @@ -234,33 +177,18 @@ namespace UniGLTF // empty schemas public string name; - public object extensions; + public glTFExtension extensions; - public object extras; + public glTFExtension extras; - protected override void SerializeMembers(GLTFJsonFormatter f) + public int GetStride() { - f.KeyValue(() => bufferView); - f.KeyValue(() => byteOffset); - f.KeyValue(() => type); - f.Key("componentType"); f.Value((int)componentType); - f.KeyValue(() => count); - if (max != null && max.Any()) - { - f.KeyValue(() => max); - } - if (min != null && min.Any()) - { - f.KeyValue(() => min); - } + return componentType.GetByteSize() * TypeCount; + } - if (sparse != null && sparse.count > 0) - { - f.Key("sparse"); f.GLTFValue(sparse); - } - - f.KeyValue(() => normalized); - f.KeyValue(() => name); + public int CalcByteSize() + { + return GetStride() * count; } } } diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFBuffer.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFBuffer.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFBuffer.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFBuffer.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFCamera.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFCamera.cs similarity index 82% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFCamera.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFCamera.cs index 87de30c1b..b75ea960c 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/glTFCamera.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFCamera.cs @@ -22,9 +22,9 @@ namespace UniGLTF public float znear; [JsonSchema(MinProperties = 1)] - public glTFOrthographic_extensions extensions; + public glTFExtension extensions; [JsonSchema(MinProperties = 1)] - public glTFOrthographic_extras extras; + public glTFExtension extras; } [Serializable] @@ -39,8 +39,8 @@ namespace UniGLTF [JsonSchema(Required = true, Minimum = 0.0f, ExclusiveMinimum = true)] public float znear; - public glTFPerspective_extensions extensions; - public glTFPerspective_extras extras; + public glTFExtension extensions; + public glTFExtension extras; } [Serializable] @@ -54,7 +54,7 @@ namespace UniGLTF public string name; - public glTFCamera_extensions extensions; - public glTFCamera_extras extras; + public glTFExtension extensions; + public glTFExtension extras; } } diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFCamera.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFCamera.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFCamera.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFCamera.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFMaterial.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFMaterial.cs similarity index 56% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFMaterial.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFMaterial.cs index ef0be0dc2..e6a74042b 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/glTFMaterial.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFMaterial.cs @@ -19,7 +19,7 @@ namespace UniGLTF } [Serializable] - public abstract class glTFTextureInfo : JsonSerializableBase, IglTFTextureinfo + public abstract class glTFTextureInfo : IglTFTextureinfo { [JsonSchema(Required = true, Minimum = 0)] public int index = -1; @@ -28,18 +28,8 @@ namespace UniGLTF public int texCoord; // empty schemas - public glTFTextureInfo_extensions extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => index); - f.KeyValue(() => texCoord); - if (extensions != null) - { - f.KeyValue(() => extensions); - } - } + public glTFExtension extensions; + public glTFExtension extras; public abstract glTFTextureTypes TextureType { get; } } @@ -68,12 +58,6 @@ namespace UniGLTF { public float scale = 1.0f; - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => scale); - base.SerializeMembers(f); - } - public override glTFTextureTypes TextureType { get { return glTFTextureTypes.Normal; } @@ -86,12 +70,6 @@ namespace UniGLTF [JsonSchema(Minimum = 0.0, Maximum = 1.0)] public float strength = 1.0f; - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => strength); - base.SerializeMembers(f); - } - public override glTFTextureTypes TextureType { get { return glTFTextureTypes.Occlusion; } @@ -108,7 +86,7 @@ namespace UniGLTF } [Serializable] - public class glTFPbrMetallicRoughness : JsonSerializableBase + public class glTFPbrMetallicRoughness { public glTFMaterialBaseColorTextureInfo baseColorTexture = null; @@ -125,30 +103,12 @@ namespace UniGLTF public float roughnessFactor = 1.0f; // empty schemas - public object extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - if (baseColorTexture != null) - { - f.Key("baseColorTexture"); f.GLTFValue(baseColorTexture); - } - if (baseColorFactor != null) - { - f.KeyValue(() => baseColorFactor); - } - if (metallicRoughnessTexture != null) - { - f.Key("metallicRoughnessTexture"); f.GLTFValue(metallicRoughnessTexture); - } - f.KeyValue(() => metallicFactor); - f.KeyValue(() => roughnessFactor); - } + public glTFExtension extensions; + public glTFExtension extras; } [Serializable] - public class glTFMaterial : JsonSerializableBase + public class glTFMaterial { public string name; public glTFPbrMetallicRoughness pbrMetallicRoughness = new glTFPbrMetallicRoughness @@ -168,54 +128,14 @@ namespace UniGLTF [JsonSchema(EnumValues = new object[] { "OPAQUE", "MASK", "BLEND" }, EnumSerializationType = EnumSerializationType.AsUpperString)] public string alphaMode; - [JsonSchema(Dependencies = new string[] { "alphaMode" }, Minimum = 0.0)] + [JsonSchema(Dependencies = new string[] { "alphaMode" }, Minimum = 0.0, SerializationConditions = new[] { "value.alphaMode==\"MASK\"" })] public float alphaCutoff = 0.5f; public bool doubleSided; [JsonSchema(SkipSchemaComparison = true)] - public glTFMaterial_extensions extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - if (!String.IsNullOrEmpty(name)) - { - f.Key("name"); f.Value(name); - } - if (pbrMetallicRoughness != null) - { - f.Key("pbrMetallicRoughness"); f.GLTFValue(pbrMetallicRoughness); - } - if (normalTexture != null) - { - f.Key("normalTexture"); f.GLTFValue(normalTexture); - } - if (occlusionTexture != null) - { - f.Key("occlusionTexture"); f.GLTFValue(occlusionTexture); - } - if (emissiveTexture != null) - { - f.Key("emissiveTexture"); f.GLTFValue(emissiveTexture); - } - if (emissiveFactor != null) - { - f.Key("emissiveFactor"); f.Serialize(emissiveFactor); - } - - f.KeyValue(() => doubleSided); - - if (!string.IsNullOrEmpty(alphaMode)) - { - f.KeyValue(() => alphaMode); - } - - if (extensions != null) - { - f.Key("extensions"); f.GLTFValue(extensions); - } - } + public glTFExtension extensions; + public glTFExtension extras; public glTFTextureInfo[] GetTextures() { diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFMaterial.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFMaterial.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFMaterial.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFMaterial.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFMesh.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFMesh.cs similarity index 61% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFMesh.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFMesh.cs index 14de38978..480f00519 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/glTFMesh.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFMesh.cs @@ -5,7 +5,7 @@ using UniJSON; namespace UniGLTF { [Serializable] - public class glTFAttributes : JsonSerializableBase + public class glTFAttributes { [JsonSchema(Minimum = 0, ExplicitIgnorableValue = -1)] public int POSITION = -1; @@ -54,22 +54,10 @@ namespace UniGLTF && WEIGHTS_0 == rhs.WEIGHTS_0 ; } - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => POSITION); - if (NORMAL != -1) f.KeyValue(() => NORMAL); - if (TANGENT != -1) f.KeyValue(() => TANGENT); - if (TEXCOORD_0 != -1) f.KeyValue(() => TEXCOORD_0); - if (TEXCOORD_1 != -1) f.KeyValue(() => TEXCOORD_1); - if (COLOR_0 != -1) f.KeyValue(() => COLOR_0); - if (JOINTS_0 != -1) f.KeyValue(() => JOINTS_0); - if (WEIGHTS_0 != -1) f.KeyValue(() => WEIGHTS_0); - } } [Serializable] - public class gltfMorphTarget : JsonSerializableBase + public class gltfMorphTarget { [JsonSchema(Minimum = 0, ExplicitIgnorableValue = -1)] public int POSITION = -1; @@ -79,20 +67,13 @@ namespace UniGLTF [JsonSchema(Minimum = 0, ExplicitIgnorableValue = -1)] public int TANGENT = -1; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => POSITION); - if (NORMAL >= 0) f.KeyValue(() => NORMAL); - if (TANGENT >= 0) f.KeyValue(() => TANGENT); - } } /// /// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/schema/mesh.primitive.schema.json /// [Serializable] - public class glTFPrimitives : JsonSerializableBase + public class glTFPrimitives { [JsonSchema(EnumValues = new object[] { 0, 1, 2, 3, 4, 5, 6 })] public int mode; @@ -118,30 +99,14 @@ namespace UniGLTF [ItemJsonSchema(SkipSchemaComparison = true)] public List targets = new List(); - public glTFPrimitives_extras extras = new glTFPrimitives_extras(); + public glTFExtension extras; [JsonSchema(SkipSchemaComparison = true)] - public glTFPrimitives_extensions extensions = null; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => mode); - f.KeyValue(() => indices); - f.Key("attributes"); f.GLTFValue(attributes); - f.KeyValue(() => material); - if (targets != null && targets.Count > 0) - { - f.Key("targets"); f.GLTFValue(targets); - } - if (extras.targetNames.Count > 0) - { - f.Key("extras"); f.GLTFValue(extras); - } - } + public glTFExtension extensions; } [Serializable] - public class glTFMesh : JsonSerializableBase + public class glTFMesh { public string name; @@ -152,10 +117,10 @@ namespace UniGLTF public float[] weights; [JsonSchema(SkipSchemaComparison = true)] - public glTFMesh_extras extras = null; + public glTFExtension extras; // empty schemas - public object extensions; + public glTFExtension extensions; public glTFMesh() { @@ -165,15 +130,5 @@ namespace UniGLTF { name = _name; } - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => name); - f.Key("primitives"); f.GLTFValue(primitives); - if (weights != null && weights.Length > 0) - { - f.KeyValue(() => weights); - } - } } } diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFMesh.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFMesh.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFMesh.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFMesh.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFNode.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFNode.cs new file mode 100644 index 000000000..955442d01 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFNode.cs @@ -0,0 +1,47 @@ +using System; +using System.Linq; +using UniJSON; + +namespace UniGLTF +{ + [Serializable] + public class glTFNode + { + // TODO: need an empty string? + public string name; + + [JsonSchema(MinItems = 1)] + [ItemJsonSchema(Minimum = 0)] + public int[] children; + + [JsonSchema(MinItems = 16, MaxItems = 16)] + public float[] matrix; + + [JsonSchema(MinItems = 3, MaxItems = 3)] + public float[] translation; + + [JsonSchema(MinItems = 4, MaxItems = 4)] + [ItemJsonSchema(Minimum = -1.0, Maximum = 1.0)] + public float[] rotation; + + [JsonSchema(MinItems = 3, MaxItems = 3)] + public float[] scale; + + [JsonSchema(Minimum = 0, ExplicitIgnorableValue = -1)] + public int mesh = -1; + + [JsonSchema(Dependencies = new string[] { "mesh" }, Minimum = 0, ExplicitIgnorableValue = -1)] + public int skin = -1; + + [JsonSchema(Dependencies = new string[] { "mesh" }, MinItems = 1)] + public float[] weights; + + [JsonSchema(Minimum = 0, ExplicitIgnorableValue = -1)] + public int camera = -1; + + // empty schemas + public glTFExtension extensions; + + public glTFExtension extras; + } +} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFNode.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFNode.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFNode.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFNode.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFSkin.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFSkin.cs similarity index 54% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFSkin.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFSkin.cs index aebffb10a..c2ae23463 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/glTFSkin.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFSkin.cs @@ -4,7 +4,7 @@ using UniJSON; namespace UniGLTF { [Serializable] - public class glTFSkin : JsonSerializableBase + public class glTFSkin { [JsonSchema(Minimum = 0, ExplicitIgnorableValue = -1)] public int inverseBindMatrices = -1; @@ -17,18 +17,8 @@ namespace UniGLTF public int skeleton = -1; // empty schemas - public object extensions; - public object extras; + public glTFExtension extensions; + public glTFExtension extras; public string name; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => inverseBindMatrices); - f.KeyValue(() => joints); - if (skeleton >= 0) - { - f.KeyValue(() => skeleton); - } - } } } diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFSkin.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFSkin.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFSkin.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFSkin.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFTexture.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFTexture.cs similarity index 64% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFTexture.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFTexture.cs index 199846b9e..20d3a8be2 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/glTFTexture.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFTexture.cs @@ -5,7 +5,7 @@ using UniJSON; namespace UniGLTF { [Serializable] - public class glTFTextureSampler : JsonSerializableBase + public class glTFTextureSampler { [JsonSchema(EnumSerializationType = EnumSerializationType.AsInt, EnumExcludes = new object[] { @@ -30,21 +30,13 @@ namespace UniGLTF public glWrap wrapT = glWrap.REPEAT; // empty schemas - public object extensions; - public object extras; + public glTFExtension extensions; + public glTFExtension extras; public string name; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.Key("magFilter"); f.Value((int)magFilter); - f.Key("minFilter"); f.Value((int)minFilter); - f.Key("wrapS"); f.Value((int)wrapS); - f.Key("wrapT"); f.Value((int)wrapT); - } } [Serializable] - public class glTFImage : JsonSerializableBase + public class glTFImage { public string name; public string uri; @@ -52,7 +44,7 @@ namespace UniGLTF [JsonSchema(Dependencies = new string[] { "mimeType" }, Minimum = 0)] public int bufferView; - [JsonSchema(EnumValues = new object[] { "image/jpeg", "image/png" }, EnumSerializationType =EnumSerializationType.AsString)] + [JsonSchema(EnumValues = new object[] { "image/jpeg", "image/png" }, EnumSerializationType = EnumSerializationType.AsString)] public string mimeType; public string GetExt() @@ -82,26 +74,12 @@ namespace UniGLTF } // empty schemas - public object extensions; - public object extras; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => name); - if (!string.IsNullOrEmpty(uri)) - { - f.KeyValue(() => uri); - } - else - { - f.KeyValue(() => bufferView); - f.KeyValue(() => mimeType); - } - } + public glTFExtension extensions; + public glTFExtension extras; } [Serializable] - public class glTFTexture : JsonSerializableBase + public class glTFTexture { [JsonSchema(Minimum = 0)] public int sampler; @@ -110,14 +88,8 @@ namespace UniGLTF public int source; // empty schemas - public object extensions; - public object extras; + public glTFExtension extensions; + public glTFExtension extras; public string name; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => sampler); - f.KeyValue(() => source); - } } } diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFTexture.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFTexture.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glTFTexture.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glTFTexture.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glbTypes.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glbTypes.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glbTypes.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glbTypes.cs diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glbTypes.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/glbTypes.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/glbTypes.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/glbTypes.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO.meta similarity index 62% rename from Assets/VRM/UniGLTF/Scripts/IO.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO.meta index 1081f515a..03f8b32fc 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO.meta +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO.meta @@ -1,8 +1,6 @@ fileFormatVersion: 2 -guid: a7addf524d7f84841b039527f0273bfa +guid: 11bf923167b421a4fa092bed7fa7575b folderAsset: yes -timeCreated: 1517139195 -licenseType: Free DefaultImporter: externalObjects: {} userData: diff --git a/Assets/VRM/UniGLTF/Scripts/IO/AnimationCurveData.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationCurveData.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/AnimationCurveData.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationCurveData.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/AnimationCurveData.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationCurveData.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/AnimationCurveData.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationCurveData.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/AnimationExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationExporter.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/AnimationExporter.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationExporter.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/AnimationExporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationExporter.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/AnimationExporter.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationExporter.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/AnimationImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationImporter.cs similarity index 95% rename from Assets/VRM/UniGLTF/Scripts/IO/AnimationImporter.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationImporter.cs index 9ea84f878..85e2e9e08 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/AnimationImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationImporter.cs @@ -268,16 +268,7 @@ namespace UniGLTF var primitive = mesh.primitives.FirstOrDefault(); var targets = primitive.targets; - List targetNames; - if(primitive != null && primitive.extras != null && primitive.extras.targetNames != null && primitive.extras.targetNames.Count > 0) - { - targetNames = primitive.extras.targetNames; - } - else if(mesh.extras != null && mesh.extras.targetNames != null && mesh.extras.targetNames.Count > 0) - { - targetNames = mesh.extras.targetNames; - } - else + if (!gltf_mesh_extras_targetNames.TryGet(mesh, out List targetNames)) { throw new Exception("glTF BlendShape Animation. targetNames invalid."); } @@ -306,7 +297,7 @@ namespace UniGLTF } return values; }); - + } break; diff --git a/Assets/VRM/UniGLTF/Scripts/IO/AnimationImporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationImporter.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/AnimationImporter.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationImporter.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/AnimationKeyframeData.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationKeyframeData.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/AnimationKeyframeData.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationKeyframeData.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/AnimationKeyframeData.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationKeyframeData.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/AnimationKeyframeData.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationKeyframeData.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Format/BytesBuffer.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/BytesBuffer.cs similarity index 83% rename from Assets/VRM/UniGLTF/Scripts/Format/BytesBuffer.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/BytesBuffer.cs index 11c805fe4..bd7963734 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/BytesBuffer.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/BytesBuffer.cs @@ -5,13 +5,6 @@ using System.Runtime.InteropServices; namespace UniGLTF { - public interface IBytesBuffer - { - string Uri { get; } - ArraySegment GetBytes(); - glTFBufferView Extend(ArraySegment array, glBufferTarget target) where T : struct; - } - public static class IBytesBufferExtensions { public static glTFBufferView Extend(this IBytesBuffer buffer, T[] array, glBufferTarget target) where T : struct @@ -88,34 +81,6 @@ namespace UniGLTF } } - /// - /// for glb chunk buffer read - /// - public class ArraySegmentByteBuffer : IBytesBuffer - { - ArraySegment m_bytes; - - public ArraySegmentByteBuffer(ArraySegment bytes) - { - m_bytes = bytes; - } - - public string Uri - { - get; - private set; - } - - public glTFBufferView Extend(ArraySegment array, glBufferTarget target) where T : struct - { - throw new NotImplementedException(); - } - - public ArraySegment GetBytes() - { - return m_bytes; - } - } /// /// for exporter diff --git a/Assets/VRM/UniGLTF/Scripts/Format/BytesBuffer.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/BytesBuffer.cs.meta similarity index 71% rename from Assets/VRM/UniGLTF/Scripts/Format/BytesBuffer.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/BytesBuffer.cs.meta index ca3050609..cdca54f8f 100644 --- a/Assets/VRM/UniGLTF/Scripts/Format/BytesBuffer.cs.meta +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/BytesBuffer.cs.meta @@ -1,7 +1,5 @@ fileFormatVersion: 2 -guid: 33b0000c5446b7547bcad1da1e9768ed -timeCreated: 1516730619 -licenseType: Free +guid: 1e9c9201942704b4f9dd050115073032 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/VRM/UniGLTF/Scripts/IO/BytesReader.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/BytesReader.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/BytesReader.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/BytesReader.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/BytesReader.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/BytesReader.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/BytesReader.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/BytesReader.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/IStorage.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/FileSystemStorage.cs similarity index 77% rename from Assets/VRM/UniGLTF/Scripts/IO/IStorage.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/FileSystemStorage.cs index 585439322..c2c07932b 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/IStorage.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/FileSystemStorage.cs @@ -1,26 +1,13 @@ -using System; +using System; using System.IO; - namespace UniGLTF { - public interface IStorage - { - ArraySegment Get(string url); - - /// - /// Get original filepath if exists - /// - /// - /// - string GetPath(string url); - } - public class SimpleStorage : IStorage { ArraySegment m_bytes; - public SimpleStorage():this(new ArraySegment()) + public SimpleStorage() : this(new ArraySegment()) { } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/FileSystemStorage.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/FileSystemStorage.cs.meta new file mode 100644 index 000000000..b8a9ebd47 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/FileSystemStorage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ca59fdd271a96dd409ea98e128fbebca +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs similarity index 95% rename from Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs index c6ce7189c..8684aa54a 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs @@ -271,28 +271,11 @@ namespace UniGLTF } } - private SerializerTypes _serializerType = SerializerTypes.Generated; - public SerializerTypes SerializerType { get { return _serializerType; } set { _serializerType = value; } } - public virtual void ParseJson(string json, IStorage storage) { Json = json; Storage = storage; - - if (_serializerType == SerializerTypes.UniJSON) - { - // Obsolete - Json.ParseAsJson().Deserialize(ref GLTF); - } - else if (_serializerType == SerializerTypes.Generated) - { - GLTF = GltfDeserializer.Deserialize(json.ParseAsJson()); - } - else if (_serializerType == SerializerTypes.JsonSerializable) - { - // Obsolete - GLTF = JsonUtility.FromJson(Json); - } + GLTF = GltfDeserializer.Deserialize(json.ParseAsJson()); if (GLTF.asset.version != "2.0") { @@ -361,27 +344,28 @@ namespace UniGLTF } } } - for (int i = 0; i < GLTF.meshes.Count; ++i) - { - var mesh = GLTF.meshes[i]; - try - { - for (int j = 0; j < mesh.primitives.Count; ++j) - { - var primitive = mesh.primitives[j]; - for (int k = 0; k < primitive.targets.Count; ++k) - { - var extraName = parsed["meshes"][i]["primitives"][j]["targets"][k]["extra"]["name"].Value.GetString(); - //Debug.LogFormat("restore morphName: {0}", extraName); - primitive.extras.targetNames.Add(extraName); - } - } - } - catch (Exception) - { - // do nothing - } - } + // for (int i = 0; i < GLTF.meshes.Count; ++i) + // { + // var mesh = GLTF.meshes[i]; + // try + // { + // for (int j = 0; j < mesh.primitives.Count; ++j) + // { + // var primitive = mesh.primitives[j]; + // for (int k = 0; k < primitive.targets.Count; ++k) + // { + // var extraName = parsed["meshes"][i]["primitives"][j]["targets"][k]["extra"]["name"].Value.GetString(); + // //Debug.LogFormat("restore morphName: {0}", extraName); + // throw new NotImplementedException(); + // // primitive.extras.targetNames.Add(extraName); + // } + // } + // } + // catch (Exception) + // { + // // do nothing + // } + // } #if false for (int i = 0; i < GLTF.nodes.Count; ++i) { diff --git a/Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MaterialExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialExporter.cs similarity index 96% rename from Assets/VRM/UniGLTF/Scripts/IO/MaterialExporter.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialExporter.cs index 1e8b14757..ca04a7d2b 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/MaterialExporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialExporter.cs @@ -1,4 +1,6 @@ -using UniGLTF.UniUnlit; +using System.Collections.Generic; +using UniGLTF.UniUnlit; +using UniJSON; using UnityEngine; @@ -188,14 +190,7 @@ namespace UniGLTF var scale = m.GetTextureScale(propertyName); offset.y = (offset.y + scale.y - 1) * -1.0f; - textureInfo.extensions = new glTFTextureInfo_extensions - { - KHR_texture_transform = new glTF_KHR_texture_transform() - { - offset = new float[] { offset.x, offset.y }, - scale = new float[] { scale.x, scale.y }, - } - }; + glTF_KHR_texture_transform.Serialize(textureInfo, (offset.x, offset.y), (scale.x, scale.y)); } } diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MaterialExporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialExporter.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/MaterialExporter.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialExporter.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MaterialImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialImporter.cs similarity index 97% rename from Assets/VRM/UniGLTF/Scripts/IO/MaterialImporter.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialImporter.cs index 13ad61ae5..5da283f84 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/MaterialImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialImporter.cs @@ -82,7 +82,7 @@ namespace UniGLTF } // unlit material - if (x.extensions != null && x.extensions.KHR_materials_unlit != null) + if (glTF_KHR_materials_unlit.IsEnable(x)) { // texture if (x.pbrMetallicRoughness.baseColorTexture != null) @@ -113,7 +113,7 @@ namespace UniGLTF { UniUnlit.Utils.SetRenderMode(material, UniUnlit.UniUnlitRenderMode.Transparent); } - else if(x.alphaMode == "MASK") + else if (x.alphaMode == "MASK") { UniUnlit.Utils.SetRenderMode(material, UniUnlit.UniUnlitRenderMode.Cutout); } @@ -292,9 +292,8 @@ namespace UniGLTF private static void SetTextureOffsetAndScale(Material material, glTFTextureInfo textureInfo, string propertyName) { - if (textureInfo.extensions != null && textureInfo.extensions.KHR_texture_transform != null) + if (glTF_KHR_texture_transform.TryGet(textureInfo, out glTF_KHR_texture_transform textureTransform)) { - var textureTransform = textureInfo.extensions.KHR_texture_transform; Vector2 offset = new Vector2(0, 0); Vector2 scale = new Vector2(1, 1); if (textureTransform.offset != null && textureTransform.offset.Length == 2) diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MaterialImporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialImporter.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/MaterialImporter.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialImporter.cs.meta diff --git a/Assets/MeshUtility/Runtime/MeshExportInfo.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshExportInfo.cs similarity index 88% rename from Assets/MeshUtility/Runtime/MeshExportInfo.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MeshExportInfo.cs index c11547f4e..de78ce315 100644 --- a/Assets/MeshUtility/Runtime/MeshExportInfo.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshExportInfo.cs @@ -1,16 +1,8 @@ using System; using UnityEngine; -namespace MeshUtility +namespace UniGLTF { - public struct MeshWithRenderer - { - public Mesh Mesh; - [Obsolete("Use Renderer")] - public Renderer Rendererer { get { return Renderer; } set { Renderer = value; } } - public Renderer Renderer; - } - [Serializable] public struct MeshExportInfo { @@ -74,14 +66,14 @@ namespace MeshUtility foreach (var m in materials) { var currentState = MaterialUseVertexColor(m) - ? MeshUtility.MeshExportInfo.VertexColorState.ExistsAndIsUsed - : MeshUtility.MeshExportInfo.VertexColorState.ExistsButNotUsed + ? MeshExportInfo.VertexColorState.ExistsAndIsUsed + : MeshExportInfo.VertexColorState.ExistsButNotUsed ; if (state.HasValue) { if (state.Value != currentState) { - state = MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed; + state = MeshExportInfo.VertexColorState.ExistsAndMixed; break; } } diff --git a/Assets/MeshUtility/Runtime/MeshExportInfo.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshExportInfo.cs.meta similarity index 83% rename from Assets/MeshUtility/Runtime/MeshExportInfo.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MeshExportInfo.cs.meta index 41e5c9e57..deaa43e4a 100644 --- a/Assets/MeshUtility/Runtime/MeshExportInfo.cs.meta +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshExportInfo.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2af6d95e4a0e06944b34d891d798b88b +guid: 14f3566dfa5223944bf4bdc936f58270 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MeshExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshExporter.cs similarity index 93% rename from Assets/VRM/UniGLTF/Scripts/IO/MeshExporter.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MeshExporter.cs index 23179719c..f72809474 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/MeshExporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshExporter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using UniJSON; using UnityEngine; namespace UniGLTF @@ -41,9 +42,9 @@ namespace UniGLTF var colorAccessorIndex = -1; - var vColorState = MeshUtility.MeshExportInfo.DetectVertexColor(mesh, materials); - if (vColorState == MeshUtility.MeshExportInfo.VertexColorState.ExistsAndIsUsed // VColor使っている - || vColorState == MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed // VColorを使っているところと使っていないところが混在(とりあえずExportする) + var vColorState = MeshExportInfo.DetectVertexColor(mesh, materials); + if (vColorState == MeshExportInfo.VertexColorState.ExistsAndIsUsed // VColor使っている + || vColorState == MeshExportInfo.VertexColorState.ExistsAndMixed // VColorを使っているところと使っていないところが混在(とりあえずExportする) ) { // UniUnlit で Multiply 設定になっている @@ -250,8 +251,16 @@ namespace UniGLTF }; } + public struct MeshWithRenderer + { + public Mesh Mesh; + [Obsolete("Use Renderer")] + public Renderer Rendererer { get { return Renderer; } set { Renderer = value; } } + public Renderer Renderer; + } + public static IEnumerable<(Mesh, glTFMesh, Dictionary)> ExportMeshes(glTF gltf, int bufferIndex, - List unityMeshes, List unityMaterials, + List unityMeshes, List unityMaterials, MeshExportSettings settings) { for (int i = 0; i < unityMeshes.Count; ++i) @@ -263,10 +272,8 @@ namespace UniGLTF var gltfMesh = ExportPrimitives(gltf, bufferIndex, x.Renderer.name, mesh, materials, unityMaterials); - if (gltfMesh.extras == null) - { - gltfMesh.extras = new glTFMesh_extras(); - } + + var targetNames = new List(); var blendShapeIndexMap = new Dictionary(); int exportBlendShapes = 0; @@ -284,7 +291,7 @@ namespace UniGLTF // maybe skip var blendShapeName = mesh.GetBlendShapeName(j); blendShapeIndexMap.Add(j, exportBlendShapes++); - gltfMesh.extras.targetNames.Add(blendShapeName); + targetNames.Add(blendShapeName); // // all primitive has same blendShape @@ -292,10 +299,11 @@ namespace UniGLTF for (int k = 0; k < gltfMesh.primitives.Count; ++k) { gltfMesh.primitives[k].targets.Add(morphTarget); - gltfMesh.primitives[k].extras.targetNames.Add(blendShapeName); } } + gltf_mesh_extras_targetNames.Serialize(gltfMesh, targetNames); + yield return (mesh, gltfMesh, blendShapeIndexMap); } } diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MeshExporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshExporter.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/MeshExporter.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MeshExporter.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MeshImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshImporter.cs similarity index 94% rename from Assets/VRM/UniGLTF/Scripts/IO/MeshImporter.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MeshImporter.cs index b1b1d62c4..b56fb644e 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/MeshImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshImporter.cs @@ -382,39 +382,17 @@ namespace UniGLTF public void RenameBlendShape(glTFMesh gltfMesh) { - if (gltfMesh.extras != null && gltfMesh.extras.targetNames != null) + if (gltf_mesh_extras_targetNames.TryGet(gltfMesh, out List targetNames)) { - var targetNames = gltfMesh.extras.targetNames; - for (int i = 1; i < gltfMesh.primitives.Count; ++i) + for (var i = 0; i < BlendShapes.Count; i++) { - if (gltfMesh.primitives[i].targets.Count != targetNames.Count) + if (i >= targetNames.Count) { - throw new FormatException(string.Format("different targets length: {0} with targetNames length.", - gltfMesh.primitives[i])); + Debug.LogWarning($"invalid primitive.extras.targetNames length"); + break; } - } - for (var i = 0; i < targetNames.Count; i++) - { BlendShapes[i].Name = targetNames[i]; } - return; - } - - var prim = gltfMesh.primitives[0]; - { - if (prim.extras != null && prim.extras.targetNames != null) - { - var targetNames = prim.extras.targetNames; - for (var i = 0; i < BlendShapes.Count; i++) - { - if (i >= targetNames.Count) - { - Debug.LogWarning($"invalid primitive.extras.targetNames length"); - break; - } - BlendShapes[i].Name = targetNames[i]; - } - } } } diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MeshImporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshImporter.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/MeshImporter.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MeshImporter.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MeshWithMaterials.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshWithMaterials.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/MeshWithMaterials.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MeshWithMaterials.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MeshWithMaterials.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshWithMaterials.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/MeshWithMaterials.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MeshWithMaterials.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Format/MonoBehaviourComparator.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MonoBehaviourComparator.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/MonoBehaviourComparator.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MonoBehaviourComparator.cs diff --git a/Assets/VRM/UniGLTF/Scripts/Format/MonoBehaviourComparator.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/MonoBehaviourComparator.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Format/MonoBehaviourComparator.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/MonoBehaviourComparator.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/NodeImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/NodeImporter.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/NodeImporter.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/NodeImporter.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/NodeImporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/NodeImporter.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/NodeImporter.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/NodeImporter.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/ShaderStore.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/ShaderStore.cs similarity index 96% rename from Assets/VRM/UniGLTF/Scripts/IO/ShaderStore.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/ShaderStore.cs index c6e810b17..2b608e23a 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/ShaderStore.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/ShaderStore.cs @@ -111,7 +111,7 @@ namespace UniGLTF return Default; } - if (material.extensions != null && material.extensions.KHR_materials_unlit != null) + if(glTF_KHR_materials_unlit.IsEnable(material)) { return UniUnlit; } diff --git a/Assets/VRM/UniGLTF/Scripts/IO/ShaderStore.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/ShaderStore.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/ShaderStore.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/ShaderStore.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/StaticMeshIntegrator.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/StaticMeshIntegrator.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/StaticMeshIntegrator.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/StaticMeshIntegrator.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/StaticMeshIntegrator.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/StaticMeshIntegrator.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/StaticMeshIntegrator.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/StaticMeshIntegrator.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureConverter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureConverter.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureConverter.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureConverter.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureConverter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureConverter.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureConverter.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureConverter.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureExportManager.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureExportManager.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureExportManager.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureExportManager.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureExportManager.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureExportManager.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureExportManager.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureExportManager.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureIO.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureIO.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureIO.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureIO.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureItem.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureItem.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureItem.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureItem.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureItem.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureItem.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureItem.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureItem.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureLoader.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureLoader.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureLoader.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureLoader.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureLoader.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureLoader.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureLoader.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureLoader.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureSamplerUtil.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureSamplerUtil.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureSamplerUtil.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureSamplerUtil.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TextureSamplerUtil.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureSamplerUtil.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TextureSamplerUtil.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TextureSamplerUtil.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TriangleUtil.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TriangleUtil.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TriangleUtil.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TriangleUtil.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/TriangleUtil.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/TriangleUtil.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/TriangleUtil.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/TriangleUtil.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/UnityPath.cs similarity index 99% rename from Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/UnityPath.cs index bb236a463..9a4cebe0d 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/UnityPath.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using UnityEngine; using System.Collections.Generic; diff --git a/Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/UnityPath.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/UnityPath.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/UnityPath.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/ZipArchiveStorage.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/ZipArchiveStorage.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/ZipArchiveStorage.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/ZipArchiveStorage.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/ZipArchiveStorage.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/ZipArchiveStorage.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/ZipArchiveStorage.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/ZipArchiveStorage.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/glbImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/glbImporter.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/glbImporter.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/glbImporter.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/glbImporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/glbImporter.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/glbImporter.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/glbImporter.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/gltfExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs similarity index 99% rename from Assets/VRM/UniGLTF/Scripts/IO/gltfExporter.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs index d17498d3b..30a535fd0 100644 --- a/Assets/VRM/UniGLTF/Scripts/IO/gltfExporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs @@ -253,7 +253,7 @@ namespace UniGLTF #region Meshes var unityMeshes = Nodes - .Select(x => new MeshUtility.MeshWithRenderer + .Select(x => new MeshExporter.MeshWithRenderer { Mesh = x.GetSharedMesh(), Renderer = x.GetComponent(), diff --git a/Assets/VRM/UniGLTF/Scripts/IO/gltfExporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/gltfExporter.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/IO/gltfImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfImporter.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/gltfImporter.cs rename to Assets/UniGLTF/Runtime/UniGLTF/IO/gltfImporter.cs diff --git a/Assets/VRM/UniGLTF/Scripts/IO/gltfImporter.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfImporter.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/IO/gltfImporter.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/IO/gltfImporter.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Resources.meta b/Assets/UniGLTF/Runtime/UniGLTF/Resources.meta new file mode 100644 index 000000000..cc6219b62 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 82ac26c4fd3be9e4f80d7d30964f3a8d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders.meta b/Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders.meta new file mode 100644 index 000000000..346da5e15 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1ee5d4bfcf72732478b030c023b8c5bf +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Resources/Shaders/NormalMapDecoder.shader b/Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/NormalMapDecoder.shader similarity index 100% rename from Assets/VRM/UniGLTF/Resources/Shaders/NormalMapDecoder.shader rename to Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/NormalMapDecoder.shader diff --git a/Assets/VRM/UniGLTF/Resources/Shaders/NormalMapDecoder.shader.meta b/Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/NormalMapDecoder.shader.meta similarity index 100% rename from Assets/VRM/UniGLTF/Resources/Shaders/NormalMapDecoder.shader.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/NormalMapDecoder.shader.meta diff --git a/Assets/VRM/UniGLTF/Resources/Shaders/NormalMapEncoder.shader b/Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/NormalMapEncoder.shader similarity index 100% rename from Assets/VRM/UniGLTF/Resources/Shaders/NormalMapEncoder.shader rename to Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/NormalMapEncoder.shader diff --git a/Assets/VRM/UniGLTF/Resources/Shaders/NormalMapEncoder.shader.meta b/Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/NormalMapEncoder.shader.meta similarity index 100% rename from Assets/VRM/UniGLTF/Resources/Shaders/NormalMapEncoder.shader.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/NormalMapEncoder.shader.meta diff --git a/Assets/VRM/UniGLTF/Resources/Shaders/StandardVColor.shader b/Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/StandardVColor.shader similarity index 100% rename from Assets/VRM/UniGLTF/Resources/Shaders/StandardVColor.shader rename to Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/StandardVColor.shader diff --git a/Assets/VRM/UniGLTF/Resources/Shaders/StandardVColor.shader.meta b/Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/StandardVColor.shader.meta similarity index 100% rename from Assets/VRM/UniGLTF/Resources/Shaders/StandardVColor.shader.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Resources/Shaders/StandardVColor.shader.meta diff --git a/Assets/VRM/UniGLTF/Scripts/UniGLTFException.cs b/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFException.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/UniGLTFException.cs rename to Assets/UniGLTF/Runtime/UniGLTF/UniGLTFException.cs diff --git a/Assets/VRM/UniGLTF/Scripts/UniGLTFException.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFException.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/UniGLTFException.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/UniGLTFException.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFVersion.cs b/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFVersion.cs new file mode 100644 index 000000000..9684c6287 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFVersion.cs @@ -0,0 +1,11 @@ + +namespace UniGLTF +{ + public static partial class UniGLTFVersion + { + public const int MAJOR = 2; + public const int MINOR = 0; + public const int PATCH = 0; + public const string VERSION = "2.0.0"; + } +} diff --git a/Assets/VRM/UniGLTF/Scripts/UniGLTFVersion.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFVersion.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/UniGLTFVersion.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/UniGLTFVersion.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/UniGLTFVersion_partial.cs b/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFVersion_partial.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/UniGLTFVersion_partial.cs rename to Assets/UniGLTF/Runtime/UniGLTF/UniGLTFVersion_partial.cs diff --git a/Assets/VRM/UniGLTF/Scripts/UniGLTFVersion_partial.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFVersion_partial.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/UniGLTFVersion_partial.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/UniGLTFVersion_partial.cs.meta diff --git a/Assets/VRM/UniGLTF/Scripts/Util.meta b/Assets/UniGLTF/Runtime/UniGLTF/Util.meta similarity index 77% rename from Assets/VRM/UniGLTF/Scripts/Util.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Util.meta index d519486c3..84a19a442 100644 --- a/Assets/VRM/UniGLTF/Scripts/Util.meta +++ b/Assets/UniGLTF/Runtime/UniGLTF/Util.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 980062d19c06cb347b7a8874479d90b7 +guid: 1595b81f792ed7b469e4391dcc7d335f folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/VRM/UniGLTF/Scripts/Util/CacheEnum.cs b/Assets/UniGLTF/Runtime/UniGLTF/Util/CacheEnum.cs similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Util/CacheEnum.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Util/CacheEnum.cs diff --git a/Assets/VRM/UniGLTF/Scripts/Util/CacheEnum.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Util/CacheEnum.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Scripts/Util/CacheEnum.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Util/CacheEnum.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniJSON.meta b/Assets/UniGLTF/Runtime/UniJSON.meta new file mode 100644 index 000000000..331870407 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniJSON.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a228393ced862a54eb598701ae684afa +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/.circleci/config.yml b/Assets/UniGLTF/Runtime/UniJSON/.circleci/config.yml similarity index 100% rename from Assets/VRM/UniJSON/.circleci/config.yml rename to Assets/UniGLTF/Runtime/UniJSON/.circleci/config.yml diff --git a/Assets/VRM/UniJSON/Scripts/ActionDisposer.cs b/Assets/UniGLTF/Runtime/UniJSON/ActionDisposer.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ActionDisposer.cs rename to Assets/UniGLTF/Runtime/UniJSON/ActionDisposer.cs diff --git a/Assets/VRM/UniJSON/Scripts/ActionDisposer.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/ActionDisposer.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ActionDisposer.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/ActionDisposer.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/ByteBuffer.cs b/Assets/UniGLTF/Runtime/UniJSON/ByteBuffer.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ByteBuffer.cs rename to Assets/UniGLTF/Runtime/UniJSON/ByteBuffer.cs diff --git a/Assets/VRM/UniJSON/Scripts/ByteBuffer.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/ByteBuffer.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ByteBuffer.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/ByteBuffer.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/ConcreteCast.cs b/Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ConcreteCast.cs rename to Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.cs index 641e4ebf1..603346973 100644 --- a/Assets/VRM/UniJSON/Scripts/ConcreteCast.cs +++ b/Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.cs @@ -1,9 +1,9 @@ using System; using System.IO; using System.Text; -using UnityEngine; using System.Reflection; #if UNITY_EDITOR +using UnityEngine; using UnityEditor; #endif diff --git a/Assets/VRM/UniJSON/Scripts/ConcreteCast.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ConcreteCast.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/ConcreteCast.g.cs b/Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.g.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ConcreteCast.g.cs rename to Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.g.cs diff --git a/Assets/VRM/UniJSON/Scripts/ConcreteCast.g.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.g.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ConcreteCast.g.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/ConcreteCast.g.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Exceptions.cs b/Assets/UniGLTF/Runtime/UniJSON/Exceptions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Exceptions.cs rename to Assets/UniGLTF/Runtime/UniJSON/Exceptions.cs diff --git a/Assets/VRM/UniJSON/Scripts/Exceptions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Exceptions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Exceptions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Exceptions.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniJSON/Extensions.meta b/Assets/UniGLTF/Runtime/UniJSON/Extensions.meta new file mode 100644 index 000000000..3fa3423bd --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniJSON/Extensions.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 87f807e570e93ea40b87c0403927b690 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/ArraySegmentExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/Extensions/ArraySegmentExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/ArraySegmentExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/ArraySegmentExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/ArraySegmentExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Extensions/ArraySegmentExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/ArraySegmentExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/ArraySegmentExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/ByteExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/Extensions/ByteExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/ByteExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/ByteExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/ByteExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Extensions/ByteExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/ByteExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/ByteExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/DateTimeOffsetExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/Extensions/DateTimeOffsetExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/DateTimeOffsetExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/DateTimeOffsetExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/DateTimeOffsetExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Extensions/DateTimeOffsetExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/DateTimeOffsetExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/DateTimeOffsetExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/EnumExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/Extensions/EnumExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/EnumExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/EnumExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/EnumExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Extensions/EnumExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/EnumExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/EnumExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/ParserExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/Extensions/ParserExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/ParserExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/ParserExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/ParserExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Extensions/ParserExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/ParserExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/ParserExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/TypeExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/Extensions/TypeExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/TypeExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/TypeExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/Extensions/TypeExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Extensions/TypeExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Extensions/TypeExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Extensions/TypeExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/FormatterExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/FormatterExtensions.cs similarity index 99% rename from Assets/VRM/UniJSON/Scripts/FormatterExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/FormatterExtensions.cs index c9b939e1f..ef9351e9e 100644 --- a/Assets/VRM/UniJSON/Scripts/FormatterExtensions.cs +++ b/Assets/UniGLTF/Runtime/UniJSON/FormatterExtensions.cs @@ -29,6 +29,7 @@ namespace UniJSON f.Value(new ArraySegment(bytes)); } +#if UNITY_5_6_OR_NEWER public static void Value(this IFormatter f, UnityEngine.Vector2 v) { //CommaCheck(); @@ -58,6 +59,7 @@ namespace UniJSON f.Key("w"); f.Value(v.w); f.EndMap(); } +#endif static MethodInfo GetMethod(Expression> expression) { diff --git a/Assets/VRM/UniJSON/Scripts/FormatterExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/FormatterExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/FormatterExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/FormatterExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/FormatterExtensionsSerializer.cs b/Assets/UniGLTF/Runtime/UniJSON/FormatterExtensionsSerializer.cs similarity index 90% rename from Assets/VRM/UniJSON/Scripts/FormatterExtensionsSerializer.cs rename to Assets/UniGLTF/Runtime/UniJSON/FormatterExtensionsSerializer.cs index 53d89b67e..ed3bbd145 100644 --- a/Assets/VRM/UniJSON/Scripts/FormatterExtensionsSerializer.cs +++ b/Assets/UniGLTF/Runtime/UniJSON/FormatterExtensionsSerializer.cs @@ -140,21 +140,7 @@ namespace UniJSON } } - { - // reflection - var schema = JsonSchema.FromType(); - return (IFormatter f, T value) => - { - var c = new JsonSchemaValidationContext(value) - { - EnableDiagnosisForNotRequiredFields = true - }; - schema.Serialize(f, value, c); - }; - } - - - //throw new NotImplementedException(); + throw new NotImplementedException(); } static Serializer s_serializer; diff --git a/Assets/VRM/UniJSON/Scripts/FormatterExtensionsSerializer.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/FormatterExtensionsSerializer.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/FormatterExtensionsSerializer.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/FormatterExtensionsSerializer.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/GenericCallUtility.meta b/Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericCallUtility.meta rename to Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility.meta diff --git a/Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericExpressionCallFactory.cs b/Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericExpressionCallFactory.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericExpressionCallFactory.cs rename to Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericExpressionCallFactory.cs diff --git a/Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericExpressionCallFactory.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericExpressionCallFactory.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericExpressionCallFactory.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericExpressionCallFactory.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericExpressionCallFactory.g.cs b/Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericExpressionCallFactory.g.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericExpressionCallFactory.g.cs rename to Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericExpressionCallFactory.g.cs diff --git a/Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericExpressionCallFactory.g.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericExpressionCallFactory.g.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericExpressionCallFactory.g.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericExpressionCallFactory.g.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericInvokeCallFactory.cs b/Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericInvokeCallFactory.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericInvokeCallFactory.cs rename to Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericInvokeCallFactory.cs index c5022bb95..9ceeca036 100644 --- a/Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericInvokeCallFactory.cs +++ b/Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericInvokeCallFactory.cs @@ -1,7 +1,7 @@ using System; using System.Reflection; -using UnityEngine; #if UNITY_EDITOR && VRM_DEVELOP +using UnityEngine; using System.IO; using System.Linq; using System.Text; diff --git a/Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericInvokeCallFactory.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericInvokeCallFactory.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericInvokeCallFactory.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericInvokeCallFactory.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericInvokeCallFactory.g.cs b/Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericInvokeCallFactory.g.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericInvokeCallFactory.g.cs rename to Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericInvokeCallFactory.g.cs diff --git a/Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericInvokeCallFactory.g.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericInvokeCallFactory.g.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericInvokeCallFactory.g.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/GenericCallUtility/GenericInvokeCallFactory.g.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/GenericCast.cs b/Assets/UniGLTF/Runtime/UniJSON/GenericCast.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericCast.cs rename to Assets/UniGLTF/Runtime/UniJSON/GenericCast.cs diff --git a/Assets/VRM/UniJSON/Scripts/GenericCast.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/GenericCast.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericCast.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/GenericCast.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/GenericConstructor.cs b/Assets/UniGLTF/Runtime/UniJSON/GenericConstructor.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericConstructor.cs rename to Assets/UniGLTF/Runtime/UniJSON/GenericConstructor.cs diff --git a/Assets/VRM/UniJSON/Scripts/GenericConstructor.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/GenericConstructor.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/GenericConstructor.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/GenericConstructor.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/IFileSystemAccessor.cs b/Assets/UniGLTF/Runtime/UniJSON/IFileSystemAccessor.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IFileSystemAccessor.cs rename to Assets/UniGLTF/Runtime/UniJSON/IFileSystemAccessor.cs diff --git a/Assets/VRM/UniJSON/Scripts/IFileSystemAccessor.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/IFileSystemAccessor.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IFileSystemAccessor.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/IFileSystemAccessor.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/IFormatter.cs b/Assets/UniGLTF/Runtime/UniJSON/IFormatter.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IFormatter.cs rename to Assets/UniGLTF/Runtime/UniJSON/IFormatter.cs diff --git a/Assets/VRM/UniJSON/Scripts/IFormatter.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/IFormatter.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IFormatter.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/IFormatter.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniJSON/IStore.meta b/Assets/UniGLTF/Runtime/UniJSON/IStore.meta new file mode 100644 index 000000000..4b9176d39 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniJSON/IStore.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ebb5538d1d7335e4fa1809ecd49da2b5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/IStore/ByteUnion.cs b/Assets/UniGLTF/Runtime/UniJSON/IStore/ByteUnion.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IStore/ByteUnion.cs rename to Assets/UniGLTF/Runtime/UniJSON/IStore/ByteUnion.cs diff --git a/Assets/VRM/UniJSON/Scripts/IStore/ByteUnion.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/IStore/ByteUnion.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IStore/ByteUnion.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/IStore/ByteUnion.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/IStore/BytesStore.cs b/Assets/UniGLTF/Runtime/UniJSON/IStore/BytesStore.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IStore/BytesStore.cs rename to Assets/UniGLTF/Runtime/UniJSON/IStore/BytesStore.cs diff --git a/Assets/VRM/UniJSON/Scripts/IStore/BytesStore.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/IStore/BytesStore.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IStore/BytesStore.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/IStore/BytesStore.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/IStore/IStore.cs b/Assets/UniGLTF/Runtime/UniJSON/IStore/IStore.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IStore/IStore.cs rename to Assets/UniGLTF/Runtime/UniJSON/IStore/IStore.cs diff --git a/Assets/VRM/UniJSON/Scripts/IStore/IStore.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/IStore/IStore.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IStore/IStore.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/IStore/IStore.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/IStore/StreamStore.cs b/Assets/UniGLTF/Runtime/UniJSON/IStore/StreamStore.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IStore/StreamStore.cs rename to Assets/UniGLTF/Runtime/UniJSON/IStore/StreamStore.cs diff --git a/Assets/VRM/UniJSON/Scripts/IStore/StreamStore.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/IStore/StreamStore.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IStore/StreamStore.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/IStore/StreamStore.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/IStore/StringBuilderStore.cs b/Assets/UniGLTF/Runtime/UniJSON/IStore/StringBuilderStore.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IStore/StringBuilderStore.cs rename to Assets/UniGLTF/Runtime/UniJSON/IStore/StringBuilderStore.cs diff --git a/Assets/VRM/UniJSON/Scripts/IStore/StringBuilderStore.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/IStore/StringBuilderStore.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IStore/StringBuilderStore.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/IStore/StringBuilderStore.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/ITreeNode.cs b/Assets/UniGLTF/Runtime/UniJSON/ITreeNode.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ITreeNode.cs rename to Assets/UniGLTF/Runtime/UniJSON/ITreeNode.cs diff --git a/Assets/VRM/UniJSON/Scripts/ITreeNode.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/ITreeNode.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ITreeNode.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/ITreeNode.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/IValue.cs b/Assets/UniGLTF/Runtime/UniJSON/IValue.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IValue.cs rename to Assets/UniGLTF/Runtime/UniJSON/IValue.cs diff --git a/Assets/VRM/UniJSON/Scripts/IValue.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/IValue.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/IValue.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/IValue.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniJSON/Json.meta b/Assets/UniGLTF/Runtime/UniJSON/Json.meta new file mode 100644 index 000000000..e74cb4108 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniJSON/Json.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2e5516a6af2ae814e8c6a5302f6b6bc9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonDiff.cs b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonDiff.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Json/JsonDiff.cs rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonDiff.cs diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonDiff.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonDiff.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Json/JsonDiff.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonDiff.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonFormatter.cs b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonFormatter.cs similarity index 98% rename from Assets/VRM/UniJSON/Scripts/Json/JsonFormatter.cs rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonFormatter.cs index edfc41a98..35c9c0dd7 100644 --- a/Assets/VRM/UniJSON/Scripts/Json/JsonFormatter.cs +++ b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonFormatter.cs @@ -7,7 +7,7 @@ using System.Text; namespace UniJSON { - public class JsonFormatter : IFormatter, IRpc + public class JsonFormatter : IFormatter { IStore m_w; protected IStore Store @@ -266,6 +266,12 @@ namespace UniJSON m_w.Write('"'); } + public void Raw(ArraySegment x) + { + CommaCheck(); + m_w.Write(x); + } + // ISO-8601: YYYY-MM-DD“T”hh:mm:ss“Z” public void Value(DateTimeOffset x) { diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonFormatter.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonFormatter.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Json/JsonFormatter.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonFormatter.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonParser.cs b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonParser.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Json/JsonParser.cs rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonParser.cs diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonParser.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonParser.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Json/JsonParser.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonParser.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonPointer.cs b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonPointer.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Json/JsonPointer.cs rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonPointer.cs diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonPointer.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonPointer.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Json/JsonPointer.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonPointer.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonString.cs b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonString.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Json/JsonString.cs rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonString.cs diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonString.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonString.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Json/JsonString.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonString.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonValue.cs b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonValue.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Json/JsonValue.cs rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonValue.cs diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonValue.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Json/JsonValue.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Json/JsonValue.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Json/JsonValue.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode.meta b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode.meta new file mode 100644 index 000000000..9c972ca85 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d587b4e9bd0d6e044a77b0111f825c90 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNode.cs b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNode.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNode.cs rename to Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNode.cs diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNode.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNode.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNode.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNode.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeArrayExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeArrayExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeArrayExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeArrayExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeArrayExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeArrayExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeArrayExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeArrayExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeJsonPointerExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeJsonPointerExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeJsonPointerExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeJsonPointerExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeJsonPointerExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeJsonPointerExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeJsonPointerExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeJsonPointerExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeObjectExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeObjectExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeObjectExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeObjectExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeObjectExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeObjectExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeObjectExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/ListTreeNode/ListTreeNodeObjectExtensions.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniJSON/MsgPack.meta b/Assets/UniGLTF/Runtime/UniJSON/MsgPack.meta new file mode 100644 index 000000000..d50a251e1 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniJSON/MsgPack.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1cffddcba2f97d44589d1fe7e05dfc2d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/EndianConverter.cs b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/EndianConverter.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/EndianConverter.cs rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/EndianConverter.cs diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/EndianConverter.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/EndianConverter.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/EndianConverter.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/EndianConverter.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/Exceptions.cs b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/Exceptions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/Exceptions.cs rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/Exceptions.cs diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/Exceptions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/Exceptions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/Exceptions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/Exceptions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackFormatter.cs b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackFormatter.cs similarity index 99% rename from Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackFormatter.cs rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackFormatter.cs index 47e4ff388..f20543f93 100644 --- a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackFormatter.cs +++ b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackFormatter.cs @@ -3,7 +3,7 @@ namespace UniJSON { - public class MsgPackFormatter : IFormatter, IRpc + public class MsgPackFormatter : IFormatter { IStore m_store; public MsgPackFormatter(IStore store) diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackFormatter.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackFormatter.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackFormatter.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackFormatter.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackParser.cs b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackParser.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackParser.cs rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackParser.cs diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackParser.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackParser.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackParser.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackParser.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackType.cs b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackType.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackType.cs rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackType.cs diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackType.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackType.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackType.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackType.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackTypeExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackTypeExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackTypeExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackTypeExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackTypeExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackTypeExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackTypeExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackTypeExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackValue.cs b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackValue.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackValue.cs rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackValue.cs diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackValue.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackValue.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/MsgPack/MsgPackValue.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/MsgPack/MsgPackValue.cs.meta diff --git a/Assets/UniGLTF/Runtime/UniJSON/Toml.meta b/Assets/UniGLTF/Runtime/UniJSON/Toml.meta new file mode 100644 index 000000000..94236f5d2 --- /dev/null +++ b/Assets/UniGLTF/Runtime/UniJSON/Toml.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 69e0a1360efdf0a4093b010d322bc05a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Toml/TomlParser.cs b/Assets/UniGLTF/Runtime/UniJSON/Toml/TomlParser.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Toml/TomlParser.cs rename to Assets/UniGLTF/Runtime/UniJSON/Toml/TomlParser.cs diff --git a/Assets/VRM/UniJSON/Scripts/Toml/TomlParser.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Toml/TomlParser.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Toml/TomlParser.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Toml/TomlParser.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Toml/TomlValue.cs b/Assets/UniGLTF/Runtime/UniJSON/Toml/TomlValue.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Toml/TomlValue.cs rename to Assets/UniGLTF/Runtime/UniJSON/Toml/TomlValue.cs diff --git a/Assets/VRM/UniJSON/Scripts/Toml/TomlValue.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Toml/TomlValue.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Toml/TomlValue.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Toml/TomlValue.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String.meta b/Assets/UniGLTF/Runtime/UniJSON/Utf8String.meta similarity index 77% rename from Assets/VRM/UniJSON/Scripts/Utf8String.meta rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String.meta index e62a8f04e..cb1938cb5 100644 --- a/Assets/VRM/UniJSON/Scripts/Utf8String.meta +++ b/Assets/UniGLTF/Runtime/UniJSON/Utf8String.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0e40e6ba8a3b47845ab0c82501dbb7d1 +guid: f07bdc748cacb454aadaff841173408b folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/IUtf8String.cs b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/IUtf8String.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/IUtf8String.cs rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/IUtf8String.cs diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/IUtf8String.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/IUtf8String.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/IUtf8String.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/IUtf8String.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/Utf8Iterator.cs b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8Iterator.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/Utf8Iterator.cs rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8Iterator.cs diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/Utf8Iterator.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8Iterator.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/Utf8Iterator.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8Iterator.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/Utf8String.cs b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8String.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/Utf8String.cs rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8String.cs diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/Utf8String.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8String.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/Utf8String.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8String.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringBuilder.cs b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringBuilder.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringBuilder.cs rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringBuilder.cs diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringBuilder.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringBuilder.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringBuilder.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringBuilder.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringExtensions.cs.meta diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringSplitterExtensions.cs b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringSplitterExtensions.cs similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringSplitterExtensions.cs rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringSplitterExtensions.cs diff --git a/Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringSplitterExtensions.cs.meta b/Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringSplitterExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Scripts/Utf8String/Utf8StringSplitterExtensions.cs.meta rename to Assets/UniGLTF/Runtime/UniJSON/Utf8String/Utf8StringSplitterExtensions.cs.meta diff --git a/Assets/VRM/DepthFirstScheduler/Editor/Tests.meta b/Assets/UniGLTF/Tests.meta similarity index 77% rename from Assets/VRM/DepthFirstScheduler/Editor/Tests.meta rename to Assets/UniGLTF/Tests.meta index 60f4d20d3..25e1f46f2 100644 --- a/Assets/VRM/DepthFirstScheduler/Editor/Tests.meta +++ b/Assets/UniGLTF/Tests.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 09d89e608be4dc847bde82a73a9d2d2d +guid: bfa02900a1cd1054b87b8de71a654e78 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/UniGLTF/Tests/DepthFirstScheduler.meta b/Assets/UniGLTF/Tests/DepthFirstScheduler.meta new file mode 100644 index 000000000..adcbf986e --- /dev/null +++ b/Assets/UniGLTF/Tests/DepthFirstScheduler.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: abe759a0ef0133e4b9e51332a2e46a6f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/DepthFirstScheduler/Editor/Tests/DepthFirstScheduler.cs b/Assets/UniGLTF/Tests/DepthFirstScheduler/DepthFirstScheduler.cs similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Editor/Tests/DepthFirstScheduler.cs rename to Assets/UniGLTF/Tests/DepthFirstScheduler/DepthFirstScheduler.cs diff --git a/Assets/VRM/DepthFirstScheduler/Editor/Tests/DepthFirstScheduler.cs.meta b/Assets/UniGLTF/Tests/DepthFirstScheduler/DepthFirstScheduler.cs.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/Editor/Tests/DepthFirstScheduler.cs.meta rename to Assets/UniGLTF/Tests/DepthFirstScheduler/DepthFirstScheduler.cs.meta diff --git a/Assets/UniGLTF/Tests/UniGLTF.Tests.asmdef b/Assets/UniGLTF/Tests/UniGLTF.Tests.asmdef new file mode 100644 index 000000000..326fd1ce3 --- /dev/null +++ b/Assets/UniGLTF/Tests/UniGLTF.Tests.asmdef @@ -0,0 +1,18 @@ +{ + "name": "UniGLTF.Tests", + "references": [ + "UniGLTF" + ], + "optionalUnityReferences": [ + "TestAssemblies" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [] +} \ No newline at end of file diff --git a/Assets/VRM/UniJSON/Editor/Tests/UniJSON.Editor.Tests.asmdef.meta b/Assets/UniGLTF/Tests/UniGLTF.Tests.asmdef.meta similarity index 76% rename from Assets/VRM/UniJSON/Editor/Tests/UniJSON.Editor.Tests.asmdef.meta rename to Assets/UniGLTF/Tests/UniGLTF.Tests.asmdef.meta index ebbee0a73..1b401c3d8 100644 --- a/Assets/VRM/UniJSON/Editor/Tests/UniJSON.Editor.Tests.asmdef.meta +++ b/Assets/UniGLTF/Tests/UniGLTF.Tests.asmdef.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 96fc039f80992a14a8b7b93aa81a3112 +guid: f9fe54bb3090be448aa10ac92648a614 AssemblyDefinitionImporter: externalObjects: {} userData: diff --git a/Assets/UniGLTF/Tests/UniGLTF.meta b/Assets/UniGLTF/Tests/UniGLTF.meta new file mode 100644 index 000000000..152f4290e --- /dev/null +++ b/Assets/UniGLTF/Tests/UniGLTF.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5c852d7252af5264d9f0e6cde91aa2a7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/Tests/CacheEnumTest.cs b/Assets/UniGLTF/Tests/UniGLTF/CacheEnumTest.cs similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Tests/CacheEnumTest.cs rename to Assets/UniGLTF/Tests/UniGLTF/CacheEnumTest.cs diff --git a/Assets/VRM/UniGLTF/Editor/Tests/CacheEnumTest.cs.meta b/Assets/UniGLTF/Tests/UniGLTF/CacheEnumTest.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Tests/CacheEnumTest.cs.meta rename to Assets/UniGLTF/Tests/UniGLTF/CacheEnumTest.cs.meta diff --git a/Assets/UniGLTF/Tests/UniGLTF/JsonDeserializeTests.cs b/Assets/UniGLTF/Tests/UniGLTF/JsonDeserializeTests.cs new file mode 100644 index 000000000..7119c3cc3 --- /dev/null +++ b/Assets/UniGLTF/Tests/UniGLTF/JsonDeserializeTests.cs @@ -0,0 +1,13 @@ +using NUnit.Framework; +using UnityEngine; + +namespace UniGLTF +{ + public class JsonDeserializeTests + { + static T deserialize(string json) + { + return JsonUtility.FromJson(json); + } + } +} diff --git a/Assets/VRM/UniGLTF/Editor/Tests/JsonDeserializeTests.cs.meta b/Assets/UniGLTF/Tests/UniGLTF/JsonDeserializeTests.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Tests/JsonDeserializeTests.cs.meta rename to Assets/UniGLTF/Tests/UniGLTF/JsonDeserializeTests.cs.meta diff --git a/Assets/VRM/UniGLTF/Editor/Tests/MaterialTests.cs b/Assets/UniGLTF/Tests/UniGLTF/MaterialTests.cs similarity index 69% rename from Assets/VRM/UniGLTF/Editor/Tests/MaterialTests.cs rename to Assets/UniGLTF/Tests/UniGLTF/MaterialTests.cs index 99d3a9dd6..d34f3dd4c 100644 --- a/Assets/VRM/UniGLTF/Editor/Tests/MaterialTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/MaterialTests.cs @@ -1,6 +1,8 @@ -using NUnit.Framework; +using System.Collections.Generic; +using NUnit.Framework; using UnityEngine; - +using UniJSON; +using System.Linq; namespace UniGLTF { @@ -28,15 +30,62 @@ namespace UniGLTF var materialExporter = new MaterialExporter(); var gltfMaterial = materialExporter.ExportMaterial(srcMaterial, textureManager); + gltfMaterial.pbrMetallicRoughness.baseColorTexture.extensions = gltfMaterial.pbrMetallicRoughness.baseColorTexture.extensions.Deserialize(); var shaderStore = new ShaderStore(null); - var materialImporter = new MaterialImporter(shaderStore, (int index) => {return null;}); - var dstMaterial = materialImporter.CreateMaterial(0,gltfMaterial, false); + var materialImporter = new MaterialImporter(shaderStore, (int index) => { return null; }); + var dstMaterial = materialImporter.CreateMaterial(0, gltfMaterial, false); - Assert.AreEqual(dstMaterial.mainTextureOffset.x, offset.x, 0.001f); - Assert.AreEqual(dstMaterial.mainTextureOffset.y, offset.y, 0.001f); - Assert.AreEqual(dstMaterial.mainTextureScale.x, scale.x, 0.001f); - Assert.AreEqual(dstMaterial.mainTextureScale.y, scale.y, 0.001f); + Assert.AreEqual(dstMaterial.mainTextureOffset.x, offset.x, 0.3f); + Assert.AreEqual(dstMaterial.mainTextureOffset.y, offset.y, 0.2f); + Assert.AreEqual(dstMaterial.mainTextureScale.x, scale.x, 0.5f); + Assert.AreEqual(dstMaterial.mainTextureScale.y, scale.y, 0.6f); + } + + [Test] + public void glTF_KHR_materials_unlit_Test() + { + { + var value = "{}".ParseAsJson(); + Assert.AreEqual(value.Value.ValueType, ValueNodeType.Object); + Assert.AreEqual(0, value.GetObjectCount()); + var list = value.ObjectItems().ToArray(); + Assert.AreEqual(0, list.Length); + } + + { + var value = "{\"unlit\":{}}".ParseAsJson(); + Assert.AreEqual(value.Value.ValueType, ValueNodeType.Object); + Assert.AreEqual(1, value.GetObjectCount()); + var list = value.ObjectItems().ToArray(); + Assert.AreEqual(1, list.Length); + Assert.AreEqual("unlit", list[0].Key.GetString()); + Assert.AreEqual(0, list[0].Value.GetObjectCount()); + } + + { + var extension = glTF_KHR_materials_unlit.Serialize().Deserialize(); + var list = extension.ObjectItems().ToArray(); + Assert.AreEqual(1, list.Length); + Assert.AreEqual(glTF_KHR_materials_unlit.ExtensionNameUtf8, list[0].Key.GetUtf8String()); + Assert.AreEqual(0, list[0].Value.GetObjectCount()); + + var material = new glTFMaterial + { + alphaMode = "OPAQUE", + pbrMetallicRoughness = new glTFPbrMetallicRoughness + { + baseColorFactor = new float[] { 1, 0, 0, 1 }, + }, + extensions = extension, + }; + + Assert.IsTrue(glTF_KHR_materials_unlit.IsEnable(material)); + + var shaderStore = new ShaderStore(null); + var shader = shaderStore.GetShader(material); + Assert.AreEqual("UniGLTF/UniUnlit", shader.name); + } } [Test] @@ -53,10 +102,7 @@ namespace UniGLTF { baseColorFactor = new float[] { 1, 0, 0, 1 }, }, - extensions = new glTFMaterial_extensions - { - KHR_materials_unlit = new glTF_KHR_materials_unlit { } - } + extensions = glTF_KHR_materials_unlit.Serialize().Deserialize(), }); Assert.AreEqual("UniGLTF/UniUnlit", shader.name); } @@ -70,10 +116,7 @@ namespace UniGLTF { baseColorTexture = new glTFMaterialBaseColorTextureInfo(), }, - extensions = new glTFMaterial_extensions - { - KHR_materials_unlit = new glTF_KHR_materials_unlit { } - } + extensions = glTF_KHR_materials_unlit.Serialize().Deserialize(), }); Assert.AreEqual("UniGLTF/UniUnlit", shader.name); } @@ -88,10 +131,7 @@ namespace UniGLTF baseColorFactor = new float[] { 1, 0, 0, 1 }, baseColorTexture = new glTFMaterialBaseColorTextureInfo(), }, - extensions = new glTFMaterial_extensions - { - KHR_materials_unlit = new glTF_KHR_materials_unlit { } - } + extensions = glTF_KHR_materials_unlit.Serialize().Deserialize(), }); Assert.AreEqual("UniGLTF/UniUnlit", shader.name); } @@ -105,10 +145,7 @@ namespace UniGLTF { baseColorFactor = new float[] { 1, 0, 0, 1 }, }, - extensions = new glTFMaterial_extensions - { - KHR_materials_unlit = new glTF_KHR_materials_unlit { } - } + extensions = glTF_KHR_materials_unlit.Serialize().Deserialize(), }); Assert.AreEqual("UniGLTF/UniUnlit", shader.name); } @@ -122,10 +159,7 @@ namespace UniGLTF { baseColorTexture = new glTFMaterialBaseColorTextureInfo(), }, - extensions = new glTFMaterial_extensions - { - KHR_materials_unlit = new glTF_KHR_materials_unlit { } - } + extensions = glTF_KHR_materials_unlit.Serialize().Deserialize(), }); Assert.AreEqual("UniGLTF/UniUnlit", shader.name); } @@ -140,10 +174,7 @@ namespace UniGLTF baseColorFactor = new float[] { 1, 0, 0, 1 }, baseColorTexture = new glTFMaterialBaseColorTextureInfo(), }, - extensions = new glTFMaterial_extensions - { - KHR_materials_unlit = new glTF_KHR_materials_unlit { } - } + extensions = glTF_KHR_materials_unlit.Serialize().Deserialize(), }); Assert.AreEqual("UniGLTF/UniUnlit", shader.name); } @@ -157,10 +188,7 @@ namespace UniGLTF { baseColorTexture = new glTFMaterialBaseColorTextureInfo(), }, - extensions = new glTFMaterial_extensions - { - KHR_materials_unlit = new glTF_KHR_materials_unlit { } - } + extensions = glTF_KHR_materials_unlit.Serialize().Deserialize(), }); Assert.AreEqual("UniGLTF/UniUnlit", shader.name); } @@ -175,10 +203,7 @@ namespace UniGLTF baseColorFactor = new float[] { 1, 0, 0, 1 }, baseColorTexture = new glTFMaterialBaseColorTextureInfo(), }, - extensions = new glTFMaterial_extensions - { - KHR_materials_unlit = new glTF_KHR_materials_unlit { } - } + extensions = glTF_KHR_materials_unlit.Serialize().Deserialize(), }); Assert.AreEqual("UniGLTF/UniUnlit", shader.name); } @@ -187,10 +212,7 @@ namespace UniGLTF // default var shader = shaderStore.GetShader(new glTFMaterial { - extensions = new glTFMaterial_extensions - { - KHR_materials_unlit = new glTF_KHR_materials_unlit { } - } + extensions = glTF_KHR_materials_unlit.Serialize().Deserialize(), }); Assert.AreEqual("UniGLTF/UniUnlit", shader.name); } diff --git a/Assets/VRM/UniGLTF/Editor/Tests/MaterialTests.cs.meta b/Assets/UniGLTF/Tests/UniGLTF/MaterialTests.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Tests/MaterialTests.cs.meta rename to Assets/UniGLTF/Tests/UniGLTF/MaterialTests.cs.meta diff --git a/Assets/VRM/UniGLTF/Editor/Tests/TextureTests.cs b/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Tests/TextureTests.cs rename to Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs diff --git a/Assets/VRM/UniGLTF/Editor/Tests/TextureTests.cs.meta b/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Tests/TextureTests.cs.meta rename to Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs.meta diff --git a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs similarity index 72% rename from Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs rename to Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs index 0c090fecf..8d0ce2d1b 100644 --- a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs @@ -8,6 +8,58 @@ using UnityEngine; namespace UniGLTF { + static class ToJsonExtensions + { + public static string ToJson(this glTF self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize(f, self); + return f.ToString(); + } + public static string ToJson(this glTFMesh self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_meshes_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTFPrimitives self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_meshes__primitives_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTFAttributes self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_meshes__primitives__attributes(f, self); + return f.ToString(); + } + public static string ToJson(this glTFMaterialBaseColorTextureInfo self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(f, self); + return f.ToString(); + } + public static string ToJson(this glTFMaterial self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_materials_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTFNode self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_nodes_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTFSkin self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_skins_ITEM(f, self); + return f.ToString(); + } + } + public class UniGLTFTests { static GameObject CreateSimpleScene() @@ -156,24 +208,18 @@ namespace UniGLTF { new glTFPrimitives { + indices = 0, attributes = new glTFAttributes { - POSITION = 0, + POSITION = 1, } } }, }; var json = model.ToJson(); - Assert.AreEqual(@"{""name"":""mesh"",""primitives"":[{""mode"":0,""indices"":-1,""attributes"":{""POSITION"":0},""material"":0}]}", json); + Assert.AreEqual(@"{""name"":""mesh"",""primitives"":[{""mode"":0,""indices"":0,""attributes"":{""POSITION"":1},""material"":0}]}", json); Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""name"":""mesh"",""primitives"":[{""mode"":0,""attributes"":{""POSITION"":0},""material"":0}]}", json2); } [Test] @@ -181,29 +227,17 @@ namespace UniGLTF { var model = new glTFPrimitives { + indices = 0, attributes = new glTFAttributes { - POSITION = 0, + POSITION = 1, }, - extras = new glTFPrimitives_extras - { - targetNames = new List - { - "aaa", - } - } + extras = gltf_mesh_extras_targetNames.Serialize("aaa"), }; var json = model.ToJson(); - Assert.AreEqual(@"{""mode"":0,""indices"":-1,""attributes"":{""POSITION"":0},""material"":0,""extras"":{""targetNames"":[""aaa""]}}", json); + Assert.AreEqual(@"{""mode"":0,""indices"":0,""attributes"":{""POSITION"":1},""material"":0,""extras"":{""targetNames"":[""aaa""]}}", json); Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""mode"":0,""attributes"":{""POSITION"":0},""material"":0,""extras"":{""targetNames"":[""aaa""]}}", json2); } [Test] @@ -217,13 +251,6 @@ namespace UniGLTF var json = model.ToJson(); Assert.AreEqual(@"{""POSITION"":0}", json); Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(json, json2); } [Test] @@ -237,28 +264,12 @@ namespace UniGLTF var json = model.ToJson(); Assert.AreEqual(@"{""index"":1,""texCoord"":0}", json); Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(json, json2); } [Test] public void TextureInfoTestError() { var model = new glTFMaterialBaseColorTextureInfo(); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[index.String] minimum: ! -1>=0", ex.Message); } [Test] @@ -273,13 +284,6 @@ namespace UniGLTF var json = model.ToJson(); Assert.AreEqual(@"{""name"":""a"",""pbrMetallicRoughness"":{""baseColorFactor"":[1,1,1,1],""metallicFactor"":1,""roughnessFactor"":1},""emissiveFactor"":[0.5,0.5,0.5],""doubleSided"":false}", json); Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""name"":""a"",""pbrMetallicRoughness"":{""baseColorFactor"":[1,1,1,1],""metallicFactor"":1,""roughnessFactor"":1},""emissiveFactor"":[0.5,0.5,0.5],""doubleSided"":false}", json2); } [Test] @@ -291,13 +295,6 @@ namespace UniGLTF emissiveFactor = new float[] { 0.5f, 0.5f, 0.5f }, alphaMode = "MASK", }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""name"":""a"",""pbrMetallicRoughness"":{""baseColorFactor"":[1,1,1,1],""metallicFactor"":1,""roughnessFactor"":1},""emissiveFactor"":[0.5,0.5,0.5],""alphaMode"":""MASK"",""alphaCutoff"":0.5,""doubleSided"":false}", json); } [Test] @@ -384,15 +381,6 @@ namespace UniGLTF name = "b", emissiveFactor = new float[] { 1.5f, 0.5f, 0.5f }, }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[emissiveFactor.String] maximum: ! 1.5<=1", ex.Message); } [Test] @@ -408,13 +396,6 @@ namespace UniGLTF var json = model.ToJson(); Assert.AreEqual(@"{""name"":""a"",""skin"":0}", json); Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""name"":""a"",""extras"":{}}", json2); } [Test] @@ -427,13 +408,6 @@ namespace UniGLTF skin = 0, camera = -1, }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""name"":""a"",""mesh"":2,""skin"":0,""extras"":{}}", json); } [Test] @@ -444,15 +418,6 @@ namespace UniGLTF name = "a", camera = -2, }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[camera.String] minimum: ! -2>=0", ex.Message); } [Test] @@ -460,42 +425,30 @@ namespace UniGLTF { var model = new glTFSkin() { + inverseBindMatrices = 0, name = "b", joints = new int[] { 1 }, }; var json = model.ToJson(); - Assert.AreEqual(@"{""inverseBindMatrices"":-1,""joints"":[1]}", json); + Assert.AreEqual(@"{""inverseBindMatrices"":0,""joints"":[1],""name"":""b""}", json); Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""joints"":[1],""name"":""b""}", json2); } [Test] public void SkinTestEmptyName() { var model = new glTFSkin() - { + { name = "", + inverseBindMatrices = 4, joints = new int[] { 1 }, }; var json = model.ToJson(); // "name" = "", not excluded - Assert.AreEqual(@"{""inverseBindMatrices"":-1,""joints"":[1]}", json); + Assert.AreEqual(@"{""inverseBindMatrices"":4,""joints"":[1]}", json); Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""joints"":[1],""name"":""""}", json2); } [Test] @@ -506,15 +459,6 @@ namespace UniGLTF name = "b", joints = null, }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[joints.String] null", ex.Message); } [Test] @@ -525,15 +469,6 @@ namespace UniGLTF name = "b", joints = new int[] { }, }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[joints.String] minItems", ex.Message); } [Test] @@ -547,13 +482,6 @@ namespace UniGLTF //var json = model.ToJson(); //Assert.AreEqual(@"{""inverseBindMatrices"":-1,""joints"":[1]}", json); //Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""version"":""0.49""}", json2); } [Test] @@ -564,15 +492,6 @@ namespace UniGLTF //var json = model.ToJson(); //Assert.AreEqual(@"{""inverseBindMatrices"":-1,""joints"":[1]}", json); //Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[version.String] null", ex.Message); } [Test] @@ -584,15 +503,7 @@ namespace UniGLTF { version = "0.49", }, - extensions = null, }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""asset"":{""version"":""0.49""},""extras"":{}}", json2); } [Test] @@ -712,13 +623,5 @@ namespace UniGLTF Assert.NotNull(dummy.Value); Assert.False(dummy.Value.Value); } - - [Test] - public void UniJSONTest() - { - var dummy = default(Dummy); - "{}".ParseAsJson().Deserialize(ref dummy); - Assert.Null(dummy.Value); - } } } diff --git a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs.meta b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs.meta similarity index 100% rename from Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs.meta rename to Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs.meta diff --git a/Assets/UniGLTF/Tests/UniJSON.meta b/Assets/UniGLTF/Tests/UniJSON.meta new file mode 100644 index 000000000..2b0ab60e1 --- /dev/null +++ b/Assets/UniGLTF/Tests/UniJSON.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 596f889e0a9d9e9498fdb37c99e58166 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/GenericCallUtilityTests.cs b/Assets/UniGLTF/Tests/UniJSON/GenericCallUtilityTests.cs similarity index 96% rename from Assets/VRM/UniJSON/Editor/Tests/GenericCallUtilityTests.cs rename to Assets/UniGLTF/Tests/UniJSON/GenericCallUtilityTests.cs index a27c4a4d2..591bbe4ab 100644 --- a/Assets/VRM/UniJSON/Editor/Tests/GenericCallUtilityTests.cs +++ b/Assets/UniGLTF/Tests/UniJSON/GenericCallUtilityTests.cs @@ -1,5 +1,4 @@ -using UnityEngine; -using NUnit.Framework; +using NUnit.Framework; using System.Collections; using System; diff --git a/Assets/VRM/UniJSON/Editor/Tests/GenericCallUtilityTests.cs.meta b/Assets/UniGLTF/Tests/UniJSON/GenericCallUtilityTests.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/GenericCallUtilityTests.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/GenericCallUtilityTests.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/IWriteStreamTest.cs b/Assets/UniGLTF/Tests/UniJSON/IWriteStreamTest.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/IWriteStreamTest.cs rename to Assets/UniGLTF/Tests/UniJSON/IWriteStreamTest.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/IWriteStreamTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/IWriteStreamTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/IWriteStreamTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/IWriteStreamTest.cs.meta diff --git a/Assets/UniGLTF/Tests/UniJSON/Json.meta b/Assets/UniGLTF/Tests/UniJSON/Json.meta new file mode 100644 index 000000000..8399303d5 --- /dev/null +++ b/Assets/UniGLTF/Tests/UniJSON/Json.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce85f3f4f8260794e8b676e65c6714f3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonDiffTests.cs b/Assets/UniGLTF/Tests/UniJSON/Json/JsonDiffTests.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Json/JsonDiffTests.cs rename to Assets/UniGLTF/Tests/UniJSON/Json/JsonDiffTests.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonDiffTests.cs.meta b/Assets/UniGLTF/Tests/UniJSON/Json/JsonDiffTests.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Json/JsonDiffTests.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/Json/JsonDiffTests.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonFormatterTest.cs b/Assets/UniGLTF/Tests/UniJSON/Json/JsonFormatterTest.cs similarity index 98% rename from Assets/VRM/UniJSON/Editor/Tests/Json/JsonFormatterTest.cs rename to Assets/UniGLTF/Tests/UniJSON/Json/JsonFormatterTest.cs index d8fcc52bf..ff5e614ed 100644 --- a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonFormatterTest.cs +++ b/Assets/UniGLTF/Tests/UniJSON/Json/JsonFormatterTest.cs @@ -1,5 +1,4 @@ using NUnit.Framework; -using UnityEngine; using System.Linq; using System.Text; diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonFormatterTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/Json/JsonFormatterTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Json/JsonFormatterTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/Json/JsonFormatterTest.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonParserTest.cs b/Assets/UniGLTF/Tests/UniJSON/Json/JsonParserTest.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Json/JsonParserTest.cs rename to Assets/UniGLTF/Tests/UniJSON/Json/JsonParserTest.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonParserTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/Json/JsonParserTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Json/JsonParserTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/Json/JsonParserTest.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonSerializerTests.cs b/Assets/UniGLTF/Tests/UniJSON/Json/JsonSerializerTests.cs similarity index 65% rename from Assets/VRM/UniJSON/Editor/Tests/Json/JsonSerializerTests.cs rename to Assets/UniGLTF/Tests/UniJSON/Json/JsonSerializerTests.cs index f96210c7d..646247ffd 100644 --- a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonSerializerTests.cs +++ b/Assets/UniGLTF/Tests/UniJSON/Json/JsonSerializerTests.cs @@ -3,7 +3,7 @@ using System; using System.Linq; using NUnit.Framework; using System.Collections.Generic; - +using UniGLTF; namespace UniJSON { @@ -79,13 +79,13 @@ namespace UniJSON new Dictionary{ } } }, "{\"a\":{}}"); - SerializeValue(new Point { X = 1 }, "{\"X\":1,\"Y\":0}"); + // SerializeValue(new Point { X = 1 }, "{\"X\":1,\"Y\":0}"); - SerializeValue(HogeFuga.Fuga, "1"); + // SerializeValue(HogeFuga.Fuga, "1"); - SerializeValue(new EnumTest(), "{\"EnumDefault\":0,\"EnumAsInt\":0,\"EnumAsString\":\"Hoge\",\"EnumAsLowerString\":\"hoge\"}"); + // SerializeValue(new EnumTest(), "{\"EnumDefault\":0,\"EnumAsInt\":0,\"EnumAsString\":\"Hoge\",\"EnumAsLowerString\":\"hoge\"}"); - SerializeValue((object)new Point { X = 1 }, "{\"X\":1,\"Y\":0}"); + // SerializeValue((object)new Point { X = 1 }, "{\"X\":1,\"Y\":0}"); } [Test] @@ -111,40 +111,40 @@ namespace UniJSON #endregion #region Deserialize - static void DeserializeValue(T value, string json) - { - var parsed = JsonParser.Parse(json); + // static void DeserializeValue(T value, string json) + // { + // var parsed = JsonParser.Parse(json); - var t = default(T); - parsed.Deserialize(ref t); + // var t = default(T); + // parsed.Deserialize(ref t); - Assert.AreEqual(value, t); - } + // Assert.AreEqual(value, t); + // } - [Test] - public void JsonDeserializerTest() - { - DeserializeValue(1, "1"); - DeserializeValue(1.1f, "1.1"); - DeserializeValue(1.2, "1.2"); - DeserializeValue(true, "true"); - DeserializeValue(false, "false"); - DeserializeValue("ascii", "\"ascii\""); + // [Test] + // public void JsonDeserializerTest() + // { + // DeserializeValue(1, "1"); + // DeserializeValue(1.1f, "1.1"); + // DeserializeValue(1.2, "1.2"); + // DeserializeValue(true, "true"); + // DeserializeValue(false, "false"); + // DeserializeValue("ascii", "\"ascii\""); - DeserializeValue(new[] { 1 }, "[1]"); - DeserializeValue(new[] { 1.1f }, "[1.1]"); - DeserializeValue(new[] { 1.2 }, "[1.2]"); - DeserializeValue(new[] { true, false }, "[true,false]"); - DeserializeValue(new[] { "ascii" }, "[\"ascii\"]"); - DeserializeValue(new List { 1 }, "[1]"); - //DeserializeValue(new object[] { null, 1, "a" }, "[null,1,\"a\"]"); + // DeserializeValue(new[] { 1 }, "[1]"); + // DeserializeValue(new[] { 1.1f }, "[1.1]"); + // DeserializeValue(new[] { 1.2 }, "[1.2]"); + // DeserializeValue(new[] { true, false }, "[true,false]"); + // DeserializeValue(new[] { "ascii" }, "[\"ascii\"]"); + // DeserializeValue(new List { 1 }, "[1]"); + // //DeserializeValue(new object[] { null, 1, "a" }, "[null,1,\"a\"]"); - DeserializeValue(new Point { X = 1 }, "{\"X\":1,\"Y\":0}"); + // DeserializeValue(new Point { X = 1 }, "{\"X\":1,\"Y\":0}"); - DeserializeValue(HogeFuga.Fuga, "1"); + // DeserializeValue(HogeFuga.Fuga, "1"); - DeserializeValue(new EnumTest(), "{\"EnumDefault\":0,\"EnumAsInt\":0,\"EnumAsString\":\"Hoge\",\"EnumAsLowerString\":\"hoge\"}"); - } + // DeserializeValue(new EnumTest(), "{\"EnumDefault\":0,\"EnumAsInt\":0,\"EnumAsString\":\"Hoge\",\"EnumAsLowerString\":\"hoge\"}"); + // } class DictionaryValue: IEquatable { @@ -185,18 +185,18 @@ namespace UniJSON } } - [Test] - public void JsonDictionaryDeserializerTest() - { - DeserializeValue(new Dictionary { }, "{}"); - DeserializeValue(new Dictionary { { "a", 1 } }, "{\"a\":1}"); - DeserializeValue(new Dictionary { { "a", - new Dictionary{ - } } }, "{\"a\":{}}"); + // [Test] + // public void JsonDictionaryDeserializerTest() + // { + // DeserializeValue(new Dictionary { }, "{}"); + // DeserializeValue(new Dictionary { { "a", 1 } }, "{\"a\":1}"); + // DeserializeValue(new Dictionary { { "a", + // new Dictionary{ + // } } }, "{\"a\":{}}"); - // fix dictionary member deserialization - DeserializeValue(new DictionaryValue(), "{\"Dict\": {}}"); - } + // // fix dictionary member deserialization + // DeserializeValue(new DictionaryValue(), "{\"Dict\": {}}"); + // } #endregion } } diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonSerializerTests.cs.meta b/Assets/UniGLTF/Tests/UniJSON/Json/JsonSerializerTests.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Json/JsonSerializerTests.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/Json/JsonSerializerTests.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonValueTests.cs b/Assets/UniGLTF/Tests/UniJSON/Json/JsonValueTests.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Json/JsonValueTests.cs rename to Assets/UniGLTF/Tests/UniJSON/Json/JsonValueTests.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/JsonValueTests.cs.meta b/Assets/UniGLTF/Tests/UniJSON/Json/JsonValueTests.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Json/JsonValueTests.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/Json/JsonValueTests.cs.meta diff --git a/Assets/UniGLTF/Tests/UniJSON/MsgPack.meta b/Assets/UniGLTF/Tests/UniJSON/MsgPack.meta new file mode 100644 index 000000000..7dc894002 --- /dev/null +++ b/Assets/UniGLTF/Tests/UniJSON/MsgPack.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a6fe9c2c8212b42459b037f4181cd3ae +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/ArrayTest.cs b/Assets/UniGLTF/Tests/UniJSON/MsgPack/ArrayTest.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/ArrayTest.cs rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/ArrayTest.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/ArrayTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/MsgPack/ArrayTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/ArrayTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/ArrayTest.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/BooleanTest.cs b/Assets/UniGLTF/Tests/UniJSON/MsgPack/BooleanTest.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/BooleanTest.cs rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/BooleanTest.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/BooleanTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/MsgPack/BooleanTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/BooleanTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/BooleanTest.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/FloatTest.cs b/Assets/UniGLTF/Tests/UniJSON/MsgPack/FloatTest.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/FloatTest.cs rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/FloatTest.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/FloatTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/MsgPack/FloatTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/FloatTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/FloatTest.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/IntTest.cs b/Assets/UniGLTF/Tests/UniJSON/MsgPack/IntTest.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/IntTest.cs rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/IntTest.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/IntTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/MsgPack/IntTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/IntTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/IntTest.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/MapTest.cs b/Assets/UniGLTF/Tests/UniJSON/MsgPack/MapTest.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/MapTest.cs rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/MapTest.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/MapTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/MsgPack/MapTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/MapTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/MapTest.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/RawTest.cs b/Assets/UniGLTF/Tests/UniJSON/MsgPack/RawTest.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/RawTest.cs rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/RawTest.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/RawTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/MsgPack/RawTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/RawTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/RawTest.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/StringTest.cs b/Assets/UniGLTF/Tests/UniJSON/MsgPack/StringTest.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/StringTest.cs rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/StringTest.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/StringTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/MsgPack/StringTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/StringTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/StringTest.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/TimeTests.cs b/Assets/UniGLTF/Tests/UniJSON/MsgPack/TimeTests.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/TimeTests.cs rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/TimeTests.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack/TimeTests.cs.meta b/Assets/UniGLTF/Tests/UniJSON/MsgPack/TimeTests.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/MsgPack/TimeTests.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/MsgPack/TimeTests.cs.meta diff --git a/Assets/UniGLTF/Tests/UniJSON/Toml.meta b/Assets/UniGLTF/Tests/UniJSON/Toml.meta new file mode 100644 index 000000000..3d8cdb15a --- /dev/null +++ b/Assets/UniGLTF/Tests/UniJSON/Toml.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8536361e247bd4b408d82604d3b16a10 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/Toml/TomlParserTests.cs b/Assets/UniGLTF/Tests/UniJSON/Toml/TomlParserTests.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Toml/TomlParserTests.cs rename to Assets/UniGLTF/Tests/UniJSON/Toml/TomlParserTests.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/Toml/TomlParserTests.cs.meta b/Assets/UniGLTF/Tests/UniJSON/Toml/TomlParserTests.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Toml/TomlParserTests.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/Toml/TomlParserTests.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/TreeTest.cs b/Assets/UniGLTF/Tests/UniJSON/TreeTest.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/TreeTest.cs rename to Assets/UniGLTF/Tests/UniJSON/TreeTest.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/TreeTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/TreeTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/TreeTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/TreeTest.cs.meta diff --git a/Assets/VRM/UniJSON/Editor/Tests/Utf8StringTest.cs b/Assets/UniGLTF/Tests/UniJSON/Utf8StringTest.cs similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Utf8StringTest.cs rename to Assets/UniGLTF/Tests/UniJSON/Utf8StringTest.cs diff --git a/Assets/VRM/UniJSON/Editor/Tests/Utf8StringTest.cs.meta b/Assets/UniGLTF/Tests/UniJSON/Utf8StringTest.cs.meta similarity index 100% rename from Assets/VRM/UniJSON/Editor/Tests/Utf8StringTest.cs.meta rename to Assets/UniGLTF/Tests/UniJSON/Utf8StringTest.cs.meta diff --git a/Assets/VRM/UniGLTF/doc.meta b/Assets/UniGLTF/doc.meta similarity index 62% rename from Assets/VRM/UniGLTF/doc.meta rename to Assets/UniGLTF/doc.meta index c689ff2de..be296161d 100644 --- a/Assets/VRM/UniGLTF/doc.meta +++ b/Assets/UniGLTF/doc.meta @@ -1,8 +1,6 @@ fileFormatVersion: 2 -guid: 556adc3131466f64ca27f06ff624a0e7 +guid: 67ffcd4667c45a24e80c5c15fee63fd8 folderAsset: yes -timeCreated: 1517138576 -licenseType: Free DefaultImporter: externalObjects: {} userData: diff --git a/Assets/VRM/DepthFirstScheduler/README.md b/Assets/UniGLTF/doc/DepthFirstScheduler.README.md similarity index 100% rename from Assets/VRM/DepthFirstScheduler/README.md rename to Assets/UniGLTF/doc/DepthFirstScheduler.README.md diff --git a/Assets/VRM/DepthFirstScheduler/README.md.meta b/Assets/UniGLTF/doc/DepthFirstScheduler.README.md.meta similarity index 100% rename from Assets/VRM/DepthFirstScheduler/README.md.meta rename to Assets/UniGLTF/doc/DepthFirstScheduler.README.md.meta diff --git a/Assets/VRM/UniGLTF/doc/SciFiHelmet.png b/Assets/UniGLTF/doc/SciFiHelmet.png similarity index 100% rename from Assets/VRM/UniGLTF/doc/SciFiHelmet.png rename to Assets/UniGLTF/doc/SciFiHelmet.png diff --git a/Assets/VRM/UniGLTF/doc/SciFiHelmet.png.meta b/Assets/UniGLTF/doc/SciFiHelmet.png.meta similarity index 100% rename from Assets/VRM/UniGLTF/doc/SciFiHelmet.png.meta rename to Assets/UniGLTF/doc/SciFiHelmet.png.meta diff --git a/Assets/VRM/UniJSON/README.md b/Assets/UniGLTF/doc/UniJSON.README.md similarity index 97% rename from Assets/VRM/UniJSON/README.md rename to Assets/UniGLTF/doc/UniJSON.README.md index 82a5a0221..89136662f 100644 --- a/Assets/VRM/UniJSON/README.md +++ b/Assets/UniGLTF/doc/UniJSON.README.md @@ -58,8 +58,8 @@ public class glTFSparseIndices public glComponentType componentType; // empty schemas - public object extensions; - public object extras; + public glTFExtension extensions; + public glTFExtension extras; } diff --git a/Assets/VRM/UniJSON/README.md.meta b/Assets/UniGLTF/doc/UniJSON.README.md.meta similarity index 100% rename from Assets/VRM/UniJSON/README.md.meta rename to Assets/UniGLTF/doc/UniJSON.README.md.meta diff --git a/Assets/VRM/UniGLTF/doc/animation.gif b/Assets/UniGLTF/doc/animation.gif similarity index 100% rename from Assets/VRM/UniGLTF/doc/animation.gif rename to Assets/UniGLTF/doc/animation.gif diff --git a/Assets/VRM/UniGLTF/doc/animation.gif.meta b/Assets/UniGLTF/doc/animation.gif.meta similarity index 100% rename from Assets/VRM/UniGLTF/doc/animation.gif.meta rename to Assets/UniGLTF/doc/animation.gif.meta diff --git a/Assets/VRM/UniGLTF/doc/duck.png b/Assets/UniGLTF/doc/duck.png similarity index 100% rename from Assets/VRM/UniGLTF/doc/duck.png rename to Assets/UniGLTF/doc/duck.png diff --git a/Assets/VRM/UniGLTF/doc/duck.png.meta b/Assets/UniGLTF/doc/duck.png.meta similarity index 100% rename from Assets/VRM/UniGLTF/doc/duck.png.meta rename to Assets/UniGLTF/doc/duck.png.meta diff --git a/Assets/VRM/UniGLTF/doc/duck_assets.png b/Assets/UniGLTF/doc/duck_assets.png similarity index 100% rename from Assets/VRM/UniGLTF/doc/duck_assets.png rename to Assets/UniGLTF/doc/duck_assets.png diff --git a/Assets/VRM/UniGLTF/doc/duck_assets.png.meta b/Assets/UniGLTF/doc/duck_assets.png.meta similarity index 100% rename from Assets/VRM/UniGLTF/doc/duck_assets.png.meta rename to Assets/UniGLTF/doc/duck_assets.png.meta diff --git a/Assets/VRM/UniGLTF/doc/duck_prefab.png b/Assets/UniGLTF/doc/duck_prefab.png similarity index 100% rename from Assets/VRM/UniGLTF/doc/duck_prefab.png rename to Assets/UniGLTF/doc/duck_prefab.png diff --git a/Assets/VRM/UniGLTF/doc/duck_prefab.png.meta b/Assets/UniGLTF/doc/duck_prefab.png.meta similarity index 100% rename from Assets/VRM/UniGLTF/doc/duck_prefab.png.meta rename to Assets/UniGLTF/doc/duck_prefab.png.meta diff --git a/Assets/VRM/UniGLTF/doc/metalroughness.png b/Assets/UniGLTF/doc/metalroughness.png similarity index 100% rename from Assets/VRM/UniGLTF/doc/metalroughness.png rename to Assets/UniGLTF/doc/metalroughness.png diff --git a/Assets/VRM/UniGLTF/doc/metalroughness.png.meta b/Assets/UniGLTF/doc/metalroughness.png.meta similarity index 100% rename from Assets/VRM/UniGLTF/doc/metalroughness.png.meta rename to Assets/UniGLTF/doc/metalroughness.png.meta diff --git a/Assets/VRM/UniGLTF/doc/pbr_to_standard.png b/Assets/UniGLTF/doc/pbr_to_standard.png similarity index 100% rename from Assets/VRM/UniGLTF/doc/pbr_to_standard.png rename to Assets/UniGLTF/doc/pbr_to_standard.png diff --git a/Assets/VRM/UniGLTF/doc/pbr_to_standard.png.meta b/Assets/UniGLTF/doc/pbr_to_standard.png.meta similarity index 100% rename from Assets/VRM/UniGLTF/doc/pbr_to_standard.png.meta rename to Assets/UniGLTF/doc/pbr_to_standard.png.meta diff --git a/Assets/UniGLTF/package.json b/Assets/UniGLTF/package.json new file mode 100644 index 000000000..4e05ec04c --- /dev/null +++ b/Assets/UniGLTF/package.json @@ -0,0 +1,16 @@ +{ + "name": "com.vrmc.unigltf", + "version": "2.0.0", + "displayName": "UniGLTF", + "description": "GLTF importer and exporter", + "unity": "2018.4", + "keywords": [ + "gltf" + ], + "author": { + "name": "VRM Consortium" + }, + "dependencies": { + "com.vrmc.vrmshaders": "0.62.0" + } +} \ No newline at end of file diff --git a/Assets/VRM/DepthFirstScheduler/Editor/Tests/DepthFirstScheduler.Editor.Tests.asmdef.meta b/Assets/UniGLTF/package.json.meta similarity index 59% rename from Assets/VRM/DepthFirstScheduler/Editor/Tests/DepthFirstScheduler.Editor.Tests.asmdef.meta rename to Assets/UniGLTF/package.json.meta index 702e17d26..cd532d186 100644 --- a/Assets/VRM/DepthFirstScheduler/Editor/Tests/DepthFirstScheduler.Editor.Tests.asmdef.meta +++ b/Assets/UniGLTF/package.json.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 68dc264f14f3454489a3339633e115f9 -AssemblyDefinitionImporter: +guid: 84fc56afa55c6c541b16d7e64f5f0f38 +TextScriptImporter: externalObjects: {} userData: assetBundleName: diff --git a/Assets/VRM.Samples/Editor/Tests/VRM.Samples.Editor.Tests.asmdef b/Assets/VRM.Samples/Editor/Tests/VRM.Samples.Editor.Tests.asmdef index aef7e873a..31fbd23fc 100644 --- a/Assets/VRM.Samples/Editor/Tests/VRM.Samples.Editor.Tests.asmdef +++ b/Assets/VRM.Samples/Editor/Tests/VRM.Samples.Editor.Tests.asmdef @@ -3,9 +3,10 @@ "references": [ "VRM", "VRM.Samples", - "UniVRM.Editor.Tests", - "UniJSON", - "MeshUtility" + "MeshUtility", + "UniGLTF", + "UniVRM.Editor", + "VRM.Tests" ], "optionalUnityReferences": [ "TestAssemblies" diff --git a/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs b/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs index ce0da3f13..c811412d5 100644 --- a/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs +++ b/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs @@ -17,6 +17,13 @@ namespace VRM.Samples var bytes = f.GetStoreBytes(); node.SetValue(p, bytes); } + + public static string ToJson(this glTF self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize(f, self); + return f.ToString(); + } } public class VRMImportExportTests @@ -89,7 +96,7 @@ namespace VRM.Samples // TODO: Check contents in JSON /*var newExportedJson = */ - JsonParser.Parse(JsonSchema.FromType().Serialize(vrm)); + // JsonParser.Parse(JsonSchema.FromType().Serialize(vrm)); /* foreach (var kv in importJson.Diff(exportJson)) @@ -131,12 +138,12 @@ namespace VRM.Samples // 生成シリアライザでJSON化する var f = new JsonFormatter(); - f.GenSerialize(context.GLTF); + GltfSerializer.Serialize(f, context.GLTF); var parsed = f.ToString().ParseAsJson(); var newJson = parsed.ToString(" "); - File.WriteAllText("old.json", oldJson); - File.WriteAllText("new.json", newJson); + // File.WriteAllText("old.json", oldJson); + // File.WriteAllText("new.json", newJson); // 比較 Assert.AreEqual(oldJson.ParseAsJson().ToString(), newJson.ParseAsJson().ToString()); @@ -145,7 +152,7 @@ namespace VRM.Samples var ff = new JsonFormatter(); var des = GltfDeserializer.Deserialize(parsed); ff.Clear(); - ff.GenSerialize(des); + GltfSerializer.Serialize(ff, des); var desJson = ff.ToString().ParseAsJson().ToString(" "); Assert.AreEqual(oldJson.ParseAsJson().ToString(), desJson.ParseAsJson().ToString()); } diff --git a/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs b/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs index 519b9dbee..08cbcb036 100644 --- a/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs +++ b/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs @@ -1,4 +1,5 @@ using System.IO; +using UniGLTF; using UnityEngine; using UnityEngine.UI; using VRM; diff --git a/Assets/VRM.Samples/VRM.Samples.asmdef b/Assets/VRM.Samples/VRM.Samples.asmdef index 3b5bad019..70aae1594 100644 --- a/Assets/VRM.Samples/VRM.Samples.asmdef +++ b/Assets/VRM.Samples/VRM.Samples.asmdef @@ -2,11 +2,15 @@ "name": "VRM.Samples", "references": [ "VRM", - "DepthFirstScheduler", - "UniHumanoid" + "UniHumanoid", + "UniGLTF" ], "optionalUnityReferences": [], "includePlatforms": [], "excludePlatforms": [], - "allowUnsafeCode": false + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [] } \ No newline at end of file diff --git a/Assets/VRM/DepthFirstScheduler.meta b/Assets/VRM/DepthFirstScheduler.meta deleted file mode 100644 index 188bdd0ab..000000000 --- a/Assets/VRM/DepthFirstScheduler.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: e236dfbc6df5ab5469d6d6d2332442de -folderAsset: yes -timeCreated: 1545999482 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/DepthFirstScheduler/DepthFirstScheduler.asmdef b/Assets/VRM/DepthFirstScheduler/DepthFirstScheduler.asmdef deleted file mode 100644 index d73eebc43..000000000 --- a/Assets/VRM/DepthFirstScheduler/DepthFirstScheduler.asmdef +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "DepthFirstScheduler" -} diff --git a/Assets/VRM/DepthFirstScheduler/Editor.meta b/Assets/VRM/DepthFirstScheduler/Editor.meta deleted file mode 100644 index d8c297a96..000000000 --- a/Assets/VRM/DepthFirstScheduler/Editor.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: cc0ab91a2011fcf4d925dd94bccdb243 -folderAsset: yes -timeCreated: 1540294739 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/DepthFirstScheduler/Editor/Tests/DepthFirstScheduler.Editor.Tests.asmdef b/Assets/VRM/DepthFirstScheduler/Editor/Tests/DepthFirstScheduler.Editor.Tests.asmdef deleted file mode 100644 index c0a902ad7..000000000 --- a/Assets/VRM/DepthFirstScheduler/Editor/Tests/DepthFirstScheduler.Editor.Tests.asmdef +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "DepthFirstScheduler.Editor.Tests", - "references": [ - "VRM", - "DepthFirstScheduler" - ], - "optionalUnityReferences": [ - "TestAssemblies" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false -} \ No newline at end of file diff --git a/Assets/VRM/DepthFirstScheduler/LICENSE b/Assets/VRM/DepthFirstScheduler/LICENSE deleted file mode 100644 index 3299d454f..000000000 --- a/Assets/VRM/DepthFirstScheduler/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 ousttrue - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Assets/VRM/DepthFirstScheduler/LICENSE.meta b/Assets/VRM/DepthFirstScheduler/LICENSE.meta deleted file mode 100644 index 2ea0914dd..000000000 --- a/Assets/VRM/DepthFirstScheduler/LICENSE.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b673d33707cbc5446870804437f3cbea -timeCreated: 1535290899 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/Editor.meta b/Assets/VRM/Editor.meta new file mode 100644 index 000000000..99f039eac --- /dev/null +++ b/Assets/VRM/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e16fa2d1e69251f4894daa1df758f033 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Editor/BlendShape.meta b/Assets/VRM/Editor/BlendShape.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape.meta rename to Assets/VRM/Editor/BlendShape.meta diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeAvatarEditor.cs b/Assets/VRM/Editor/BlendShape/BlendShapeAvatarEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeAvatarEditor.cs rename to Assets/VRM/Editor/BlendShape/BlendShapeAvatarEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeAvatarEditor.cs.meta b/Assets/VRM/Editor/BlendShape/BlendShapeAvatarEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeAvatarEditor.cs.meta rename to Assets/VRM/Editor/BlendShape/BlendShapeAvatarEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipDrawer.cs b/Assets/VRM/Editor/BlendShape/BlendShapeClipDrawer.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipDrawer.cs rename to Assets/VRM/Editor/BlendShape/BlendShapeClipDrawer.cs diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipDrawer.cs.meta b/Assets/VRM/Editor/BlendShape/BlendShapeClipDrawer.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipDrawer.cs.meta rename to Assets/VRM/Editor/BlendShape/BlendShapeClipDrawer.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipEditor.cs b/Assets/VRM/Editor/BlendShape/BlendShapeClipEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipEditor.cs rename to Assets/VRM/Editor/BlendShape/BlendShapeClipEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipEditor.cs.meta b/Assets/VRM/Editor/BlendShape/BlendShapeClipEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipEditor.cs.meta rename to Assets/VRM/Editor/BlendShape/BlendShapeClipEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipEditorHelper.cs b/Assets/VRM/Editor/BlendShape/BlendShapeClipEditorHelper.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipEditorHelper.cs rename to Assets/VRM/Editor/BlendShape/BlendShapeClipEditorHelper.cs diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipEditorHelper.cs.meta b/Assets/VRM/Editor/BlendShape/BlendShapeClipEditorHelper.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipEditorHelper.cs.meta rename to Assets/VRM/Editor/BlendShape/BlendShapeClipEditorHelper.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipSelector.cs b/Assets/VRM/Editor/BlendShape/BlendShapeClipSelector.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipSelector.cs rename to Assets/VRM/Editor/BlendShape/BlendShapeClipSelector.cs diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipSelector.cs.meta b/Assets/VRM/Editor/BlendShape/BlendShapeClipSelector.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/BlendShapeClipSelector.cs.meta rename to Assets/VRM/Editor/BlendShape/BlendShapeClipSelector.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/PreviewEditor.cs b/Assets/VRM/Editor/BlendShape/PreviewEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/PreviewEditor.cs rename to Assets/VRM/Editor/BlendShape/PreviewEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/PreviewEditor.cs.meta b/Assets/VRM/Editor/BlendShape/PreviewEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/PreviewEditor.cs.meta rename to Assets/VRM/Editor/BlendShape/PreviewEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/PreviewFaceRenderer.cs b/Assets/VRM/Editor/BlendShape/PreviewFaceRenderer.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/PreviewFaceRenderer.cs rename to Assets/VRM/Editor/BlendShape/PreviewFaceRenderer.cs diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/PreviewFaceRenderer.cs.meta b/Assets/VRM/Editor/BlendShape/PreviewFaceRenderer.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/PreviewFaceRenderer.cs.meta rename to Assets/VRM/Editor/BlendShape/PreviewFaceRenderer.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/SerializedBlendShapeClipEditor.cs b/Assets/VRM/Editor/BlendShape/SerializedBlendShapeClipEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/SerializedBlendShapeClipEditor.cs rename to Assets/VRM/Editor/BlendShape/SerializedBlendShapeClipEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/SerializedBlendShapeClipEditor.cs.meta b/Assets/VRM/Editor/BlendShape/SerializedBlendShapeClipEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/SerializedBlendShapeClipEditor.cs.meta rename to Assets/VRM/Editor/BlendShape/SerializedBlendShapeClipEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/VRMBlendShapeProxyEditor.cs b/Assets/VRM/Editor/BlendShape/VRMBlendShapeProxyEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/VRMBlendShapeProxyEditor.cs rename to Assets/VRM/Editor/BlendShape/VRMBlendShapeProxyEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/VRMBlendShapeProxyEditor.cs.meta b/Assets/VRM/Editor/BlendShape/VRMBlendShapeProxyEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/VRMBlendShapeProxyEditor.cs.meta rename to Assets/VRM/Editor/BlendShape/VRMBlendShapeProxyEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/VRMBlendShapeProxyValidator.cs b/Assets/VRM/Editor/BlendShape/VRMBlendShapeProxyValidator.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/VRMBlendShapeProxyValidator.cs rename to Assets/VRM/Editor/BlendShape/VRMBlendShapeProxyValidator.cs diff --git a/Assets/VRM/UniVRM/Editor/BlendShape/VRMBlendShapeProxyValidator.cs.meta b/Assets/VRM/Editor/BlendShape/VRMBlendShapeProxyValidator.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/BlendShape/VRMBlendShapeProxyValidator.cs.meta rename to Assets/VRM/Editor/BlendShape/VRMBlendShapeProxyValidator.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/FirstPerson.meta b/Assets/VRM/Editor/FirstPerson.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/FirstPerson.meta rename to Assets/VRM/Editor/FirstPerson.meta diff --git a/Assets/VRM/UniVRM/Editor/FirstPerson/RendererFirstPersonFlagsDrawer.cs b/Assets/VRM/Editor/FirstPerson/RendererFirstPersonFlagsDrawer.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/FirstPerson/RendererFirstPersonFlagsDrawer.cs rename to Assets/VRM/Editor/FirstPerson/RendererFirstPersonFlagsDrawer.cs diff --git a/Assets/VRM/UniVRM/Editor/FirstPerson/RendererFirstPersonFlagsDrawer.cs.meta b/Assets/VRM/Editor/FirstPerson/RendererFirstPersonFlagsDrawer.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/FirstPerson/RendererFirstPersonFlagsDrawer.cs.meta rename to Assets/VRM/Editor/FirstPerson/RendererFirstPersonFlagsDrawer.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/FirstPerson/VRMFirstPersonEditor.cs b/Assets/VRM/Editor/FirstPerson/VRMFirstPersonEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/FirstPerson/VRMFirstPersonEditor.cs rename to Assets/VRM/Editor/FirstPerson/VRMFirstPersonEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/FirstPerson/VRMFirstPersonEditor.cs.meta b/Assets/VRM/Editor/FirstPerson/VRMFirstPersonEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/FirstPerson/VRMFirstPersonEditor.cs.meta rename to Assets/VRM/Editor/FirstPerson/VRMFirstPersonEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/FirstPerson/VRMFirstPersonValidator.cs b/Assets/VRM/Editor/FirstPerson/VRMFirstPersonValidator.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/FirstPerson/VRMFirstPersonValidator.cs rename to Assets/VRM/Editor/FirstPerson/VRMFirstPersonValidator.cs diff --git a/Assets/VRM/UniVRM/Editor/FirstPerson/VRMFirstPersonValidator.cs.meta b/Assets/VRM/Editor/FirstPerson/VRMFirstPersonValidator.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/FirstPerson/VRMFirstPersonValidator.cs.meta rename to Assets/VRM/Editor/FirstPerson/VRMFirstPersonValidator.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format.meta b/Assets/VRM/Editor/Format.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format.meta rename to Assets/VRM/Editor/Format.meta diff --git a/Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs b/Assets/VRM/Editor/Format/HumanoidValidator.cs similarity index 98% rename from Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs rename to Assets/VRM/Editor/Format/HumanoidValidator.cs index cc89267b5..c67649d78 100644 --- a/Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs +++ b/Assets/VRM/Editor/Format/HumanoidValidator.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; using System.Linq; +using MeshUtility; using MeshUtility.M17N; using UnityEngine; -namespace MeshUtility.Validators +namespace VRM { public static class HumanoidValidator { @@ -73,7 +74,7 @@ namespace MeshUtility.Validators return Vector3.Cross(lr, Vector3.up); } - public static IReadOnlyList MeshInformations; + public static IReadOnlyList MeshInformations; public static bool EnableFreeze; public static IEnumerable Validate(GameObject ExportRoot) diff --git a/Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs.meta b/Assets/VRM/Editor/Format/HumanoidValidator.cs.meta similarity index 83% rename from Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs.meta rename to Assets/VRM/Editor/Format/HumanoidValidator.cs.meta index f50f4461a..6b9849e29 100644 --- a/Assets/MeshUtility/Editor/ExportDialog/Valildators/HumanoidValidator.cs.meta +++ b/Assets/VRM/Editor/Format/HumanoidValidator.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9013f2150f3c6d943a6f6b6394f7a1ff +guid: d6dd0ca0faa486f4a8aa3bb895e2c697 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/VRM/UniVRM/Editor/Format/RecordDisposer.cs b/Assets/VRM/Editor/Format/RecordDisposer.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/RecordDisposer.cs rename to Assets/VRM/Editor/Format/RecordDisposer.cs diff --git a/Assets/VRM/UniVRM/Editor/Format/RecordDisposer.cs.meta b/Assets/VRM/Editor/Format/RecordDisposer.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/RecordDisposer.cs.meta rename to Assets/VRM/Editor/Format/RecordDisposer.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMAOTMenu.cs b/Assets/VRM/Editor/Format/VRMAOTMenu.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMAOTMenu.cs rename to Assets/VRM/Editor/Format/VRMAOTMenu.cs diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMAOTMenu.cs.meta b/Assets/VRM/Editor/Format/VRMAOTMenu.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMAOTMenu.cs.meta rename to Assets/VRM/Editor/Format/VRMAOTMenu.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMAssetWriter.cs b/Assets/VRM/Editor/Format/VRMAssetWriter.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMAssetWriter.cs rename to Assets/VRM/Editor/Format/VRMAssetWriter.cs diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMAssetWriter.cs.meta b/Assets/VRM/Editor/Format/VRMAssetWriter.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMAssetWriter.cs.meta rename to Assets/VRM/Editor/Format/VRMAssetWriter.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/Editor/Format/VRMEditorExporter.cs similarity index 98% rename from Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs rename to Assets/VRM/Editor/Format/VRMEditorExporter.cs index 03d86ae3f..96e236ab0 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs +++ b/Assets/VRM/Editor/Format/VRMEditorExporter.cs @@ -16,7 +16,7 @@ namespace VRM /// /// 出力先 /// エクスポート設定 - public static void Export(string path, GameObject exportRoot, VRMMetaObject meta, VRMExportSettings settings, IReadOnlyList info) + public static void Export(string path, GameObject exportRoot, VRMMetaObject meta, VRMExportSettings settings, IReadOnlyList info) { List destroy = new List(); try @@ -137,7 +137,7 @@ namespace VRM /// /// 作業が終わったらDestoryするべき一時オブジェクト static void Export(string path, GameObject exportRoot, VRMMetaObject meta, - VRMExportSettings settings, IReadOnlyList info, + VRMExportSettings settings, IReadOnlyList info, List destroy) { var target = exportRoot; diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs.meta b/Assets/VRM/Editor/Format/VRMEditorExporter.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMEditorExporter.cs.meta rename to Assets/VRM/Editor/Format/VRMEditorExporter.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshes.cs b/Assets/VRM/Editor/Format/VRMExportMeshes.cs similarity index 91% rename from Assets/VRM/UniVRM/Editor/Format/VRMExportMeshes.cs rename to Assets/VRM/Editor/Format/VRMExportMeshes.cs index 3225590e9..58e7e253d 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshes.cs +++ b/Assets/VRM/Editor/Format/VRMExportMeshes.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using MeshUtility; +using UniGLTF; using UnityEngine; namespace VRM @@ -56,14 +57,14 @@ namespace VRM return false; } - public List Meshes = new List(); + public List Meshes = new List(); public int ExpectedExportByteSize => Meshes.Where(x => x.IsRendererActive).Sum(x => x.ExportByteSize); List m_validations = new List(); public IEnumerable Validations => m_validations; - public static void CalcMeshSize(ref MeshUtility.MeshExportInfo info, + public static void CalcMeshSize(ref MeshExportInfo info, string relativePath, VRMExportSettings settings, IReadOnlyList clips) { var sb = new StringBuilder(); @@ -133,11 +134,11 @@ namespace VRM sb.Append($") x {info.Mesh.vertexCount}"); switch (info.VertexColor) { - case MeshUtility.MeshExportInfo.VertexColorState.ExistsAndIsUsed: - case MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed: // エクスポートする + case MeshExportInfo.VertexColorState.ExistsAndIsUsed: + case MeshExportInfo.VertexColorState.ExistsAndMixed: // エクスポートする sb.Insert(0, "[use vcolor]"); break; - case MeshUtility.MeshExportInfo.VertexColorState.ExistsButNotUsed: + case MeshExportInfo.VertexColorState.ExistsButNotUsed: sb.Insert(0, "[remove vcolor]"); break; } @@ -151,7 +152,7 @@ namespace VRM info.Summary = sb.ToString(); } - bool TryGetMeshInfo(GameObject root, Renderer renderer, IReadOnlyList clips, VRMExportSettings settings, out MeshUtility.MeshExportInfo info) + bool TryGetMeshInfo(GameObject root, Renderer renderer, IReadOnlyList clips, VRMExportSettings settings, out MeshExportInfo info) { info = default; if (root == null) @@ -187,7 +188,7 @@ namespace VRM return false; } - info.VertexColor = MeshUtility.MeshExportInfo.DetectVertexColor(info.Mesh, info.Renderer.sharedMaterials); + info.VertexColor = MeshExportInfo.DetectVertexColor(info.Mesh, info.Renderer.sharedMaterials); var relativePath = UniGLTF.UnityExtensions.RelativePathFrom(renderer.transform, root.transform); CalcMeshSize(ref info, relativePath, settings, clips); @@ -217,7 +218,7 @@ namespace VRM foreach (var renderer in ExportRoot.GetComponentsInChildren(true)) { - if (TryGetMeshInfo(ExportRoot, renderer, clips, settings, out MeshUtility.MeshExportInfo info)) + if (TryGetMeshInfo(ExportRoot, renderer, clips, settings, out MeshExportInfo info)) { Meshes.Add(info); } diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshes.cs.meta b/Assets/VRM/Editor/Format/VRMExportMeshes.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMExportMeshes.cs.meta rename to Assets/VRM/Editor/Format/VRMExportMeshes.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshesEditor.cs b/Assets/VRM/Editor/Format/VRMExportMeshesEditor.cs similarity index 95% rename from Assets/VRM/UniVRM/Editor/Format/VRMExportMeshesEditor.cs rename to Assets/VRM/Editor/Format/VRMExportMeshesEditor.cs index b1f1383bd..e48bbfd51 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshesEditor.cs +++ b/Assets/VRM/Editor/Format/VRMExportMeshesEditor.cs @@ -32,7 +32,7 @@ namespace VRM ); } - void DrawElement(int i, MeshUtility.MeshExportInfo info) + void DrawElement(int i, UniGLTF.MeshExportInfo info) { var r = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(EditorGUIUtility.singleLineHeight * 3 + 20)); var col0 = 32; diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportMeshesEditor.cs.meta b/Assets/VRM/Editor/Format/VRMExportMeshesEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMExportMeshesEditor.cs.meta rename to Assets/VRM/Editor/Format/VRMExportMeshesEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs b/Assets/VRM/Editor/Format/VRMExportSettings.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs rename to Assets/VRM/Editor/Format/VRMExportSettings.cs diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs.meta b/Assets/VRM/Editor/Format/VRMExportSettings.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMExportSettings.cs.meta rename to Assets/VRM/Editor/Format/VRMExportSettings.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs b/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs rename to Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs.meta b/Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMExportSettingsEditor.cs.meta rename to Assets/VRM/Editor/Format/VRMExportSettingsEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExporterVaildator.cs b/Assets/VRM/Editor/Format/VRMExporterVaildator.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMExporterVaildator.cs rename to Assets/VRM/Editor/Format/VRMExporterVaildator.cs diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExporterVaildator.cs.meta b/Assets/VRM/Editor/Format/VRMExporterVaildator.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMExporterVaildator.cs.meta rename to Assets/VRM/Editor/Format/VRMExporterVaildator.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs b/Assets/VRM/Editor/Format/VRMExporterWizard.cs similarity index 97% rename from Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs rename to Assets/VRM/Editor/Format/VRMExporterWizard.cs index 5609279f8..d422fe12f 100644 --- a/Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs +++ b/Assets/VRM/Editor/Format/VRMExporterWizard.cs @@ -95,7 +95,7 @@ namespace VRM // default setting m_settings.PoseFreeze = - MeshUtility.Validators.HumanoidValidator.HasRotationOrScale(root) + HumanoidValidator.HasRotationOrScale(root) || m_meshes.Meshes.Any(x => x.ExportBlendShapeCount > 0 && !x.HasSkinning) ; } @@ -153,8 +153,8 @@ namespace VRM IEnumerable ValidatorFactory() { - MeshUtility.Validators.HumanoidValidator.MeshInformations = m_meshes.Meshes; - MeshUtility.Validators.HumanoidValidator.EnableFreeze = m_settings.PoseFreeze; + HumanoidValidator.MeshInformations = m_meshes.Meshes; + HumanoidValidator.EnableFreeze = m_settings.PoseFreeze; VRMExporterValidator.ReduceBlendshape = m_settings.ReduceBlendshape; yield return MeshUtility.Validators.HierarchyValidator.Validate; @@ -163,7 +163,7 @@ namespace VRM yield break; } - yield return MeshUtility.Validators.HumanoidValidator.Validate; + yield return HumanoidValidator.Validate; yield return VRMExporterValidator.Validate; yield return VRMSpringBoneValidator.Validate; @@ -269,7 +269,7 @@ namespace VRM { switch (meshInfo.VertexColor) { - case MeshUtility.MeshExportInfo.VertexColorState.ExistsAndMixed: + case UniGLTF.MeshExportInfo.VertexColorState.ExistsAndMixed: MeshUtility.Validation.Warning($"{meshInfo.Renderer}: Both vcolor.multiply and not multiply unlit materials exist").DrawGUI(); break; } diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs.meta b/Assets/VRM/Editor/Format/VRMExporterWizard.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMExporterWizard.cs.meta rename to Assets/VRM/Editor/Format/VRMExporterWizard.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMHumanoidNormalizerMenu.cs b/Assets/VRM/Editor/Format/VRMHumanoidNormalizerMenu.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMHumanoidNormalizerMenu.cs rename to Assets/VRM/Editor/Format/VRMHumanoidNormalizerMenu.cs diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMHumanoidNormalizerMenu.cs.meta b/Assets/VRM/Editor/Format/VRMHumanoidNormalizerMenu.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMHumanoidNormalizerMenu.cs.meta rename to Assets/VRM/Editor/Format/VRMHumanoidNormalizerMenu.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMImporterMenu.cs b/Assets/VRM/Editor/Format/VRMImporterMenu.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMImporterMenu.cs rename to Assets/VRM/Editor/Format/VRMImporterMenu.cs diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMImporterMenu.cs.meta b/Assets/VRM/Editor/Format/VRMImporterMenu.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMImporterMenu.cs.meta rename to Assets/VRM/Editor/Format/VRMImporterMenu.cs.meta diff --git a/Assets/VRM/Editor/Format/VRMVersionMenu.cs b/Assets/VRM/Editor/Format/VRMVersionMenu.cs new file mode 100644 index 000000000..d0cb3efd3 --- /dev/null +++ b/Assets/VRM/Editor/Format/VRMVersionMenu.cs @@ -0,0 +1,251 @@ +using System.IO; +using System.Text; +using UnityEditor; +using UnityEngine; +using UniGLTF; + +namespace VRM +{ + public class VRMVersionMenu : EditorWindow + { + /// + /// UNIGLTF + /// + static string UniGltfVersionPath = "Assets/UniGLTF/UniGLTF/Scripts/UniGLTFVersion.cs"; + + const string UniGltfVersionTemplate = @" +namespace UniGLTF +{{ + public static partial class UniGLTFVersion + {{ + public const int MAJOR = {0}; + public const int MINOR = {1}; + public const int PATCH = {2}; + public const string VERSION = ""{0}.{1}.{2}""; + }} +}} +"; + + /// + /// VRM + /// + const string VrmVersionPath = "Assets/VRM/UniVRM/Scripts/Format/VRMVersion.cs"; + const string VrmVersionTemplate = @" +namespace VRM +{{ + public static partial class VRMVersion + {{ + public const int MAJOR = {0}; + public const int MINOR = {1}; + public const int PATCH = {2}; + public const string VERSION = ""{0}.{1}.{2}""; + }} +}} +"; + + struct UpmPackage + { + public readonly string Name; + public readonly string Path; + public readonly string Template; + + public UpmPackage(string name, string path, string template) + { + Name = name; + Path = path; + Template = template; + } + } + + UpmPackage[] Packages = new UpmPackage[] + { + new UpmPackage("VRMShaders", "Assets/VRMShaders/package.json", +@"{{ + ""name"": ""com.vrmc.vrmshaders"", + ""version"": ""{1}"", + ""displayName"": ""VRM Shaders"", + ""description"": ""VRM Shaders"", + ""unity"": ""2018.4"", + ""keywords"": [ + ""vrm"", + ""shader"" + ], + ""author"": {{ + ""name"": ""VRM Consortium"" + }} +}} +"), + new UpmPackage("MeshUtility", "Assets/MeshUtility/package.json", +@"{{ + ""name"": ""com.vrmc.meshutility"", + ""version"": ""{1}"", + ""displayName"": ""MeshUtility"", + ""unity"": ""2018.4"", + ""description"": ""MeshUtility is a package for mesh separation, etc. \n\nCheck out the latest information here: "", + ""keywords"": [ + ""mesh"" + ], + ""author"": {{ + ""name"": ""VRM Consortium"" + }} +}} +"), + new UpmPackage("VRM", "Assets/VRM/package.json", +@"{{ + ""name"": ""com.vrmc.univrm"", + ""version"": ""{1}"", + ""displayName"": ""VRM"", + ""description"": ""VRM importer"", + ""unity"": ""2018.4"", + ""keywords"": [ + ""vrm"", + ""importer"", + ""avatar"", + ""vr"" + ], + ""author"": {{ + ""name"": ""VRM Consortium"" + }}, + ""dependencies"": {{ + ""com.vrmc.vrmshaders"": ""{1}"", + ""com.vrmc.meshutility"": ""{1}"", + ""com.vrmc.unigltf"": ""{0}"" + }} +}} +"), + }; + + UpmPackage UniGLTFPackage = new UpmPackage("UniGLTF", "Assets/UniGLTF/package.json", +@"{{ + ""name"": ""com.vrmc.unigltf"", + ""version"": ""{0}"", + ""displayName"": ""UniGLTF"", + ""description"": ""GLTF importer and exporter"", + ""unity"": ""2018.4"", + ""keywords"": [ + ""gltf"" + ], + ""author"": {{ + ""name"": ""VRM Consortium"" + }}, + ""dependencies"": {{ + ""com.vrmc.vrmshaders"": ""{1}"" + }} +}}"); + + [SerializeField] + string m_vrmVersion; + + [SerializeField] + string m_uniGltfVersion; + + static bool TryGetVersion(string src, out (int, int, int) version) + { + if (string.IsNullOrEmpty(src)) + { + version = default; + return false; + } + + var splitted = src.Split('.'); + if (splitted.Length != 3) + { + version = default; + return false; + } + + version = ( + int.Parse(splitted[0]), + int.Parse(splitted[1]), + int.Parse(splitted[2]) + ); + return true; + } + + /// + /// バージョン管理ダイアログ + /// + void OnGUI() + { + GUILayout.Label("VRM"); + GUILayout.Label($"Current version: {VRMVersion.VERSION}"); + m_vrmVersion = EditorGUILayout.TextField("Major.Minor.Patch", m_vrmVersion); + GUILayout.Space(30); + + GUILayout.Label("UniGLTF"); + GUILayout.Label($"Current version: {UniGLTFVersion.VERSION}"); + m_uniGltfVersion = EditorGUILayout.TextField("Major.Minor.Patch", m_uniGltfVersion); + GUILayout.Space(30); + + if (GUILayout.Button("Apply")) + { + if (TryGetVersion(m_vrmVersion, out (int, int, int) vrmVersion)) + { + if (TryGetVersion(m_uniGltfVersion, out (int, int, int) uniGltfVersion)) + { + UpdateVrmVersion(uniGltfVersion, vrmVersion); + UpdateUniGLTFVersion(uniGltfVersion, vrmVersion); + AssetDatabase.Refresh(); + Debug.Log($"{uniGltfVersion}, {vrmVersion}"); + } + else + { + Debug.LogWarning($"InvalidFormat: {m_uniGltfVersion}"); + } + } + else + { + Debug.LogWarning($"InvalidFormat: {m_vrmVersion}"); + } + } + + if (GUILayout.Button("Close")) + { + Close(); + } + } + + void UpdateUniGLTFVersion((int, int, int) uniGltf, (int, int, int) vrm) + { + var utf8 = new UTF8Encoding(false); + File.WriteAllText(UniGltfVersionPath, string.Format(UniGltfVersionTemplate, + uniGltf.Item1, + uniGltf.Item2, + uniGltf.Item3), utf8); + + File.WriteAllText(UniGLTFPackage.Path, string.Format(UniGLTFPackage.Template, + $"{uniGltf.Item1}.{uniGltf.Item2}.{uniGltf.Item3}", + $"{vrm.Item1}.{vrm.Item2}.{vrm.Item3}" + ), utf8); + } + + void UpdateVrmVersion((int, int, int) uniGltf, (int, int, int) vrm) + { + // generate + var utf8 = new UTF8Encoding(false); + File.WriteAllText(VrmVersionPath, string.Format(VrmVersionTemplate, + vrm.Item1, + vrm.Item2, + vrm.Item3), utf8); + // UPM + foreach (var upm in Packages) + { + File.WriteAllText(upm.Path, string.Format(upm.Template, + $"{uniGltf.Item1}.{uniGltf.Item2}.{uniGltf.Item3}", + $"{vrm.Item1}.{vrm.Item2}.{vrm.Item3}" + ), utf8); + } + } + +#if VRM_DEVELOP + [MenuItem(VRMVersion.MENU + "/VersionDialog")] +#endif + static void ShowVersionDialog() + { + var window = ScriptableObject.CreateInstance(); + window.m_vrmVersion = VRMVersion.VERSION; + window.m_uniGltfVersion = UniGLTFVersion.VERSION; + window.ShowUtility(); + } + } +} diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMVersionMenu.cs.meta b/Assets/VRM/Editor/Format/VRMVersionMenu.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/VRMVersionMenu.cs.meta rename to Assets/VRM/Editor/Format/VRMVersionMenu.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs b/Assets/VRM/Editor/Format/vrmAssetPostprocessor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs rename to Assets/VRM/Editor/Format/vrmAssetPostprocessor.cs diff --git a/Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs.meta b/Assets/VRM/Editor/Format/vrmAssetPostprocessor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Format/vrmAssetPostprocessor.cs.meta rename to Assets/VRM/Editor/Format/vrmAssetPostprocessor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/LookAt.meta b/Assets/VRM/Editor/LookAt.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/LookAt.meta rename to Assets/VRM/Editor/LookAt.meta diff --git a/Assets/VRM/UniVRM/Editor/LookAt/VRMLookAtHeadEditor.cs b/Assets/VRM/Editor/LookAt/VRMLookAtHeadEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/LookAt/VRMLookAtHeadEditor.cs rename to Assets/VRM/Editor/LookAt/VRMLookAtHeadEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/LookAt/VRMLookAtHeadEditor.cs.meta b/Assets/VRM/Editor/LookAt/VRMLookAtHeadEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/LookAt/VRMLookAtHeadEditor.cs.meta rename to Assets/VRM/Editor/LookAt/VRMLookAtHeadEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Meta.meta b/Assets/VRM/Editor/Meta.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Meta.meta rename to Assets/VRM/Editor/Meta.meta diff --git a/Assets/VRM/UniVRM/Editor/Meta/VRMMetaEditor.cs b/Assets/VRM/Editor/Meta/VRMMetaEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Meta/VRMMetaEditor.cs rename to Assets/VRM/Editor/Meta/VRMMetaEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/Meta/VRMMetaEditor.cs.meta b/Assets/VRM/Editor/Meta/VRMMetaEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Meta/VRMMetaEditor.cs.meta rename to Assets/VRM/Editor/Meta/VRMMetaEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Meta/VRMMetaObjectEditor.cs b/Assets/VRM/Editor/Meta/VRMMetaObjectEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Meta/VRMMetaObjectEditor.cs rename to Assets/VRM/Editor/Meta/VRMMetaObjectEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/Meta/VRMMetaObjectEditor.cs.meta b/Assets/VRM/Editor/Meta/VRMMetaObjectEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Meta/VRMMetaObjectEditor.cs.meta rename to Assets/VRM/Editor/Meta/VRMMetaObjectEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/SkinnedMeshUtility.meta b/Assets/VRM/Editor/SkinnedMeshUtility.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/SkinnedMeshUtility.meta rename to Assets/VRM/Editor/SkinnedMeshUtility.meta diff --git a/Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs rename to Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs.meta b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs.meta rename to Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs rename to Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs diff --git a/Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs.meta b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs.meta rename to Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/SkinnedMeshUtility.cs b/Assets/VRM/Editor/SkinnedMeshUtility/SkinnedMeshUtility.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/SkinnedMeshUtility.cs rename to Assets/VRM/Editor/SkinnedMeshUtility/SkinnedMeshUtility.cs diff --git a/Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/SkinnedMeshUtility.cs.meta b/Assets/VRM/Editor/SkinnedMeshUtility/SkinnedMeshUtility.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/SkinnedMeshUtility.cs.meta rename to Assets/VRM/Editor/SkinnedMeshUtility/SkinnedMeshUtility.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/SpringBone.meta b/Assets/VRM/Editor/SpringBone.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/SpringBone.meta rename to Assets/VRM/Editor/SpringBone.meta diff --git a/Assets/VRM/UniVRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs b/Assets/VRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs rename to Assets/VRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs diff --git a/Assets/VRM/UniVRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs.meta b/Assets/VRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs.meta rename to Assets/VRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/SpringBone/VRMSpringBoneValidator.cs b/Assets/VRM/Editor/SpringBone/VRMSpringBoneValidator.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/SpringBone/VRMSpringBoneValidator.cs rename to Assets/VRM/Editor/SpringBone/VRMSpringBoneValidator.cs diff --git a/Assets/VRM/UniVRM/Editor/SpringBone/VRMSpringBoneValidator.cs.meta b/Assets/VRM/Editor/SpringBone/VRMSpringBoneValidator.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/SpringBone/VRMSpringBoneValidator.cs.meta rename to Assets/VRM/Editor/SpringBone/VRMSpringBoneValidator.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/UniVRM.Editor.asmdef b/Assets/VRM/Editor/VRM.Editor.asmdef similarity index 86% rename from Assets/VRM/UniVRM/Editor/UniVRM.Editor.asmdef rename to Assets/VRM/Editor/VRM.Editor.asmdef index 41389d70d..a56ec1e28 100644 --- a/Assets/VRM/UniVRM/Editor/UniVRM.Editor.asmdef +++ b/Assets/VRM/Editor/VRM.Editor.asmdef @@ -2,11 +2,12 @@ "name": "UniVRM.Editor", "references": [ "VRM", - "UniJSON", "UniHumanoid", "MeshUtility", "MeshUtility.Editor", - "UniUnlit" + "UniUnlit", + "UniGLTF", + "UniGLTF.Editor" ], "optionalUnityReferences": [], "includePlatforms": [ diff --git a/Assets/VRM/UniVRM/Editor/UniVRM.Editor.asmdef.meta b/Assets/VRM/Editor/VRM.Editor.asmdef.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/UniVRM.Editor.asmdef.meta rename to Assets/VRM/Editor/VRM.Editor.asmdef.meta diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/DeserializerGenerator.cs b/Assets/VRM/Editor/VRMDeserializerGenerator.cs similarity index 76% rename from Assets/VRM/UniGLTF/Editor/Serialization/DeserializerGenerator.cs rename to Assets/VRM/Editor/VRMDeserializerGenerator.cs index c6bb8bbae..4e01875cd 100644 --- a/Assets/VRM/UniGLTF/Editor/Serialization/DeserializerGenerator.cs +++ b/Assets/VRM/Editor/VRMDeserializerGenerator.cs @@ -4,7 +4,7 @@ using System.Text; using UnityEditor; using UnityEngine; -namespace UniGLTF +namespace VRM { public static class DeserializerGenerator { @@ -15,17 +15,17 @@ namespace UniGLTF get { return Path.Combine(UnityEngine.Application.dataPath, - "VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs"); + "VRM/UniVRM/Scripts/Format/VRMDeserializer.g.cs"); } } /// /// AOT向けにデシリアライザを生成する /// - [MenuItem(VRM.VRMVersion.MENU + "/Generate Deserializer")] + [MenuItem(VRM.VRMVersion.MENU + "/VRM: Generate Deserializer")] static void GenerateSerializer() { - var info = new ObjectSerialization(typeof(glTF), "gltf"); + var info = new UniGLTF.ObjectSerialization(typeof(glTF_VRM_extensions), "vrm", "_Deserialize"); Debug.Log(info); using (var s = File.Open(OutPath, FileMode.Create)) @@ -39,9 +39,9 @@ using System.Collections.Generic; using VRM; using UnityEngine; -namespace UniGLTF { +namespace VRM { -public static class GltfDeserializer +public static class VrmDeserializer { "); @@ -50,8 +50,8 @@ public static class GltfDeserializer // footer w.Write(@" -} // GltfDeserializer -} // UniGLTF +} // VrmfDeserializer +} // VRM "); Debug.LogFormat("write: {0}", OutPath); diff --git a/Assets/VRM/Editor/VRMDeserializerGenerator.cs.meta b/Assets/VRM/Editor/VRMDeserializerGenerator.cs.meta new file mode 100644 index 000000000..a04be1f2d --- /dev/null +++ b/Assets/VRM/Editor/VRMDeserializerGenerator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fccecb79adf40a948b2c218b4e7703b3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniVRM/DevOnly/Editor/VRMExportUnityPackage.cs b/Assets/VRM/Editor/VRMExportUnityPackage.cs similarity index 100% rename from Assets/VRM/UniVRM/DevOnly/Editor/VRMExportUnityPackage.cs rename to Assets/VRM/Editor/VRMExportUnityPackage.cs diff --git a/Assets/VRM/UniVRM/DevOnly/Editor/VRMExportUnityPackage.cs.meta b/Assets/VRM/Editor/VRMExportUnityPackage.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/DevOnly/Editor/VRMExportUnityPackage.cs.meta rename to Assets/VRM/Editor/VRMExportUnityPackage.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/VRMMonoBehaviourComparator.cs b/Assets/VRM/Editor/VRMMonoBehaviourComparator.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/VRMMonoBehaviourComparator.cs rename to Assets/VRM/Editor/VRMMonoBehaviourComparator.cs diff --git a/Assets/VRM/UniVRM/Editor/VRMMonoBehaviourComparator.cs.meta b/Assets/VRM/Editor/VRMMonoBehaviourComparator.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/VRMMonoBehaviourComparator.cs.meta rename to Assets/VRM/Editor/VRMMonoBehaviourComparator.cs.meta diff --git a/Assets/VRM/Editor/VRMSerializerGenerator.cs b/Assets/VRM/Editor/VRMSerializerGenerator.cs new file mode 100644 index 000000000..75be56bc4 --- /dev/null +++ b/Assets/VRM/Editor/VRMSerializerGenerator.cs @@ -0,0 +1,62 @@ +using System.IO; +using System.Reflection; +using System.Text; +using UniGLTF; +using UnityEditor; +using UnityEngine; + +namespace VRM +{ + public static class VRMSerializerGenerator + { + const BindingFlags FIELD_FLAGS = BindingFlags.Instance | BindingFlags.Public; + + static string OutPath + { + get + { + return Path.Combine(UnityEngine.Application.dataPath, + "VRM/UniVRM/Scripts/Format/VRMSerializer.g.cs"); + } + } + + const string Begin = @" +using System; +using System.Collections.Generic; +using UniJSON; +using UnityEngine; +using VRM; + +namespace VRM { + + static public class VRMSerializer + { + +"; + const string End = @" + } // class +} // namespace +"; + + /// + /// AOT向けにシリアライザを生成する + /// + [MenuItem(VRM.VRMVersion.MENU + "/VRM: Generate Serializer")] + static void GenerateSerializer() + { + var info = new ObjectSerialization(typeof(glTF_VRM_extensions), "vrm", "Serialize_"); + Debug.Log(info); + + using (var s = File.Open(OutPath, FileMode.Create)) + using (var w = new StreamWriter(s, new UTF8Encoding(false))) + { + w.Write(Begin); + info.GenerateSerializer(w, "Serialize"); + w.Write(End); + } + + Debug.LogFormat("write: {0}", OutPath); + UnityPath.FromFullpath(OutPath).ImportAsset(); + } + } +} diff --git a/Assets/VRM/Editor/VRMSerializerGenerator.cs.meta b/Assets/VRM/Editor/VRMSerializerGenerator.cs.meta new file mode 100644 index 000000000..5bc512e7f --- /dev/null +++ b/Assets/VRM/Editor/VRMSerializerGenerator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ea35ccbf1dc9c654d9b27a2fc54b3f5a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Resources.meta b/Assets/VRM/Resources.meta similarity index 100% rename from Assets/VRM/UniVRM/Resources.meta rename to Assets/VRM/Resources.meta diff --git a/Assets/VRM/UniVRM/Resources/Shaders.meta b/Assets/VRM/Resources/Shaders.meta similarity index 100% rename from Assets/VRM/UniVRM/Resources/Shaders.meta rename to Assets/VRM/Resources/Shaders.meta diff --git a/Assets/VRM/UniVRM/Resources/Shaders/VRMShaders.shadervariants b/Assets/VRM/Resources/Shaders/VRMShaders.shadervariants similarity index 100% rename from Assets/VRM/UniVRM/Resources/Shaders/VRMShaders.shadervariants rename to Assets/VRM/Resources/Shaders/VRMShaders.shadervariants diff --git a/Assets/VRM/UniVRM/Resources/Shaders/VRMShaders.shadervariants.meta b/Assets/VRM/Resources/Shaders/VRMShaders.shadervariants.meta similarity index 100% rename from Assets/VRM/UniVRM/Resources/Shaders/VRMShaders.shadervariants.meta rename to Assets/VRM/Resources/Shaders/VRMShaders.shadervariants.meta diff --git a/Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitCutout.shader b/Assets/VRM/Resources/Shaders/VRMUnlitCutout.shader similarity index 100% rename from Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitCutout.shader rename to Assets/VRM/Resources/Shaders/VRMUnlitCutout.shader diff --git a/Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitCutout.shader.meta b/Assets/VRM/Resources/Shaders/VRMUnlitCutout.shader.meta similarity index 100% rename from Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitCutout.shader.meta rename to Assets/VRM/Resources/Shaders/VRMUnlitCutout.shader.meta diff --git a/Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTexture.shader b/Assets/VRM/Resources/Shaders/VRMUnlitTexture.shader similarity index 100% rename from Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTexture.shader rename to Assets/VRM/Resources/Shaders/VRMUnlitTexture.shader diff --git a/Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTexture.shader.meta b/Assets/VRM/Resources/Shaders/VRMUnlitTexture.shader.meta similarity index 100% rename from Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTexture.shader.meta rename to Assets/VRM/Resources/Shaders/VRMUnlitTexture.shader.meta diff --git a/Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTransparent.shader b/Assets/VRM/Resources/Shaders/VRMUnlitTransparent.shader similarity index 100% rename from Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTransparent.shader rename to Assets/VRM/Resources/Shaders/VRMUnlitTransparent.shader diff --git a/Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTransparent.shader.meta b/Assets/VRM/Resources/Shaders/VRMUnlitTransparent.shader.meta similarity index 100% rename from Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTransparent.shader.meta rename to Assets/VRM/Resources/Shaders/VRMUnlitTransparent.shader.meta diff --git a/Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTransparentZWrite.shader b/Assets/VRM/Resources/Shaders/VRMUnlitTransparentZWrite.shader similarity index 100% rename from Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTransparentZWrite.shader rename to Assets/VRM/Resources/Shaders/VRMUnlitTransparentZWrite.shader diff --git a/Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTransparentZWrite.shader.meta b/Assets/VRM/Resources/Shaders/VRMUnlitTransparentZWrite.shader.meta similarity index 100% rename from Assets/VRM/UniVRM/Resources/Shaders/VRMUnlitTransparentZWrite.shader.meta rename to Assets/VRM/Resources/Shaders/VRMUnlitTransparentZWrite.shader.meta diff --git a/Assets/VRM/Runtime.meta b/Assets/VRM/Runtime.meta new file mode 100644 index 000000000..440adb5b6 --- /dev/null +++ b/Assets/VRM/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fa718af2898e5564aa4fc9c9f7f5a429 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape.meta b/Assets/VRM/Runtime/BlendShape.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape.meta rename to Assets/VRM/Runtime/BlendShape.meta diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeAvatar.cs b/Assets/VRM/Runtime/BlendShape/BlendShapeAvatar.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeAvatar.cs rename to Assets/VRM/Runtime/BlendShape/BlendShapeAvatar.cs diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeAvatar.cs.meta b/Assets/VRM/Runtime/BlendShape/BlendShapeAvatar.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeAvatar.cs.meta rename to Assets/VRM/Runtime/BlendShape/BlendShapeAvatar.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeBindingMerger.cs b/Assets/VRM/Runtime/BlendShape/BlendShapeBindingMerger.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeBindingMerger.cs rename to Assets/VRM/Runtime/BlendShape/BlendShapeBindingMerger.cs diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeBindingMerger.cs.meta b/Assets/VRM/Runtime/BlendShape/BlendShapeBindingMerger.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeBindingMerger.cs.meta rename to Assets/VRM/Runtime/BlendShape/BlendShapeBindingMerger.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeClip.cs b/Assets/VRM/Runtime/BlendShape/BlendShapeClip.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeClip.cs rename to Assets/VRM/Runtime/BlendShape/BlendShapeClip.cs diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeClip.cs.meta b/Assets/VRM/Runtime/BlendShape/BlendShapeClip.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeClip.cs.meta rename to Assets/VRM/Runtime/BlendShape/BlendShapeClip.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeClipHandler.cs b/Assets/VRM/Runtime/BlendShape/BlendShapeClipHandler.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeClipHandler.cs rename to Assets/VRM/Runtime/BlendShape/BlendShapeClipHandler.cs diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeClipHandler.cs.meta b/Assets/VRM/Runtime/BlendShape/BlendShapeClipHandler.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeClipHandler.cs.meta rename to Assets/VRM/Runtime/BlendShape/BlendShapeClipHandler.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeKey.cs b/Assets/VRM/Runtime/BlendShape/BlendShapeKey.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeKey.cs rename to Assets/VRM/Runtime/BlendShape/BlendShapeKey.cs diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeKey.cs.meta b/Assets/VRM/Runtime/BlendShape/BlendShapeKey.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeKey.cs.meta rename to Assets/VRM/Runtime/BlendShape/BlendShapeKey.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeMerger.cs b/Assets/VRM/Runtime/BlendShape/BlendShapeMerger.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeMerger.cs rename to Assets/VRM/Runtime/BlendShape/BlendShapeMerger.cs diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeMerger.cs.meta b/Assets/VRM/Runtime/BlendShape/BlendShapeMerger.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/BlendShapeMerger.cs.meta rename to Assets/VRM/Runtime/BlendShape/BlendShapeMerger.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/Blinker.cs b/Assets/VRM/Runtime/BlendShape/Blinker.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/Blinker.cs rename to Assets/VRM/Runtime/BlendShape/Blinker.cs diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/Blinker.cs.meta b/Assets/VRM/Runtime/BlendShape/Blinker.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/Blinker.cs.meta rename to Assets/VRM/Runtime/BlendShape/Blinker.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/MaterialValueBindingMerger.cs b/Assets/VRM/Runtime/BlendShape/MaterialValueBindingMerger.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/MaterialValueBindingMerger.cs rename to Assets/VRM/Runtime/BlendShape/MaterialValueBindingMerger.cs diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/MaterialValueBindingMerger.cs.meta b/Assets/VRM/Runtime/BlendShape/MaterialValueBindingMerger.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/MaterialValueBindingMerger.cs.meta rename to Assets/VRM/Runtime/BlendShape/MaterialValueBindingMerger.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/MeshPreviewItem.cs b/Assets/VRM/Runtime/BlendShape/MeshPreviewItem.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/MeshPreviewItem.cs rename to Assets/VRM/Runtime/BlendShape/MeshPreviewItem.cs diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/MeshPreviewItem.cs.meta b/Assets/VRM/Runtime/BlendShape/MeshPreviewItem.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/MeshPreviewItem.cs.meta rename to Assets/VRM/Runtime/BlendShape/MeshPreviewItem.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/PreviewSceneManager.cs b/Assets/VRM/Runtime/BlendShape/PreviewSceneManager.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/PreviewSceneManager.cs rename to Assets/VRM/Runtime/BlendShape/PreviewSceneManager.cs diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/PreviewSceneManager.cs.meta b/Assets/VRM/Runtime/BlendShape/PreviewSceneManager.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/PreviewSceneManager.cs.meta rename to Assets/VRM/Runtime/BlendShape/PreviewSceneManager.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/VRMBlendShapeProxy.cs b/Assets/VRM/Runtime/BlendShape/VRMBlendShapeProxy.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/VRMBlendShapeProxy.cs rename to Assets/VRM/Runtime/BlendShape/VRMBlendShapeProxy.cs diff --git a/Assets/VRM/UniVRM/Scripts/BlendShape/VRMBlendShapeProxy.cs.meta b/Assets/VRM/Runtime/BlendShape/VRMBlendShapeProxy.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/BlendShape/VRMBlendShapeProxy.cs.meta rename to Assets/VRM/Runtime/BlendShape/VRMBlendShapeProxy.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/EnumUtil.cs b/Assets/VRM/Runtime/EnumUtil.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/EnumUtil.cs rename to Assets/VRM/Runtime/EnumUtil.cs diff --git a/Assets/VRM/UniVRM/Scripts/EnumUtil.cs.meta b/Assets/VRM/Runtime/EnumUtil.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/EnumUtil.cs.meta rename to Assets/VRM/Runtime/EnumUtil.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Extensions.meta b/Assets/VRM/Runtime/Extensions.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Extensions.meta rename to Assets/VRM/Runtime/Extensions.meta diff --git a/Assets/VRM/UniVRM/Scripts/Extensions/EnumExtensions.cs b/Assets/VRM/Runtime/Extensions/EnumExtensions.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Extensions/EnumExtensions.cs rename to Assets/VRM/Runtime/Extensions/EnumExtensions.cs diff --git a/Assets/VRM/UniVRM/Scripts/Extensions/EnumExtensions.cs.meta b/Assets/VRM/Runtime/Extensions/EnumExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Extensions/EnumExtensions.cs.meta rename to Assets/VRM/Runtime/Extensions/EnumExtensions.cs.meta diff --git a/Assets/VRM/Runtime/Extensions/VrmHumanoidExtensions.cs b/Assets/VRM/Runtime/Extensions/VrmHumanoidExtensions.cs new file mode 100644 index 000000000..7c8c948e9 --- /dev/null +++ b/Assets/VRM/Runtime/Extensions/VrmHumanoidExtensions.cs @@ -0,0 +1,117 @@ +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +namespace VRM +{ + public static class VRMBoneExtensions + { + public static VRMBone FromHumanBodyBone(this HumanBodyBones human) + { + return human.ToVrmBone(); + } + + public static HumanBodyBones ToHumanBodyBone(this VRMBone bone) + { +#if UNITY_5_6_OR_NEWER +#else + if (bone == VRMBone.upperChest) + { + return HumanBodyBones.LastBone; + } +#endif + return bone.ToUnityBone(); + + } + } + + public static class VRMHumanoidExtensions + { + public static void SetNodeIndex(this glTF_VRM_Humanoid self, HumanBodyBones _key, int node) + { + var key = _key.FromHumanBodyBone(); + var index = self.humanBones.FindIndex(x => x.vrmBone == key); + if (index == -1 || self.humanBones[index] == null) + { + // not found + self.humanBones.Add(new glTF_VRM_HumanoidBone + { + vrmBone = key, + node = node + }); + } + else + { + self.humanBones[index].node = node; + } + } + + public static void Apply(this glTF_VRM_Humanoid self, UniHumanoid.AvatarDescription desc, List nodes) + { + self.armStretch = desc.armStretch; + self.legStretch = desc.legStretch; + self.upperArmTwist = desc.upperArmTwist; + self.lowerArmTwist = desc.lowerArmTwist; + self.upperLegTwist = desc.upperLegTwist; + self.lowerLegTwist = desc.lowerArmTwist; + self.feetSpacing = desc.feetSpacing; + self.hasTranslationDoF = desc.hasTranslationDoF; + + foreach (var x in desc.human) + { + var key = x.humanBone.FromHumanBodyBone(); + var found = self.humanBones.FirstOrDefault(y => y.vrmBone == key); + if (found == null) + { + found = new glTF_VRM_HumanoidBone + { + vrmBone = key + }; + self.humanBones.Add(found); + } + + found.node = nodes.FindIndex(y => y.name == x.boneName); + + found.useDefaultValues = x.useDefaultValues; + found.axisLength = x.axisLength; + found.center = x.center; + found.max = x.max; + found.min = x.min; + } + } + + public static UniHumanoid.AvatarDescription ToDescription(this glTF_VRM_Humanoid self, List nodes) + { + var description = ScriptableObject.CreateInstance(); + description.upperLegTwist = self.upperLegTwist; + description.lowerLegTwist = self.lowerLegTwist; + description.upperArmTwist = self.upperArmTwist; + description.lowerArmTwist = self.lowerArmTwist; + description.armStretch = self.armStretch; + description.legStretch = self.legStretch; + description.hasTranslationDoF = self.hasTranslationDoF; + + var boneLimits = new UniHumanoid.BoneLimit[self.humanBones.Count]; + int index = 0; + foreach (var x in self.humanBones) + { + if (x.node < 0 || x.node >= nodes.Count) continue; + boneLimits[index] = new UniHumanoid.BoneLimit + { + boneName = nodes[x.node].name, + useDefaultValues = x.useDefaultValues, + axisLength = x.axisLength, + center = x.center, + min = x.min, + max = x.max, + humanBone = x.vrmBone.ToHumanBodyBone(), + }; + index++; + } + + description.human = boneLimits; + + return description; + } + } +} diff --git a/Assets/VRM/Runtime/Extensions/VrmHumanoidExtensions.cs.meta b/Assets/VRM/Runtime/Extensions/VrmHumanoidExtensions.cs.meta new file mode 100644 index 000000000..bf5b5b8c5 --- /dev/null +++ b/Assets/VRM/Runtime/Extensions/VrmHumanoidExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 158e5a48e96dfce4a92244763bc1d69d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs b/Assets/VRM/Runtime/Extensions/glTF_VRMExtensions.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs rename to Assets/VRM/Runtime/Extensions/glTF_VRMExtensions.cs diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs.meta b/Assets/VRM/Runtime/Extensions/glTF_VRMExtensions.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRMExtensions.cs.meta rename to Assets/VRM/Runtime/Extensions/glTF_VRMExtensions.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/FirstPerson.meta b/Assets/VRM/Runtime/FirstPerson.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/FirstPerson.meta rename to Assets/VRM/Runtime/FirstPerson.meta diff --git a/Assets/VRM/UniVRM/Scripts/FirstPerson/VRMFirstPerson.cs b/Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs similarity index 99% rename from Assets/VRM/UniVRM/Scripts/FirstPerson/VRMFirstPerson.cs rename to Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs index 509c974db..9bfe0681f 100644 --- a/Assets/VRM/UniVRM/Scripts/FirstPerson/VRMFirstPerson.cs +++ b/Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs @@ -114,7 +114,7 @@ namespace VRM return FirstPersonFlag.Auto; } - foreach (var x in context.GLTF.extensions.VRM.firstPerson.meshAnnotations) + foreach (var x in context.VRM.firstPerson.meshAnnotations) { if (x.mesh == index) { diff --git a/Assets/VRM/UniVRM/Scripts/FirstPerson/VRMFirstPerson.cs.meta b/Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/FirstPerson/VRMFirstPerson.cs.meta rename to Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/FirstPerson/VRMFirstPersonCameraManager.cs b/Assets/VRM/Runtime/FirstPerson/VRMFirstPersonCameraManager.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/FirstPerson/VRMFirstPersonCameraManager.cs rename to Assets/VRM/Runtime/FirstPerson/VRMFirstPersonCameraManager.cs diff --git a/Assets/VRM/UniVRM/Scripts/FirstPerson/VRMFirstPersonCameraManager.cs.meta b/Assets/VRM/Runtime/FirstPerson/VRMFirstPersonCameraManager.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/FirstPerson/VRMFirstPersonCameraManager.cs.meta rename to Assets/VRM/Runtime/FirstPerson/VRMFirstPersonCameraManager.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format.meta b/Assets/VRM/Runtime/Format.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format.meta rename to Assets/VRM/Runtime/Format.meta diff --git a/Assets/VRM/Runtime/Format/VRMDeserializer.g.cs b/Assets/VRM/Runtime/Format/VRMDeserializer.g.cs new file mode 100644 index 000000000..3566ff447 --- /dev/null +++ b/Assets/VRM/Runtime/Format/VRMDeserializer.g.cs @@ -0,0 +1,1099 @@ + +using UniJSON; +using System; +using System.Collections.Generic; +using VRM; +using UnityEngine; + +namespace VRM { + +public static class VrmDeserializer +{ + + +public static glTF_VRM_extensions Deserialize(ListTreeNode parsed) +{ + var value = new glTF_VRM_extensions(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="exporterVersion"){ + value.exporterVersion = kv.Value.GetString(); + continue; + } + + if(key=="specVersion"){ + value.specVersion = kv.Value.GetString(); + continue; + } + + if(key=="meta"){ + value.meta = Deserialize_vrm_meta(kv.Value); + continue; + } + + if(key=="humanoid"){ + value.humanoid = Deserialize_vrm_humanoid(kv.Value); + continue; + } + + if(key=="firstPerson"){ + value.firstPerson = Deserialize_vrm_firstPerson(kv.Value); + continue; + } + + if(key=="blendShapeMaster"){ + value.blendShapeMaster = Deserialize_vrm_blendShapeMaster(kv.Value); + continue; + } + + if(key=="secondaryAnimation"){ + value.secondaryAnimation = Deserialize_vrm_secondaryAnimation(kv.Value); + continue; + } + + if(key=="materialProperties"){ + value.materialProperties = Deserialize_vrm_materialProperties(kv.Value); + continue; + } + + } + return value; +} + +public static glTF_VRM_Meta Deserialize_vrm_meta(ListTreeNode parsed) +{ + var value = new glTF_VRM_Meta(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="title"){ + value.title = kv.Value.GetString(); + continue; + } + + if(key=="version"){ + value.version = kv.Value.GetString(); + continue; + } + + if(key=="author"){ + value.author = kv.Value.GetString(); + continue; + } + + if(key=="contactInformation"){ + value.contactInformation = kv.Value.GetString(); + continue; + } + + if(key=="reference"){ + value.reference = kv.Value.GetString(); + continue; + } + + if(key=="texture"){ + value.texture = kv.Value.GetInt32(); + continue; + } + + if(key=="allowedUserName"){ + value.allowedUserName = kv.Value.GetString(); + continue; + } + + if(key=="violentUssageName"){ + value.violentUssageName = kv.Value.GetString(); + continue; + } + + if(key=="sexualUssageName"){ + value.sexualUssageName = kv.Value.GetString(); + continue; + } + + if(key=="commercialUssageName"){ + value.commercialUssageName = kv.Value.GetString(); + continue; + } + + if(key=="otherPermissionUrl"){ + value.otherPermissionUrl = kv.Value.GetString(); + continue; + } + + if(key=="licenseName"){ + value.licenseName = kv.Value.GetString(); + continue; + } + + if(key=="otherLicenseUrl"){ + value.otherLicenseUrl = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static glTF_VRM_Humanoid Deserialize_vrm_humanoid(ListTreeNode parsed) +{ + var value = new glTF_VRM_Humanoid(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="humanBones"){ + value.humanBones = Deserialize_vrm_humanoid_humanBones(kv.Value); + continue; + } + + if(key=="armStretch"){ + value.armStretch = kv.Value.GetSingle(); + continue; + } + + if(key=="legStretch"){ + value.legStretch = kv.Value.GetSingle(); + continue; + } + + if(key=="upperArmTwist"){ + value.upperArmTwist = kv.Value.GetSingle(); + continue; + } + + if(key=="lowerArmTwist"){ + value.lowerArmTwist = kv.Value.GetSingle(); + continue; + } + + if(key=="upperLegTwist"){ + value.upperLegTwist = kv.Value.GetSingle(); + continue; + } + + if(key=="lowerLegTwist"){ + value.lowerLegTwist = kv.Value.GetSingle(); + continue; + } + + if(key=="feetSpacing"){ + value.feetSpacing = kv.Value.GetSingle(); + continue; + } + + if(key=="hasTranslationDoF"){ + value.hasTranslationDoF = kv.Value.GetBoolean(); + continue; + } + + } + return value; +} + +public static List Deserialize_vrm_humanoid_humanBones(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_vrm_humanoid_humanBones_LIST(x)); + } + return value; +} +public static glTF_VRM_HumanoidBone Deserialize_vrm_humanoid_humanBones_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_HumanoidBone(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="bone"){ + value.bone = kv.Value.GetString(); + continue; + } + + if(key=="node"){ + value.node = kv.Value.GetInt32(); + continue; + } + + if(key=="useDefaultValues"){ + value.useDefaultValues = kv.Value.GetBoolean(); + continue; + } + + if(key=="min"){ + value.min = Deserialize_vrm_humanoid_humanBones__min(kv.Value); + continue; + } + + if(key=="max"){ + value.max = Deserialize_vrm_humanoid_humanBones__max(kv.Value); + continue; + } + + if(key=="center"){ + value.center = Deserialize_vrm_humanoid_humanBones__center(kv.Value); + continue; + } + + if(key=="axisLength"){ + value.axisLength = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_vrm_humanoid_humanBones__min(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_vrm_humanoid_humanBones__max(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_vrm_humanoid_humanBones__center(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static glTF_VRM_Firstperson Deserialize_vrm_firstPerson(ListTreeNode parsed) +{ + var value = new glTF_VRM_Firstperson(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="firstPersonBone"){ + value.firstPersonBone = kv.Value.GetInt32(); + continue; + } + + if(key=="firstPersonBoneOffset"){ + value.firstPersonBoneOffset = Deserialize_vrm_firstPerson_firstPersonBoneOffset(kv.Value); + continue; + } + + if(key=="meshAnnotations"){ + value.meshAnnotations = Deserialize_vrm_firstPerson_meshAnnotations(kv.Value); + continue; + } + + if(key=="lookAtTypeName"){ + value.lookAtTypeName = kv.Value.GetString(); + continue; + } + + if(key=="lookAtHorizontalInner"){ + value.lookAtHorizontalInner = Deserialize_vrm_firstPerson_lookAtHorizontalInner(kv.Value); + continue; + } + + if(key=="lookAtHorizontalOuter"){ + value.lookAtHorizontalOuter = Deserialize_vrm_firstPerson_lookAtHorizontalOuter(kv.Value); + continue; + } + + if(key=="lookAtVerticalDown"){ + value.lookAtVerticalDown = Deserialize_vrm_firstPerson_lookAtVerticalDown(kv.Value); + continue; + } + + if(key=="lookAtVerticalUp"){ + value.lookAtVerticalUp = Deserialize_vrm_firstPerson_lookAtVerticalUp(kv.Value); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_vrm_firstPerson_firstPersonBoneOffset(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static List Deserialize_vrm_firstPerson_meshAnnotations(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_vrm_firstPerson_meshAnnotations_LIST(x)); + } + return value; +} +public static glTF_VRM_MeshAnnotation Deserialize_vrm_firstPerson_meshAnnotations_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_MeshAnnotation(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="mesh"){ + value.mesh = kv.Value.GetInt32(); + continue; + } + + if(key=="firstPersonFlag"){ + value.firstPersonFlag = kv.Value.GetString(); + continue; + } + + } + return value; +} + +public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtHorizontalInner(ListTreeNode parsed) +{ + var value = new glTF_VRM_DegreeMap(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="curve"){ + value.curve = Deserialize_vrm_firstPerson_lookAtHorizontalInner_curve(kv.Value); + continue; + } + + if(key=="xRange"){ + value.xRange = kv.Value.GetSingle(); + continue; + } + + if(key=="yRange"){ + value.yRange = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_vrm_firstPerson_lookAtHorizontalInner_curve(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtHorizontalOuter(ListTreeNode parsed) +{ + var value = new glTF_VRM_DegreeMap(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="curve"){ + value.curve = Deserialize_vrm_firstPerson_lookAtHorizontalOuter_curve(kv.Value); + continue; + } + + if(key=="xRange"){ + value.xRange = kv.Value.GetSingle(); + continue; + } + + if(key=="yRange"){ + value.yRange = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_vrm_firstPerson_lookAtHorizontalOuter_curve(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtVerticalDown(ListTreeNode parsed) +{ + var value = new glTF_VRM_DegreeMap(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="curve"){ + value.curve = Deserialize_vrm_firstPerson_lookAtVerticalDown_curve(kv.Value); + continue; + } + + if(key=="xRange"){ + value.xRange = kv.Value.GetSingle(); + continue; + } + + if(key=="yRange"){ + value.yRange = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_vrm_firstPerson_lookAtVerticalDown_curve(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static glTF_VRM_DegreeMap Deserialize_vrm_firstPerson_lookAtVerticalUp(ListTreeNode parsed) +{ + var value = new glTF_VRM_DegreeMap(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="curve"){ + value.curve = Deserialize_vrm_firstPerson_lookAtVerticalUp_curve(kv.Value); + continue; + } + + if(key=="xRange"){ + value.xRange = kv.Value.GetSingle(); + continue; + } + + if(key=="yRange"){ + value.yRange = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_vrm_firstPerson_lookAtVerticalUp_curve(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static glTF_VRM_BlendShapeMaster Deserialize_vrm_blendShapeMaster(ListTreeNode parsed) +{ + var value = new glTF_VRM_BlendShapeMaster(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="blendShapeGroups"){ + value.blendShapeGroups = Deserialize_vrm_blendShapeMaster_blendShapeGroups(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_vrm_blendShapeMaster_blendShapeGroups(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_vrm_blendShapeMaster_blendShapeGroups_LIST(x)); + } + return value; +} +public static glTF_VRM_BlendShapeGroup Deserialize_vrm_blendShapeMaster_blendShapeGroups_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_BlendShapeGroup(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="presetName"){ + value.presetName = kv.Value.GetString(); + continue; + } + + if(key=="binds"){ + value.binds = Deserialize_vrm_blendShapeMaster_blendShapeGroups__binds(kv.Value); + continue; + } + + if(key=="materialValues"){ + value.materialValues = Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues(kv.Value); + continue; + } + + if(key=="isBinary"){ + value.isBinary = kv.Value.GetBoolean(); + continue; + } + + } + return value; +} + +public static List Deserialize_vrm_blendShapeMaster_blendShapeGroups__binds(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_vrm_blendShapeMaster_blendShapeGroups__binds_LIST(x)); + } + return value; +} +public static glTF_VRM_BlendShapeBind Deserialize_vrm_blendShapeMaster_blendShapeGroups__binds_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_BlendShapeBind(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="mesh"){ + value.mesh = kv.Value.GetInt32(); + continue; + } + + if(key=="index"){ + value.index = kv.Value.GetInt32(); + continue; + } + + if(key=="weight"){ + value.weight = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static List Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_LIST(x)); + } + return value; +} +public static glTF_VRM_MaterialValueBind Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_MaterialValueBind(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="materialName"){ + value.materialName = kv.Value.GetString(); + continue; + } + + if(key=="propertyName"){ + value.propertyName = kv.Value.GetString(); + continue; + } + + if(key=="targetValue"){ + value.targetValue = Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues__targetValue(kv.Value); + continue; + } + + } + return value; +} + +public static Single[] Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues__targetValue(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + +public static glTF_VRM_SecondaryAnimation Deserialize_vrm_secondaryAnimation(ListTreeNode parsed) +{ + var value = new glTF_VRM_SecondaryAnimation(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="boneGroups"){ + value.boneGroups = Deserialize_vrm_secondaryAnimation_boneGroups(kv.Value); + continue; + } + + if(key=="colliderGroups"){ + value.colliderGroups = Deserialize_vrm_secondaryAnimation_colliderGroups(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_vrm_secondaryAnimation_boneGroups(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_vrm_secondaryAnimation_boneGroups_LIST(x)); + } + return value; +} +public static glTF_VRM_SecondaryAnimationGroup Deserialize_vrm_secondaryAnimation_boneGroups_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_SecondaryAnimationGroup(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="comment"){ + value.comment = kv.Value.GetString(); + continue; + } + + if(key=="stiffiness"){ + value.stiffiness = kv.Value.GetSingle(); + continue; + } + + if(key=="gravityPower"){ + value.gravityPower = kv.Value.GetSingle(); + continue; + } + + if(key=="gravityDir"){ + value.gravityDir = Deserialize_vrm_secondaryAnimation_boneGroups__gravityDir(kv.Value); + continue; + } + + if(key=="dragForce"){ + value.dragForce = kv.Value.GetSingle(); + continue; + } + + if(key=="center"){ + value.center = kv.Value.GetInt32(); + continue; + } + + if(key=="hitRadius"){ + value.hitRadius = kv.Value.GetSingle(); + continue; + } + + if(key=="bones"){ + value.bones = Deserialize_vrm_secondaryAnimation_boneGroups__bones(kv.Value); + continue; + } + + if(key=="colliderGroups"){ + value.colliderGroups = Deserialize_vrm_secondaryAnimation_boneGroups__colliderGroups(kv.Value); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_vrm_secondaryAnimation_boneGroups__gravityDir(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Int32[] Deserialize_vrm_secondaryAnimation_boneGroups__bones(ListTreeNode parsed) +{ + var value = new Int32[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetInt32(); + } + return value; +} + +public static Int32[] Deserialize_vrm_secondaryAnimation_boneGroups__colliderGroups(ListTreeNode parsed) +{ + var value = new Int32[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetInt32(); + } + return value; +} + +public static List Deserialize_vrm_secondaryAnimation_colliderGroups(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_vrm_secondaryAnimation_colliderGroups_LIST(x)); + } + return value; +} +public static glTF_VRM_SecondaryAnimationColliderGroup Deserialize_vrm_secondaryAnimation_colliderGroups_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_SecondaryAnimationColliderGroup(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="node"){ + value.node = kv.Value.GetInt32(); + continue; + } + + if(key=="colliders"){ + value.colliders = Deserialize_vrm_secondaryAnimation_colliderGroups__colliders(kv.Value); + continue; + } + + } + return value; +} + +public static List Deserialize_vrm_secondaryAnimation_colliderGroups__colliders(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_vrm_secondaryAnimation_colliderGroups__colliders_LIST(x)); + } + return value; +} +public static glTF_VRM_SecondaryAnimationCollider Deserialize_vrm_secondaryAnimation_colliderGroups__colliders_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_SecondaryAnimationCollider(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="offset"){ + value.offset = Deserialize_vrm_secondaryAnimation_colliderGroups__colliders__offset(kv.Value); + continue; + } + + if(key=="radius"){ + value.radius = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static Vector3 Deserialize_vrm_secondaryAnimation_colliderGroups__colliders__offset(ListTreeNode parsed) +{ + var value = new Vector3(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="x"){ + value.x = kv.Value.GetSingle(); + continue; + } + + if(key=="y"){ + value.y = kv.Value.GetSingle(); + continue; + } + + if(key=="z"){ + value.z = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static List Deserialize_vrm_materialProperties(ListTreeNode parsed) +{ + var value = new List(); + foreach(var x in parsed.ArrayItems()) + { + value.Add(Deserialize_vrm_materialProperties_LIST(x)); + } + return value; +} +public static glTF_VRM_Material Deserialize_vrm_materialProperties_LIST(ListTreeNode parsed) +{ + var value = new glTF_VRM_Material(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="name"){ + value.name = kv.Value.GetString(); + continue; + } + + if(key=="shader"){ + value.shader = kv.Value.GetString(); + continue; + } + + if(key=="renderQueue"){ + value.renderQueue = kv.Value.GetInt32(); + continue; + } + + if(key=="floatProperties"){ + value.floatProperties = Deserialize_vrm_materialProperties__floatProperties(kv.Value); + continue; + } + + if(key=="vectorProperties"){ + value.vectorProperties = Deserialize_vrm_materialProperties__vectorProperties(kv.Value); + continue; + } + + if(key=="textureProperties"){ + value.textureProperties = Deserialize_vrm_materialProperties__textureProperties(kv.Value); + continue; + } + + if(key=="keywordMap"){ + value.keywordMap = Deserialize_vrm_materialProperties__keywordMap(kv.Value); + continue; + } + + if(key=="tagMap"){ + value.tagMap = Deserialize_vrm_materialProperties__tagMap(kv.Value); + continue; + } + + } + return value; +} + + +public static Dictionary Deserialize_vrm_materialProperties__floatProperties(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), kv.Value.GetSingle()); + } + return value; +} + + +public static Dictionary Deserialize_vrm_materialProperties__vectorProperties(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), Deserialize_vrm_materialProperties__vectorProperties_DICT(kv.Value)); + } + return value; +} + +public static Single[] Deserialize_vrm_materialProperties__vectorProperties_DICT(ListTreeNode parsed) +{ + var value = new Single[parsed.GetArrayCount()]; + int i=0; + foreach(var x in parsed.ArrayItems()) + { + value[i++] = x.GetSingle(); + } + return value; +} + + +public static Dictionary Deserialize_vrm_materialProperties__textureProperties(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), kv.Value.GetInt32()); + } + return value; +} + + +public static Dictionary Deserialize_vrm_materialProperties__keywordMap(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), kv.Value.GetBoolean()); + } + return value; +} + + +public static Dictionary Deserialize_vrm_materialProperties__tagMap(ListTreeNode parsed) +{ + var value = new Dictionary(); + foreach(var kv in parsed.ObjectItems()) + { + value.Add(kv.Key.GetString(), kv.Value.GetString()); + } + return value; +} + +} // VrmfDeserializer +} // VRM diff --git a/Assets/VRM/Runtime/Format/VRMDeserializer.g.cs.meta b/Assets/VRM/Runtime/Format/VRMDeserializer.g.cs.meta new file mode 100644 index 000000000..13b3fa2ca --- /dev/null +++ b/Assets/VRM/Runtime/Format/VRMDeserializer.g.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7d3f5617d4d8fd74494cab1e56d6b001 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMException.cs b/Assets/VRM/Runtime/Format/VRMException.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMException.cs rename to Assets/VRM/Runtime/Format/VRMException.cs diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMException.cs.meta b/Assets/VRM/Runtime/Format/VRMException.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMException.cs.meta rename to Assets/VRM/Runtime/Format/VRMException.cs.meta diff --git a/Assets/VRM/Runtime/Format/VRMSerializer.g.cs b/Assets/VRM/Runtime/Format/VRMSerializer.g.cs new file mode 100644 index 000000000..ec49f1e3e --- /dev/null +++ b/Assets/VRM/Runtime/Format/VRMSerializer.g.cs @@ -0,0 +1,1034 @@ + +using System; +using System.Collections.Generic; +using UniJSON; +using UnityEngine; +using VRM; + +namespace VRM { + + static public class VRMSerializer + { + + +public static void Serialize(JsonFormatter f, glTF_VRM_extensions value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.exporterVersion)){ + f.Key("exporterVersion"); + f.Value(value.exporterVersion); + } + + if(!string.IsNullOrEmpty(value.specVersion)){ + f.Key("specVersion"); + f.Value(value.specVersion); + } + + if(value.meta!=null){ + f.Key("meta"); + Serialize_vrm_meta(f, value.meta); + } + + if(value.humanoid!=null){ + f.Key("humanoid"); + Serialize_vrm_humanoid(f, value.humanoid); + } + + if(value.firstPerson!=null){ + f.Key("firstPerson"); + Serialize_vrm_firstPerson(f, value.firstPerson); + } + + if(value.blendShapeMaster!=null){ + f.Key("blendShapeMaster"); + Serialize_vrm_blendShapeMaster(f, value.blendShapeMaster); + } + + if(value.secondaryAnimation!=null){ + f.Key("secondaryAnimation"); + Serialize_vrm_secondaryAnimation(f, value.secondaryAnimation); + } + + if(value.materialProperties!=null&&value.materialProperties.Count>=0){ + f.Key("materialProperties"); + Serialize_vrm_materialProperties(f, value.materialProperties); + } + + f.EndMap(); +} + +public static void Serialize_vrm_meta(JsonFormatter f, glTF_VRM_Meta value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.title)){ + f.Key("title"); + f.Value(value.title); + } + + if(!string.IsNullOrEmpty(value.version)){ + f.Key("version"); + f.Value(value.version); + } + + if(!string.IsNullOrEmpty(value.author)){ + f.Key("author"); + f.Value(value.author); + } + + if(!string.IsNullOrEmpty(value.contactInformation)){ + f.Key("contactInformation"); + f.Value(value.contactInformation); + } + + if(!string.IsNullOrEmpty(value.reference)){ + f.Key("reference"); + f.Value(value.reference); + } + + if(value.texture>=0){ + f.Key("texture"); + f.Value(value.texture); + } + + if(!string.IsNullOrEmpty(value.allowedUserName)){ + f.Key("allowedUserName"); + f.Value(value.allowedUserName); + } + + if(!string.IsNullOrEmpty(value.violentUssageName)){ + f.Key("violentUssageName"); + f.Value(value.violentUssageName); + } + + if(!string.IsNullOrEmpty(value.sexualUssageName)){ + f.Key("sexualUssageName"); + f.Value(value.sexualUssageName); + } + + if(!string.IsNullOrEmpty(value.commercialUssageName)){ + f.Key("commercialUssageName"); + f.Value(value.commercialUssageName); + } + + if(!string.IsNullOrEmpty(value.otherPermissionUrl)){ + f.Key("otherPermissionUrl"); + f.Value(value.otherPermissionUrl); + } + + if(!string.IsNullOrEmpty(value.licenseName)){ + f.Key("licenseName"); + f.Value(value.licenseName); + } + + if(!string.IsNullOrEmpty(value.otherLicenseUrl)){ + f.Key("otherLicenseUrl"); + f.Value(value.otherLicenseUrl); + } + + f.EndMap(); +} + +public static void Serialize_vrm_humanoid(JsonFormatter f, glTF_VRM_Humanoid value) +{ + f.BeginMap(); + + + if(value.humanBones!=null&&value.humanBones.Count>=0){ + f.Key("humanBones"); + Serialize_vrm_humanoid_humanBones(f, value.humanBones); + } + + if(true){ + f.Key("armStretch"); + f.Value(value.armStretch); + } + + if(true){ + f.Key("legStretch"); + f.Value(value.legStretch); + } + + if(true){ + f.Key("upperArmTwist"); + f.Value(value.upperArmTwist); + } + + if(true){ + f.Key("lowerArmTwist"); + f.Value(value.lowerArmTwist); + } + + if(true){ + f.Key("upperLegTwist"); + f.Value(value.upperLegTwist); + } + + if(true){ + f.Key("lowerLegTwist"); + f.Value(value.lowerLegTwist); + } + + if(true){ + f.Key("feetSpacing"); + f.Value(value.feetSpacing); + } + + if(true){ + f.Key("hasTranslationDoF"); + f.Value(value.hasTranslationDoF); + } + + f.EndMap(); +} + +public static void Serialize_vrm_humanoid_humanBones(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_vrm_humanoid_humanBones_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_vrm_humanoid_humanBones_ITEM(JsonFormatter f, glTF_VRM_HumanoidBone value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.bone)){ + f.Key("bone"); + f.Value(value.bone); + } + + if(value.node>=0){ + f.Key("node"); + f.Value(value.node); + } + + if(true){ + f.Key("useDefaultValues"); + f.Value(value.useDefaultValues); + } + + if(value.min!=null&&value.min!=Vector3.zero){ + f.Key("min"); + Serialize_vrm_humanoid_humanBones__min(f, value.min); + } + + if(value.max!=null&&value.min!=Vector3.zero){ + f.Key("max"); + Serialize_vrm_humanoid_humanBones__max(f, value.max); + } + + if(value.center!=null&&value.min!=Vector3.zero){ + f.Key("center"); + Serialize_vrm_humanoid_humanBones__center(f, value.center); + } + + if(value.axisLength>0){ + f.Key("axisLength"); + f.Value(value.axisLength); + } + + f.EndMap(); +} + +public static void Serialize_vrm_humanoid_humanBones__min(JsonFormatter f, Vector3 value) +{ + f.BeginMap(); + + + if(true){ + f.Key("x"); + f.Value(value.x); + } + + if(true){ + f.Key("y"); + f.Value(value.y); + } + + if(true){ + f.Key("z"); + f.Value(value.z); + } + + f.EndMap(); +} + +public static void Serialize_vrm_humanoid_humanBones__max(JsonFormatter f, Vector3 value) +{ + f.BeginMap(); + + + if(true){ + f.Key("x"); + f.Value(value.x); + } + + if(true){ + f.Key("y"); + f.Value(value.y); + } + + if(true){ + f.Key("z"); + f.Value(value.z); + } + + f.EndMap(); +} + +public static void Serialize_vrm_humanoid_humanBones__center(JsonFormatter f, Vector3 value) +{ + f.BeginMap(); + + + if(true){ + f.Key("x"); + f.Value(value.x); + } + + if(true){ + f.Key("y"); + f.Value(value.y); + } + + if(true){ + f.Key("z"); + f.Value(value.z); + } + + f.EndMap(); +} + +public static void Serialize_vrm_firstPerson(JsonFormatter f, glTF_VRM_Firstperson value) +{ + f.BeginMap(); + + + if(value.firstPersonBone>=0){ + f.Key("firstPersonBone"); + f.Value(value.firstPersonBone); + } + + if(value.firstPersonBoneOffset!=null){ + f.Key("firstPersonBoneOffset"); + Serialize_vrm_firstPerson_firstPersonBoneOffset(f, value.firstPersonBoneOffset); + } + + if(value.meshAnnotations!=null&&value.meshAnnotations.Count>=0){ + f.Key("meshAnnotations"); + Serialize_vrm_firstPerson_meshAnnotations(f, value.meshAnnotations); + } + + if(!string.IsNullOrEmpty(value.lookAtTypeName)){ + f.Key("lookAtTypeName"); + f.Value(value.lookAtTypeName); + } + + if(value.lookAtHorizontalInner!=null){ + f.Key("lookAtHorizontalInner"); + Serialize_vrm_firstPerson_lookAtHorizontalInner(f, value.lookAtHorizontalInner); + } + + if(value.lookAtHorizontalOuter!=null){ + f.Key("lookAtHorizontalOuter"); + Serialize_vrm_firstPerson_lookAtHorizontalOuter(f, value.lookAtHorizontalOuter); + } + + if(value.lookAtVerticalDown!=null){ + f.Key("lookAtVerticalDown"); + Serialize_vrm_firstPerson_lookAtVerticalDown(f, value.lookAtVerticalDown); + } + + if(value.lookAtVerticalUp!=null){ + f.Key("lookAtVerticalUp"); + Serialize_vrm_firstPerson_lookAtVerticalUp(f, value.lookAtVerticalUp); + } + + f.EndMap(); +} + +public static void Serialize_vrm_firstPerson_firstPersonBoneOffset(JsonFormatter f, Vector3 value) +{ + f.BeginMap(); + + + if(true){ + f.Key("x"); + f.Value(value.x); + } + + if(true){ + f.Key("y"); + f.Value(value.y); + } + + if(true){ + f.Key("z"); + f.Value(value.z); + } + + f.EndMap(); +} + +public static void Serialize_vrm_firstPerson_meshAnnotations(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_vrm_firstPerson_meshAnnotations_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_vrm_firstPerson_meshAnnotations_ITEM(JsonFormatter f, glTF_VRM_MeshAnnotation value) +{ + f.BeginMap(); + + + if(value.mesh>=0){ + f.Key("mesh"); + f.Value(value.mesh); + } + + if(!string.IsNullOrEmpty(value.firstPersonFlag)){ + f.Key("firstPersonFlag"); + f.Value(value.firstPersonFlag); + } + + f.EndMap(); +} + +public static void Serialize_vrm_firstPerson_lookAtHorizontalInner(JsonFormatter f, glTF_VRM_DegreeMap value) +{ + f.BeginMap(); + + + if(value.curve!=null&&value.curve.Length>=0){ + f.Key("curve"); + Serialize_vrm_firstPerson_lookAtHorizontalInner_curve(f, value.curve); + } + + if(true){ + f.Key("xRange"); + f.Value(value.xRange); + } + + if(true){ + f.Key("yRange"); + f.Value(value.yRange); + } + + f.EndMap(); +} + +public static void Serialize_vrm_firstPerson_lookAtHorizontalInner_curve(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_vrm_firstPerson_lookAtHorizontalOuter(JsonFormatter f, glTF_VRM_DegreeMap value) +{ + f.BeginMap(); + + + if(value.curve!=null&&value.curve.Length>=0){ + f.Key("curve"); + Serialize_vrm_firstPerson_lookAtHorizontalOuter_curve(f, value.curve); + } + + if(true){ + f.Key("xRange"); + f.Value(value.xRange); + } + + if(true){ + f.Key("yRange"); + f.Value(value.yRange); + } + + f.EndMap(); +} + +public static void Serialize_vrm_firstPerson_lookAtHorizontalOuter_curve(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_vrm_firstPerson_lookAtVerticalDown(JsonFormatter f, glTF_VRM_DegreeMap value) +{ + f.BeginMap(); + + + if(value.curve!=null&&value.curve.Length>=0){ + f.Key("curve"); + Serialize_vrm_firstPerson_lookAtVerticalDown_curve(f, value.curve); + } + + if(true){ + f.Key("xRange"); + f.Value(value.xRange); + } + + if(true){ + f.Key("yRange"); + f.Value(value.yRange); + } + + f.EndMap(); +} + +public static void Serialize_vrm_firstPerson_lookAtVerticalDown_curve(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_vrm_firstPerson_lookAtVerticalUp(JsonFormatter f, glTF_VRM_DegreeMap value) +{ + f.BeginMap(); + + + if(value.curve!=null&&value.curve.Length>=0){ + f.Key("curve"); + Serialize_vrm_firstPerson_lookAtVerticalUp_curve(f, value.curve); + } + + if(true){ + f.Key("xRange"); + f.Value(value.xRange); + } + + if(true){ + f.Key("yRange"); + f.Value(value.yRange); + } + + f.EndMap(); +} + +public static void Serialize_vrm_firstPerson_lookAtVerticalUp_curve(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_vrm_blendShapeMaster(JsonFormatter f, glTF_VRM_BlendShapeMaster value) +{ + f.BeginMap(); + + + if(value.blendShapeGroups!=null&&value.blendShapeGroups.Count>=0){ + f.Key("blendShapeGroups"); + Serialize_vrm_blendShapeMaster_blendShapeGroups(f, value.blendShapeGroups); + } + + f.EndMap(); +} + +public static void Serialize_vrm_blendShapeMaster_blendShapeGroups(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_vrm_blendShapeMaster_blendShapeGroups_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_vrm_blendShapeMaster_blendShapeGroups_ITEM(JsonFormatter f, glTF_VRM_BlendShapeGroup value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + if(!string.IsNullOrEmpty(value.presetName)){ + f.Key("presetName"); + f.Value(value.presetName); + } + + if(value.binds!=null&&value.binds.Count>=0){ + f.Key("binds"); + Serialize_vrm_blendShapeMaster_blendShapeGroups__binds(f, value.binds); + } + + if(value.materialValues!=null&&value.materialValues.Count>=0){ + f.Key("materialValues"); + Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues(f, value.materialValues); + } + + if(true){ + f.Key("isBinary"); + f.Value(value.isBinary); + } + + f.EndMap(); +} + +public static void Serialize_vrm_blendShapeMaster_blendShapeGroups__binds(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_vrm_blendShapeMaster_blendShapeGroups__binds_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_vrm_blendShapeMaster_blendShapeGroups__binds_ITEM(JsonFormatter f, glTF_VRM_BlendShapeBind value) +{ + f.BeginMap(); + + + if(value.mesh>=0){ + f.Key("mesh"); + f.Value(value.mesh); + } + + if(value.index>=0){ + f.Key("index"); + f.Value(value.index); + } + + if(value.weight>=0){ + f.Key("weight"); + f.Value(value.weight); + } + + f.EndMap(); +} + +public static void Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_ITEM(JsonFormatter f, glTF_VRM_MaterialValueBind value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.materialName)){ + f.Key("materialName"); + f.Value(value.materialName); + } + + if(!string.IsNullOrEmpty(value.propertyName)){ + f.Key("propertyName"); + f.Value(value.propertyName); + } + + if(value.targetValue!=null&&value.targetValue.Length>=0){ + f.Key("targetValue"); + Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues__targetValue(f, value.targetValue); + } + + f.EndMap(); +} + +public static void Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues__targetValue(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_vrm_secondaryAnimation(JsonFormatter f, glTF_VRM_SecondaryAnimation value) +{ + f.BeginMap(); + + + if(value.boneGroups!=null&&value.boneGroups.Count>=0){ + f.Key("boneGroups"); + Serialize_vrm_secondaryAnimation_boneGroups(f, value.boneGroups); + } + + if(value.colliderGroups!=null&&value.colliderGroups.Count>=0){ + f.Key("colliderGroups"); + Serialize_vrm_secondaryAnimation_colliderGroups(f, value.colliderGroups); + } + + f.EndMap(); +} + +public static void Serialize_vrm_secondaryAnimation_boneGroups(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_vrm_secondaryAnimation_boneGroups_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_vrm_secondaryAnimation_boneGroups_ITEM(JsonFormatter f, glTF_VRM_SecondaryAnimationGroup value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.comment)){ + f.Key("comment"); + f.Value(value.comment); + } + + if(true){ + f.Key("stiffiness"); + f.Value(value.stiffiness); + } + + if(true){ + f.Key("gravityPower"); + f.Value(value.gravityPower); + } + + if(value.gravityDir!=null){ + f.Key("gravityDir"); + Serialize_vrm_secondaryAnimation_boneGroups__gravityDir(f, value.gravityDir); + } + + if(true){ + f.Key("dragForce"); + f.Value(value.dragForce); + } + + if(true){ + f.Key("center"); + f.Value(value.center); + } + + if(true){ + f.Key("hitRadius"); + f.Value(value.hitRadius); + } + + if(value.bones!=null&&value.bones.Length>=0){ + f.Key("bones"); + Serialize_vrm_secondaryAnimation_boneGroups__bones(f, value.bones); + } + + if(value.colliderGroups!=null&&value.colliderGroups.Length>=0){ + f.Key("colliderGroups"); + Serialize_vrm_secondaryAnimation_boneGroups__colliderGroups(f, value.colliderGroups); + } + + f.EndMap(); +} + +public static void Serialize_vrm_secondaryAnimation_boneGroups__gravityDir(JsonFormatter f, Vector3 value) +{ + f.BeginMap(); + + + if(true){ + f.Key("x"); + f.Value(value.x); + } + + if(true){ + f.Key("y"); + f.Value(value.y); + } + + if(true){ + f.Key("z"); + f.Value(value.z); + } + + f.EndMap(); +} + +public static void Serialize_vrm_secondaryAnimation_boneGroups__bones(JsonFormatter f, Int32[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_vrm_secondaryAnimation_boneGroups__colliderGroups(JsonFormatter f, Int32[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_vrm_secondaryAnimation_colliderGroups(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_vrm_secondaryAnimation_colliderGroups_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_vrm_secondaryAnimation_colliderGroups_ITEM(JsonFormatter f, glTF_VRM_SecondaryAnimationColliderGroup value) +{ + f.BeginMap(); + + + if(value.node>=0){ + f.Key("node"); + f.Value(value.node); + } + + if(value.colliders!=null&&value.colliders.Count>=0){ + f.Key("colliders"); + Serialize_vrm_secondaryAnimation_colliderGroups__colliders(f, value.colliders); + } + + f.EndMap(); +} + +public static void Serialize_vrm_secondaryAnimation_colliderGroups__colliders(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_vrm_secondaryAnimation_colliderGroups__colliders_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_vrm_secondaryAnimation_colliderGroups__colliders_ITEM(JsonFormatter f, glTF_VRM_SecondaryAnimationCollider value) +{ + f.BeginMap(); + + + if(value.offset!=null){ + f.Key("offset"); + Serialize_vrm_secondaryAnimation_colliderGroups__colliders__offset(f, value.offset); + } + + if(true){ + f.Key("radius"); + f.Value(value.radius); + } + + f.EndMap(); +} + +public static void Serialize_vrm_secondaryAnimation_colliderGroups__colliders__offset(JsonFormatter f, Vector3 value) +{ + f.BeginMap(); + + + if(true){ + f.Key("x"); + f.Value(value.x); + } + + if(true){ + f.Key("y"); + f.Value(value.y); + } + + if(true){ + f.Key("z"); + f.Value(value.z); + } + + f.EndMap(); +} + +public static void Serialize_vrm_materialProperties(JsonFormatter f, List value) +{ + f.BeginList(); + + foreach(var item in value) + { + Serialize_vrm_materialProperties_ITEM(f, item); + + } + f.EndList(); +} + +public static void Serialize_vrm_materialProperties_ITEM(JsonFormatter f, glTF_VRM_Material value) +{ + f.BeginMap(); + + + if(!string.IsNullOrEmpty(value.name)){ + f.Key("name"); + f.Value(value.name); + } + + if(!string.IsNullOrEmpty(value.shader)){ + f.Key("shader"); + f.Value(value.shader); + } + + if(true){ + f.Key("renderQueue"); + f.Value(value.renderQueue); + } + + if(value.floatProperties!=null&&value.floatProperties.Count>0){ + f.Key("floatProperties"); + Serialize_vrm_materialProperties__floatProperties(f, value.floatProperties); + } + + if(value.vectorProperties!=null&&value.vectorProperties.Count>0){ + f.Key("vectorProperties"); + Serialize_vrm_materialProperties__vectorProperties(f, value.vectorProperties); + } + + if(value.textureProperties!=null&&value.textureProperties.Count>0){ + f.Key("textureProperties"); + Serialize_vrm_materialProperties__textureProperties(f, value.textureProperties); + } + + if(value.keywordMap!=null&&value.keywordMap.Count>0){ + f.Key("keywordMap"); + Serialize_vrm_materialProperties__keywordMap(f, value.keywordMap); + } + + if(value.tagMap!=null&&value.tagMap.Count>0){ + f.Key("tagMap"); + Serialize_vrm_materialProperties__tagMap(f, value.tagMap); + } + + f.EndMap(); +} + +public static void Serialize_vrm_materialProperties__floatProperties(JsonFormatter f, Dictionary value) +{ + f.BeginMap(); + foreach(var kv in value) + { + f.Key(kv.Key); + f.Value(kv.Value); + } + f.EndMap(); +} + +public static void Serialize_vrm_materialProperties__vectorProperties(JsonFormatter f, Dictionary value) +{ + f.BeginMap(); + foreach(var kv in value) + { + f.Key(kv.Key); + Serialize_vrm_materialProperties__vectorProperties_ITEM(f, kv.Value); + } + f.EndMap(); +} + +public static void Serialize_vrm_materialProperties__vectorProperties_ITEM(JsonFormatter f, Single[] value) +{ + f.BeginList(); + + foreach(var item in value) + { + f.Value(item); + + } + f.EndList(); +} + +public static void Serialize_vrm_materialProperties__textureProperties(JsonFormatter f, Dictionary value) +{ + f.BeginMap(); + foreach(var kv in value) + { + f.Key(kv.Key); + f.Value(kv.Value); + } + f.EndMap(); +} + +public static void Serialize_vrm_materialProperties__keywordMap(JsonFormatter f, Dictionary value) +{ + f.BeginMap(); + foreach(var kv in value) + { + f.Key(kv.Key); + f.Value(kv.Value); + } + f.EndMap(); +} + +public static void Serialize_vrm_materialProperties__tagMap(JsonFormatter f, Dictionary value) +{ + f.BeginMap(); + foreach(var kv in value) + { + f.Key(kv.Key); + f.Value(kv.Value); + } + f.EndMap(); +} + + } // class +} // namespace diff --git a/Assets/VRM/Runtime/Format/VRMSerializer.g.cs.meta b/Assets/VRM/Runtime/Format/VRMSerializer.g.cs.meta new file mode 100644 index 000000000..c90430fe6 --- /dev/null +++ b/Assets/VRM/Runtime/Format/VRMSerializer.g.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e6690cb3c5aaeaa4f862b396991bf4a5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs b/Assets/VRM/Runtime/Format/VRMSpecVersion.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs rename to Assets/VRM/Runtime/Format/VRMSpecVersion.cs diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs.meta b/Assets/VRM/Runtime/Format/VRMSpecVersion.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMSpecVersion.cs.meta rename to Assets/VRM/Runtime/Format/VRMSpecVersion.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMVersion.cs b/Assets/VRM/Runtime/Format/VRMVersion.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMVersion.cs rename to Assets/VRM/Runtime/Format/VRMVersion.cs diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMVersion.cs.meta b/Assets/VRM/Runtime/Format/VRMVersion.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMVersion.cs.meta rename to Assets/VRM/Runtime/Format/VRMVersion.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMVersionPartial.cs b/Assets/VRM/Runtime/Format/VRMVersionPartial.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMVersionPartial.cs rename to Assets/VRM/Runtime/Format/VRMVersionPartial.cs diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMVersionPartial.cs.meta b/Assets/VRM/Runtime/Format/VRMVersionPartial.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMVersionPartial.cs.meta rename to Assets/VRM/Runtime/Format/VRMVersionPartial.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_BlendShape.cs b/Assets/VRM/Runtime/Format/glTF_VRM_BlendShape.cs similarity index 64% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_BlendShape.cs rename to Assets/VRM/Runtime/Format/glTF_VRM_BlendShape.cs index 80e859660..6b7f53951 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_BlendShape.cs +++ b/Assets/VRM/Runtime/Format/glTF_VRM_BlendShape.cs @@ -8,23 +8,16 @@ namespace VRM { [Serializable] [JsonSchema(Title = "vrm.blendshape.materialbind")] - public class glTF_VRM_MaterialValueBind : UniGLTF.JsonSerializableBase + public class glTF_VRM_MaterialValueBind { public string materialName; public string propertyName; public float[] targetValue; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => materialName); - f.KeyValue(() => propertyName); - f.KeyValue(() => targetValue); - } } [Serializable] [JsonSchema(Title = "vrm.blendshape.bind")] - public class glTF_VRM_BlendShapeBind : UniGLTF.JsonSerializableBase + public class glTF_VRM_BlendShapeBind { [JsonSchema(Required = true, Minimum = 0)] public int mesh = -1; @@ -32,15 +25,8 @@ namespace VRM [JsonSchema(Required = true, Minimum = 0)] public int index = -1; - [JsonSchema(Required =true, Minimum = 0, Maximum = 100, Description = @"SkinnedMeshRenderer.SetBlendShapeWeight")] + [JsonSchema(Required = true, Minimum = 0, Maximum = 100, Description = @"SkinnedMeshRenderer.SetBlendShapeWeight")] public float weight = 0; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => mesh); - f.KeyValue(() => index); - f.KeyValue(() => weight); - } } public enum BlendShapePreset @@ -75,7 +61,7 @@ namespace VRM [Serializable] [JsonSchema(Title = "vrm.blendshape.group", Description = "BlendShapeClip of UniVRM")] - public class glTF_VRM_BlendShapeGroup : UniGLTF.JsonSerializableBase + public class glTF_VRM_BlendShapeGroup { [JsonSchema(Description = "Expression name")] public string name; @@ -110,27 +96,12 @@ namespace VRM [JsonSchema(Description = "0 or 1. Do not allow an intermediate value. Value should rounded")] public bool isBinary; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => name); - f.KeyValue(() => presetName); - f.KeyValue(() => isBinary); - f.Key("binds"); f.GLTFValue(binds); - f.Key("materialValues"); f.GLTFValue(materialValues); - } } [Serializable] [JsonSchema(Title = "vrm.blendshape", Description = "BlendShapeAvatar of UniVRM")] - public class glTF_VRM_BlendShapeMaster : UniGLTF.JsonSerializableBase + public class glTF_VRM_BlendShapeMaster { public List blendShapeGroups = new List(); - - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.Key("blendShapeGroups"); f.GLTFValue(blendShapeGroups); - } } } diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_BlendShape.cs.meta b/Assets/VRM/Runtime/Format/glTF_VRM_BlendShape.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_BlendShape.cs.meta rename to Assets/VRM/Runtime/Format/glTF_VRM_BlendShape.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_FirstPerson.cs b/Assets/VRM/Runtime/Format/glTF_VRM_FirstPerson.cs similarity index 69% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_FirstPerson.cs rename to Assets/VRM/Runtime/Format/glTF_VRM_FirstPerson.cs index d376478fa..f1ab7e968 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_FirstPerson.cs +++ b/Assets/VRM/Runtime/Format/glTF_VRM_FirstPerson.cs @@ -9,7 +9,7 @@ namespace VRM { [Serializable] [JsonSchema(Title = "vrm.firstperson.degreemap")] - public class glTF_VRM_DegreeMap : UniGLTF.JsonSerializableBase + public class glTF_VRM_DegreeMap { [JsonSchema(Description = "None linear mapping params. time, value, inTangent, outTangent")] public float[] curve; @@ -19,16 +19,6 @@ namespace VRM [JsonSchema(Description = "Look at map range degree from xRange.")] public float yRange = 10.0f; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - if (curve != null) - { - f.KeyValue(() => curve); - } - f.KeyValue(() => xRange); - f.KeyValue(() => yRange); - } } public enum FirstPersonFlag @@ -41,19 +31,13 @@ namespace VRM [Serializable] [JsonSchema(Title = "vrm.firstperson.meshannotation")] - public class glTF_VRM_MeshAnnotation : JsonSerializableBase + public class glTF_VRM_MeshAnnotation { // When the value is -1, it means that no target mesh is found. [JsonSchema(Minimum = 0)] public int mesh; public string firstPersonFlag; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => mesh); - f.KeyValue(() => firstPersonFlag); - } } public enum LookAtType @@ -65,13 +49,14 @@ namespace VRM [Serializable] [JsonSchema(Title = "vrm.firstperson")] - public class glTF_VRM_Firstperson : UniGLTF.JsonSerializableBase + public class glTF_VRM_Firstperson { // When the value is -1, it means that no bone for first person is found. [JsonSchema(Description = "The bone whose rendering should be turned off in first-person view. Usually Head is specified.", Minimum = 0, ExplicitIgnorableValue = -1)] public int firstPersonBone = -1; - [JsonSchema(Description = @"The target position of the VR headset in first-person view. It is assumed that an offset from the head bone to the VR headset is added.")] + [JsonSchema(Description = @"The target position of the VR headset in first-person view. It is assumed that an offset from the head bone to the VR headset is added." + )] public Vector3 firstPersonBoneOffset; [JsonSchema(Description = "Switch display / undisplay for each mesh in first-person view or the others.")] @@ -103,18 +88,5 @@ namespace VRM [JsonSchema(Description = "Eye controller setting.")] public glTF_VRM_DegreeMap lookAtVerticalUp = new glTF_VRM_DegreeMap(); - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => firstPersonBone); - f.KeyValue(() => firstPersonBoneOffset); - f.Key("meshAnnotations"); f.GLTFValue(meshAnnotations); - - f.KeyValue(() => lookAtTypeName); - f.Key("lookAtHorizontalInner"); f.GLTFValue(lookAtHorizontalInner); - f.Key("lookAtHorizontalOuter"); f.GLTFValue(lookAtHorizontalOuter); - f.Key("lookAtVerticalDown"); f.GLTFValue(lookAtVerticalDown); - f.Key("lookAtVerticalUp"); f.GLTFValue(lookAtVerticalUp); - } } } diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_FirstPerson.cs.meta b/Assets/VRM/Runtime/Format/glTF_VRM_FirstPerson.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_FirstPerson.cs.meta rename to Assets/VRM/Runtime/Format/glTF_VRM_FirstPerson.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Humanoid.cs b/Assets/VRM/Runtime/Format/glTF_VRM_Humanoid.cs similarity index 51% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Humanoid.cs rename to Assets/VRM/Runtime/Format/glTF_VRM_Humanoid.cs index 6065a38da..27e1051f7 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Humanoid.cs +++ b/Assets/VRM/Runtime/Format/glTF_VRM_Humanoid.cs @@ -2,10 +2,8 @@ using System.Collections.Generic; using System.Linq; using UniGLTF; -using UniJSON; using UnityEngine; - namespace VRM { public enum VRMBone @@ -69,29 +67,9 @@ namespace VRM unknown, } - public static class VRMBoneExtensions - { - public static VRMBone FromHumanBodyBone(this HumanBodyBones human) - { - return human.ToVrmBone(); - } - - public static HumanBodyBones ToHumanBodyBone(this VRMBone bone) - { -#if UNITY_5_6_OR_NEWER -#else - if (bone == VRMBone.upperChest) - { - return HumanBodyBones.LastBone; - } -#endif - return bone.ToUnityBone(); - } - } - [Serializable] [JsonSchema(Title = "vrm.humanoid.bone")] - public class glTF_VRM_HumanoidBone : JsonSerializableBase + public class glTF_VRM_HumanoidBone { [JsonSchema(Description = "Human bone name.", EnumValues = new object[] { @@ -172,36 +150,22 @@ namespace VRM [JsonSchema(Description = "Unity's HumanLimit.useDefaultValues")] public bool useDefaultValues = true; - [JsonSchema(Description = "Unity's HumanLimit.min")] + [JsonSchema(Description = "Unity's HumanLimit.min", SerializationConditions = new string[] { "value.min!=Vector3.zero" })] public Vector3 min; - [JsonSchema(Description = "Unity's HumanLimit.max")] + [JsonSchema(Description = "Unity's HumanLimit.max", SerializationConditions = new string[] { "value.min!=Vector3.zero" })] public Vector3 max; - [JsonSchema(Description = "Unity's HumanLimit.center")] + [JsonSchema(Description = "Unity's HumanLimit.center", SerializationConditions = new string[] { "value.min!=Vector3.zero" })] public Vector3 center; - [JsonSchema(Description = "Unity's HumanLimit.axisLength")] + [JsonSchema(Description = "Unity's HumanLimit.axisLength", Minimum = 0, ExclusiveMinimum = true)] public float axisLength; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.Key("bone"); f.Value((string) bone.ToString()); - f.KeyValue(() => node); - f.KeyValue(() => useDefaultValues); - if (!useDefaultValues) - { - f.KeyValue(() => min); - f.KeyValue(() => max); - f.KeyValue(() => center); - f.KeyValue(() => axisLength); - } - } } [Serializable] [JsonSchema(Title = "vrm.humanoid")] - public class glTF_VRM_Humanoid : JsonSerializableBase + public class glTF_VRM_Humanoid { public List humanBones = new List(); @@ -228,105 +192,5 @@ namespace VRM [JsonSchema(Description = "Unity's HumanDescription.hasTranslationDoF")] public bool hasTranslationDoF = false; - - public void SetNodeIndex(HumanBodyBones _key, int node) - { - var key = _key.FromHumanBodyBone(); - var index = humanBones.FindIndex(x => x.vrmBone == key); - if (index == -1 || humanBones[index] == null) - { - // not found - humanBones.Add(new glTF_VRM_HumanoidBone - { - vrmBone = key, - node = node - }); - } - else - { - humanBones[index].node = node; - } - } - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.Key("humanBones"); f.GLTFValue(humanBones); - f.KeyValue(() => armStretch); - f.KeyValue(() => legStretch); - f.KeyValue(() => upperArmTwist); - f.KeyValue(() => lowerArmTwist); - f.KeyValue(() => upperLegTwist); - f.KeyValue(() => lowerLegTwist); - f.KeyValue(() => feetSpacing); - f.KeyValue(() => hasTranslationDoF); - } - - public void Apply(UniHumanoid.AvatarDescription desc, List nodes) - { - armStretch = desc.armStretch; - legStretch = desc.legStretch; - upperArmTwist = desc.upperArmTwist; - lowerArmTwist = desc.lowerArmTwist; - upperLegTwist = desc.upperLegTwist; - lowerLegTwist = desc.lowerArmTwist; - feetSpacing = desc.feetSpacing; - hasTranslationDoF = desc.hasTranslationDoF; - - foreach (var x in desc.human) - { - var key = x.humanBone.FromHumanBodyBone(); - var found = humanBones.FirstOrDefault(y => y.vrmBone == key); - if (found == null) - { - found = new glTF_VRM_HumanoidBone - { - vrmBone = key - }; - humanBones.Add(found); - } - - found.node = nodes.FindIndex(y => y.name == x.boneName); - - found.useDefaultValues = x.useDefaultValues; - found.axisLength = x.axisLength; - found.center = x.center; - found.max = x.max; - found.min = x.min; - } - } - - public UniHumanoid.AvatarDescription ToDescription(List nodes) - { - var description = ScriptableObject.CreateInstance(); - description.upperLegTwist = upperLegTwist; - description.lowerLegTwist = lowerLegTwist; - description.upperArmTwist = upperArmTwist; - description.lowerArmTwist = lowerArmTwist; - description.armStretch = armStretch; - description.legStretch = legStretch; - description.hasTranslationDoF = hasTranslationDoF; - - var boneLimits = new UniHumanoid.BoneLimit[humanBones.Count]; - int index = 0; - foreach (var x in humanBones) - { - if (x.node < 0 || x.node >= nodes.Count) continue; - boneLimits[index] = new UniHumanoid.BoneLimit - { - boneName = nodes[x.node].name, - useDefaultValues = x.useDefaultValues, - axisLength = x.axisLength, - center = x.center, - min = x.min, - max = x.max, - humanBone = x.vrmBone.ToHumanBodyBone(), - }; - index++; - } - - description.human = boneLimits; - - return description; - } } -} \ No newline at end of file +} diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Humanoid.cs.meta b/Assets/VRM/Runtime/Format/glTF_VRM_Humanoid.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Humanoid.cs.meta rename to Assets/VRM/Runtime/Format/glTF_VRM_Humanoid.cs.meta diff --git a/Assets/VRM/Runtime/Format/glTF_VRM_Material.cs b/Assets/VRM/Runtime/Format/glTF_VRM_Material.cs new file mode 100644 index 000000000..846ab0b82 --- /dev/null +++ b/Assets/VRM/Runtime/Format/glTF_VRM_Material.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniGLTF; +using UniJSON; + + +namespace VRM +{ + [Serializable] + [JsonSchema(Title = "vrm.material")] + public class glTF_VRM_Material + { + public string name; + public string shader; + public int renderQueue = -1; + + public Dictionary floatProperties = new Dictionary(); + public Dictionary vectorProperties = new Dictionary(); + public Dictionary textureProperties = new Dictionary(); + public Dictionary keywordMap = new Dictionary(); + public Dictionary tagMap = new Dictionary(); + + public static readonly string VRM_USE_GLTFSHADER = "VRM_USE_GLTFSHADER"; + + static Utf8String s_floatProperties = Utf8String.From("floatProperties"); + static Utf8String s_vectorProperties = Utf8String.From("vectorProperties"); + static Utf8String s_keywordMap = Utf8String.From("keywordMap"); + static Utf8String s_tagMap = Utf8String.From("tagMap"); + static Utf8String s_textureProperties = Utf8String.From("textureProperties"); + } +} diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Material.cs.meta b/Assets/VRM/Runtime/Format/glTF_VRM_Material.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Material.cs.meta rename to Assets/VRM/Runtime/Format/glTF_VRM_Material.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Meta.cs b/Assets/VRM/Runtime/Format/glTF_VRM_Meta.cs similarity index 86% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Meta.cs rename to Assets/VRM/Runtime/Format/glTF_VRM_Meta.cs index 7610142ff..c1036ebc7 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Meta.cs +++ b/Assets/VRM/Runtime/Format/glTF_VRM_Meta.cs @@ -32,7 +32,7 @@ namespace VRM [Serializable] [JsonSchema(Title = "vrm.meta")] - public class glTF_VRM_Meta : JsonSerializableBase + public class glTF_VRM_Meta { static UssageLicense FromString(string src) { @@ -146,26 +146,5 @@ namespace VRM [JsonSchema(Description = "If “Other” is selected, put the URL link of the license document here.")] public string otherLicenseUrl; #endregion - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => version); - - f.KeyValue(() => author); - f.KeyValue(() => contactInformation); - f.KeyValue(() => reference); - - f.KeyValue(() => title); - f.KeyValue(() => texture); - - f.KeyValue(() => allowedUserName); - f.KeyValue(() => violentUssageName); - f.KeyValue(() => sexualUssageName); - f.KeyValue(() => commercialUssageName); - f.KeyValue(() => otherPermissionUrl); - - f.KeyValue(() => licenseName); - f.KeyValue(() => otherLicenseUrl); - } } } diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Meta.cs.meta b/Assets/VRM/Runtime/Format/glTF_VRM_Meta.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Meta.cs.meta rename to Assets/VRM/Runtime/Format/glTF_VRM_Meta.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_SecondaryAnimation.cs b/Assets/VRM/Runtime/Format/glTF_VRM_SecondaryAnimation.cs similarity index 70% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_SecondaryAnimation.cs rename to Assets/VRM/Runtime/Format/glTF_VRM_SecondaryAnimation.cs index 5d825b8c3..ba5257ec3 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_SecondaryAnimation.cs +++ b/Assets/VRM/Runtime/Format/glTF_VRM_SecondaryAnimation.cs @@ -8,42 +8,30 @@ using UnityEngine; namespace VRM { [Serializable] - public class glTF_VRM_SecondaryAnimationCollider : JsonSerializableBase + public class glTF_VRM_SecondaryAnimationCollider { [JsonSchema(Description = "The local coordinate from the node of the collider group.")] public Vector3 offset; [JsonSchema(Description = "The radius of the collider.")] public float radius; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => offset); - f.KeyValue(() => radius); - } } [Serializable] [JsonSchema(Title = "vrm.secondaryanimation.collidergroup", Description = @"Set sphere balls for colliders used for collision detections with swaying objects.")] - public class glTF_VRM_SecondaryAnimationColliderGroup : JsonSerializableBase + public class glTF_VRM_SecondaryAnimationColliderGroup { [JsonSchema(Description = "The node of the collider group for setting up collision detections.", Minimum = 0)] public int node; public List colliders = new List(); - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => node); - f.Key("colliders"); f.GLTFValue(colliders); - } } [Serializable] [JsonSchema(Title = "vrm.secondaryanimation.spring")] - public class glTF_VRM_SecondaryAnimationGroup : JsonSerializableBase + public class glTF_VRM_SecondaryAnimationGroup { [JsonSchema(Description = "Annotation comment")] public string comment; @@ -76,35 +64,16 @@ namespace VRM [JsonSchema(Description = "Specify the index of the collider group for collisions with swaying objects.")] [ItemJsonSchema(Minimum = 0)] public int[] colliderGroups = new int[] { }; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => comment); - f.KeyValue(() => stiffiness); - f.KeyValue(() => gravityPower); - f.KeyValue(() => gravityDir); - f.KeyValue(() => dragForce); - f.KeyValue(() => center); - f.KeyValue(() => hitRadius); - f.KeyValue(() => bones); - f.KeyValue(() => colliderGroups); - } } [Serializable] [JsonSchema(Title = "vrm.secondaryanimation", Description = "The setting of automatic animation of string-like objects such as tails and hairs.")] - public class glTF_VRM_SecondaryAnimation : JsonSerializableBase + public class glTF_VRM_SecondaryAnimation { [JsonSchema(ExplicitIgnorableItemLength = 0)] public List boneGroups = new List(); [JsonSchema(ExplicitIgnorableItemLength = 0)] public List colliderGroups = new List(); - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.Key("boneGroups"); f.GLTFValue(boneGroups); - f.Key("colliderGroups"); f.GLTFValue(colliderGroups); - } } } diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_SecondaryAnimation.cs.meta b/Assets/VRM/Runtime/Format/glTF_VRM_SecondaryAnimation.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_SecondaryAnimation.cs.meta rename to Assets/VRM/Runtime/Format/glTF_VRM_SecondaryAnimation.cs.meta diff --git a/Assets/VRM/Runtime/Format/glTF_VRM_extensions.cs b/Assets/VRM/Runtime/Format/glTF_VRM_extensions.cs new file mode 100644 index 000000000..26340156d --- /dev/null +++ b/Assets/VRM/Runtime/Format/glTF_VRM_extensions.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using UniGLTF; +using UniJSON; + +namespace VRM +{ + [Serializable] + [JsonSchema(Title = "vrm", Description = @" +VRM extension is for 3d humanoid avatars (and models) in VR applications. +")] + public class glTF_VRM_extensions + { + public const string ExtensionName = "VRM"; + + public static readonly Utf8String ExtensionNameUtf8 = Utf8String.From(ExtensionName); + + [JsonSchema(Description = @"Version of exporter that vrm created. " + VRMVersion.VRM_VERSION)] + public string exporterVersion = "UniVRM-" + VRMVersion.VERSION; + + [JsonSchema(Description = @"Version of VRM specification. " + VRMSpecVersion.VERSION)] + public string specVersion = VRMSpecVersion.Version; + + public glTF_VRM_Meta meta = new glTF_VRM_Meta(); + public glTF_VRM_Humanoid humanoid = new glTF_VRM_Humanoid(); + public glTF_VRM_Firstperson firstPerson = new glTF_VRM_Firstperson(); + public glTF_VRM_BlendShapeMaster blendShapeMaster = new glTF_VRM_BlendShapeMaster(); + public glTF_VRM_SecondaryAnimation secondaryAnimation = new glTF_VRM_SecondaryAnimation(); + public List materialProperties = new List(); + + public static bool TryDeserilize(glTFExtension extension, out glTF_VRM_extensions vrm) + { + if (extension is glTFExtensionImport import) + { + foreach (var kv in import.ObjectItems()) + { + if (kv.Key.GetUtf8String() == ExtensionNameUtf8) + { + vrm = VrmDeserializer.Deserialize(kv.Value); + return true; + } + } + } + + vrm = default; + return false; + } + } +} diff --git a/Assets/VRM/Runtime/Format/glTF_VRM_extensions.cs.meta b/Assets/VRM/Runtime/Format/glTF_VRM_extensions.cs.meta new file mode 100644 index 000000000..5cf92e8ef --- /dev/null +++ b/Assets/VRM/Runtime/Format/glTF_VRM_extensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d58b001b3cfa63e41b4d2d6afa403f5d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Scripts/Humanoid.meta b/Assets/VRM/Runtime/Humanoid.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Humanoid.meta rename to Assets/VRM/Runtime/Humanoid.meta diff --git a/Assets/VRM/UniVRM/Scripts/Humanoid/VRMHumanoidDescription.cs b/Assets/VRM/Runtime/Humanoid/VRMHumanoidDescription.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Humanoid/VRMHumanoidDescription.cs rename to Assets/VRM/Runtime/Humanoid/VRMHumanoidDescription.cs diff --git a/Assets/VRM/UniVRM/Scripts/Humanoid/VRMHumanoidDescription.cs.meta b/Assets/VRM/Runtime/Humanoid/VRMHumanoidDescription.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Humanoid/VRMHumanoidDescription.cs.meta rename to Assets/VRM/Runtime/Humanoid/VRMHumanoidDescription.cs.meta diff --git a/Assets/VRM/Runtime/IO.meta b/Assets/VRM/Runtime/IO.meta new file mode 100644 index 000000000..0c716eb7d --- /dev/null +++ b/Assets/VRM/Runtime/IO.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0a722962c8944b04db7bf2bd5d39bd5c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMExporter.cs b/Assets/VRM/Runtime/IO/VRMExporter.cs similarity index 57% rename from Assets/VRM/UniVRM/Scripts/Format/VRMExporter.cs rename to Assets/VRM/Runtime/IO/VRMExporter.cs index e35cf298f..390cfe73d 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/VRMExporter.cs +++ b/Assets/VRM/Runtime/IO/VRMExporter.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using System.Linq; using UniGLTF; +using UniJSON; using UnityEngine; @@ -23,11 +25,12 @@ namespace VRM } return gltf; } - + + public readonly VRM.glTF_VRM_extensions VRM = new glTF_VRM_extensions(); + public VRMExporter(glTF gltf) : base(gltf) { gltf.extensionsUsed.Add(glTF_VRM_extensions.ExtensionName); - gltf.extensions.VRM = new glTF_VRM_extensions(); } public override void Export(MeshExportSettings configuration) @@ -51,7 +54,7 @@ namespace VRM if (description != null) { // use description - glTF.extensions.VRM.humanoid.Apply(description, nodes); + VRM.humanoid.Apply(description, nodes); } if (isCreated) @@ -73,7 +76,7 @@ namespace VRM var transform = animator.GetBoneTransform(key); if (transform != null) { - glTF.extensions.VRM.humanoid.SetNodeIndex(key, nodes.IndexOf(transform)); + VRM.humanoid.SetNodeIndex(key, nodes.IndexOf(transform)); } } } @@ -88,15 +91,15 @@ namespace VRM { foreach (var x in avatar.Clips) { - glTF.extensions.VRM.blendShapeMaster.Add(x, this); + VRM.blendShapeMaster.Add(x, this); } } } // secondary VRMSpringUtility.ExportSecondary(Copy.transform, Nodes, - x => glTF.extensions.VRM.secondaryAnimation.colliderGroups.Add(x), - x => glTF.extensions.VRM.secondaryAnimation.boneGroups.Add(x) + x => VRM.secondaryAnimation.colliderGroups.Add(x), + x => VRM.secondaryAnimation.boneGroups.Add(x) ); #pragma warning disable 0618 @@ -105,17 +108,17 @@ namespace VRM var meta = Copy.GetComponent(); if (meta != null) { - glTF.extensions.VRM.meta.author = meta.Author; - glTF.extensions.VRM.meta.contactInformation = meta.ContactInformation; - glTF.extensions.VRM.meta.title = meta.Title; + VRM.meta.author = meta.Author; + VRM.meta.contactInformation = meta.ContactInformation; + VRM.meta.title = meta.Title; if (meta.Thumbnail != null) { - glTF.extensions.VRM.meta.texture = TextureIO.ExportTexture(glTF, glTF.buffers.Count - 1, meta.Thumbnail, glTFTextureTypes.Unknown); + VRM.meta.texture = TextureIO.ExportTexture(glTF, glTF.buffers.Count - 1, meta.Thumbnail, glTFTextureTypes.Unknown); } - glTF.extensions.VRM.meta.licenseType = meta.LicenseType; - glTF.extensions.VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl; - glTF.extensions.VRM.meta.reference = meta.Reference; + VRM.meta.licenseType = meta.LicenseType; + VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl; + VRM.meta.reference = meta.Reference; } } #pragma warning restore 0618 @@ -128,28 +131,28 @@ namespace VRM var meta = _meta.Meta; // info - glTF.extensions.VRM.meta.version = meta.Version; - glTF.extensions.VRM.meta.author = meta.Author; - glTF.extensions.VRM.meta.contactInformation = meta.ContactInformation; - glTF.extensions.VRM.meta.reference = meta.Reference; - glTF.extensions.VRM.meta.title = meta.Title; + VRM.meta.version = meta.Version; + VRM.meta.author = meta.Author; + VRM.meta.contactInformation = meta.ContactInformation; + VRM.meta.reference = meta.Reference; + VRM.meta.title = meta.Title; if (meta.Thumbnail != null) { - glTF.extensions.VRM.meta.texture = TextureIO.ExportTexture(glTF, glTF.buffers.Count - 1, meta.Thumbnail, glTFTextureTypes.Unknown); + VRM.meta.texture = TextureIO.ExportTexture(glTF, glTF.buffers.Count - 1, meta.Thumbnail, glTFTextureTypes.Unknown); } // ussage permission - glTF.extensions.VRM.meta.allowedUser = meta.AllowedUser; - glTF.extensions.VRM.meta.violentUssage = meta.ViolentUssage; - glTF.extensions.VRM.meta.sexualUssage = meta.SexualUssage; - glTF.extensions.VRM.meta.commercialUssage = meta.CommercialUssage; - glTF.extensions.VRM.meta.otherPermissionUrl = meta.OtherPermissionUrl; + VRM.meta.allowedUser = meta.AllowedUser; + VRM.meta.violentUssage = meta.ViolentUssage; + VRM.meta.sexualUssage = meta.SexualUssage; + VRM.meta.commercialUssage = meta.CommercialUssage; + VRM.meta.otherPermissionUrl = meta.OtherPermissionUrl; // distribution license - glTF.extensions.VRM.meta.licenseType = meta.LicenseType; + VRM.meta.licenseType = meta.LicenseType; if (meta.LicenseType == LicenseType.Other) { - glTF.extensions.VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl; + VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl; } } } @@ -160,9 +163,9 @@ namespace VRM { if (firstPerson.FirstPersonBone != null) { - glTF.extensions.VRM.firstPerson.firstPersonBone = Nodes.IndexOf(firstPerson.FirstPersonBone); - glTF.extensions.VRM.firstPerson.firstPersonBoneOffset = firstPerson.FirstPersonOffset; - glTF.extensions.VRM.firstPerson.meshAnnotations = firstPerson.Renderers.Select(x => new glTF_VRM_MeshAnnotation + VRM.firstPerson.firstPersonBone = Nodes.IndexOf(firstPerson.FirstPersonBone); + VRM.firstPerson.firstPersonBoneOffset = firstPerson.FirstPersonOffset; + VRM.firstPerson.meshAnnotations = firstPerson.Renderers.Select(x => new glTF_VRM_MeshAnnotation { mesh = Meshes.IndexOf(x.SharedMesh), firstPersonFlag = x.FirstPersonFlag.ToString(), @@ -178,18 +181,18 @@ namespace VRM var blendShapeApplyer = Copy.GetComponent(); if (boneApplyer != null) { - glTF.extensions.VRM.firstPerson.lookAtType = LookAtType.Bone; - glTF.extensions.VRM.firstPerson.lookAtHorizontalInner.Apply(boneApplyer.HorizontalInner); - glTF.extensions.VRM.firstPerson.lookAtHorizontalOuter.Apply(boneApplyer.HorizontalOuter); - glTF.extensions.VRM.firstPerson.lookAtVerticalDown.Apply(boneApplyer.VerticalDown); - glTF.extensions.VRM.firstPerson.lookAtVerticalUp.Apply(boneApplyer.VerticalUp); + VRM.firstPerson.lookAtType = LookAtType.Bone; + VRM.firstPerson.lookAtHorizontalInner.Apply(boneApplyer.HorizontalInner); + VRM.firstPerson.lookAtHorizontalOuter.Apply(boneApplyer.HorizontalOuter); + VRM.firstPerson.lookAtVerticalDown.Apply(boneApplyer.VerticalDown); + VRM.firstPerson.lookAtVerticalUp.Apply(boneApplyer.VerticalUp); } else if (blendShapeApplyer != null) { - glTF.extensions.VRM.firstPerson.lookAtType = LookAtType.BlendShape; - glTF.extensions.VRM.firstPerson.lookAtHorizontalOuter.Apply(blendShapeApplyer.Horizontal); - glTF.extensions.VRM.firstPerson.lookAtVerticalDown.Apply(blendShapeApplyer.VerticalDown); - glTF.extensions.VRM.firstPerson.lookAtVerticalUp.Apply(blendShapeApplyer.VerticalUp); + VRM.firstPerson.lookAtType = LookAtType.BlendShape; + VRM.firstPerson.lookAtHorizontalOuter.Apply(blendShapeApplyer.Horizontal); + VRM.firstPerson.lookAtVerticalDown.Apply(blendShapeApplyer.VerticalDown); + VRM.firstPerson.lookAtVerticalUp.Apply(blendShapeApplyer.VerticalUp); } } } @@ -198,8 +201,14 @@ namespace VRM // materials foreach (var m in Materials) { - glTF.extensions.VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, TextureManager.Textures)); + VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, TextureManager.Textures)); } + + // Serialize VRM + var f = new JsonFormatter(); + VRMSerializer.Serialize(f, VRM); + var bytes = f.GetStoreBytes(); + glTFExtensionExport.GetOrCreate(ref glTF.extensions).Add("VRM", bytes); } } } diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMExporter.cs.meta b/Assets/VRM/Runtime/IO/VRMExporter.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMExporter.cs.meta rename to Assets/VRM/Runtime/IO/VRMExporter.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMImporter.cs b/Assets/VRM/Runtime/IO/VRMImporter.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMImporter.cs rename to Assets/VRM/Runtime/IO/VRMImporter.cs diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMImporter.cs.meta b/Assets/VRM/Runtime/IO/VRMImporter.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMImporter.cs.meta rename to Assets/VRM/Runtime/IO/VRMImporter.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMImporterContext.cs b/Assets/VRM/Runtime/IO/VRMImporterContext.cs similarity index 92% rename from Assets/VRM/UniVRM/Scripts/Format/VRMImporterContext.cs rename to Assets/VRM/Runtime/IO/VRMImporterContext.cs index 6bbcc2bba..9921b6ba2 100644 --- a/Assets/VRM/UniVRM/Scripts/Format/VRMImporterContext.cs +++ b/Assets/VRM/Runtime/IO/VRMImporterContext.cs @@ -5,13 +5,13 @@ using UniGLTF; using UnityEngine; using System.IO; using System.Collections; +using UniJSON; namespace VRM { public class VRMImporterContext : ImporterContext { - const string HUMANOID_KEY = "humanoid"; - const string MATERIAL_KEY = "materialProperties"; + public VRM.glTF_VRM_extensions VRM { get; private set; } public VRMImporterContext() { @@ -34,8 +34,17 @@ namespace VRM public override void ParseJson(string json, IStorage storage) { + // parse GLTF part(core + unlit, textureTransform, targetNames) base.ParseJson(json, storage); - SetMaterialImporter(new VRMMaterialImporter(this, glTF_VRM_Material.Parse(Json))); + + // parse VRM part + if (glTF_VRM_extensions.TryDeserilize(GLTF.extensions, out glTF_VRM_extensions vrm)) + { + VRM = vrm; + } + + // override material importer + SetMaterialImporter(new VRMMaterialImporter(this, VRM.materialProperties)); } #region OnLoad @@ -64,7 +73,7 @@ namespace VRM using (MeasureTime("VRM LoadSecondary")) { VRMSpringUtility.LoadSecondary(Root.transform, Nodes, - GLTF.extensions.VRM.secondaryAnimation); + VRM.secondaryAnimation); } yield return null; @@ -77,17 +86,6 @@ namespace VRM void LoadMeta() { var meta = ReadMeta(); - if (meta.Thumbnail == null) - { - /* - // 作る - var lookAt = Root.GetComponent(); - var thumbnail = lookAt.CreateThumbnail(); - thumbnail.name = "thumbnail"; - meta.Thumbnail = thumbnail; - Textures.Add(new TextureItem(thumbnail)); - */ - } var _meta = Root.AddComponent(); _meta.Meta = meta; Meta = meta; @@ -97,7 +95,7 @@ namespace VRM { var firstPerson = Root.AddComponent(); - var gltfFirstPerson = GLTF.extensions.VRM.firstPerson; + var gltfFirstPerson = VRM.firstPerson; if (gltfFirstPerson.firstPersonBone != -1) { firstPerson.FirstPersonBone = Nodes[gltfFirstPerson.firstPersonBone]; @@ -130,7 +128,7 @@ namespace VRM } } - var blendShapeList = GLTF.extensions.VRM.blendShapeMaster.blendShapeGroups; + var blendShapeList = VRM.blendShapeMaster.blendShapeGroups; if (blendShapeList != null && blendShapeList.Count > 0) { foreach (var x in blendShapeList) @@ -255,7 +253,7 @@ namespace VRM private void LoadHumanoid() { - AvatarDescription = GLTF.extensions.VRM.humanoid.ToDescription(Nodes); + AvatarDescription = VRM.humanoid.ToDescription(Nodes); AvatarDescription.name = "AvatarDescription"; HumanoidAvatar = AvatarDescription.CreateAvatar(Root.transform); if (!HumanoidAvatar.isValid || !HumanoidAvatar.isHuman) @@ -295,9 +293,9 @@ namespace VRM { var meta = ScriptableObject.CreateInstance(); meta.name = "Meta"; - meta.ExporterVersion = GLTF.extensions.VRM.exporterVersion; + meta.ExporterVersion = VRM.exporterVersion; - var gltfMeta = GLTF.extensions.VRM.meta; + var gltfMeta = VRM.meta; meta.Version = gltfMeta.version; // model version meta.Author = gltfMeta.author; meta.ContactInformation = gltfMeta.contactInformation; diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMImporterContext.cs.meta b/Assets/VRM/Runtime/IO/VRMImporterContext.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMImporterContext.cs.meta rename to Assets/VRM/Runtime/IO/VRMImporterContext.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMMaterialExporter.cs b/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMMaterialExporter.cs rename to Assets/VRM/Runtime/IO/VRMMaterialExporter.cs diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMMaterialExporter.cs.meta b/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMMaterialExporter.cs.meta rename to Assets/VRM/Runtime/IO/VRMMaterialExporter.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMMaterialImporter.cs b/Assets/VRM/Runtime/IO/VRMMaterialImporter.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMMaterialImporter.cs rename to Assets/VRM/Runtime/IO/VRMMaterialImporter.cs diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMMaterialImporter.cs.meta b/Assets/VRM/Runtime/IO/VRMMaterialImporter.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Format/VRMMaterialImporter.cs.meta rename to Assets/VRM/Runtime/IO/VRMMaterialImporter.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/IVRMComponent.cs b/Assets/VRM/Runtime/IVRMComponent.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/IVRMComponent.cs rename to Assets/VRM/Runtime/IVRMComponent.cs diff --git a/Assets/VRM/UniVRM/Scripts/IVRMComponent.cs.meta b/Assets/VRM/Runtime/IVRMComponent.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/IVRMComponent.cs.meta rename to Assets/VRM/Runtime/IVRMComponent.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/LookAt.meta b/Assets/VRM/Runtime/LookAt.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt.meta rename to Assets/VRM/Runtime/LookAt.meta diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/CurveMapper.cs b/Assets/VRM/Runtime/LookAt/CurveMapper.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/CurveMapper.cs rename to Assets/VRM/Runtime/LookAt/CurveMapper.cs diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/CurveMapper.cs.meta b/Assets/VRM/Runtime/LookAt/CurveMapper.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/CurveMapper.cs.meta rename to Assets/VRM/Runtime/LookAt/CurveMapper.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/LookAtTargetSwitcher.cs b/Assets/VRM/Runtime/LookAt/LookAtTargetSwitcher.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/LookAtTargetSwitcher.cs rename to Assets/VRM/Runtime/LookAt/LookAtTargetSwitcher.cs diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/LookAtTargetSwitcher.cs.meta b/Assets/VRM/Runtime/LookAt/LookAtTargetSwitcher.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/LookAtTargetSwitcher.cs.meta rename to Assets/VRM/Runtime/LookAt/LookAtTargetSwitcher.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/LookTarget.cs b/Assets/VRM/Runtime/LookAt/LookTarget.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/LookTarget.cs rename to Assets/VRM/Runtime/LookAt/LookTarget.cs diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/LookTarget.cs.meta b/Assets/VRM/Runtime/LookAt/LookTarget.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/LookTarget.cs.meta rename to Assets/VRM/Runtime/LookAt/LookTarget.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/Matrix4x4Extensions.cs b/Assets/VRM/Runtime/LookAt/Matrix4x4Extensions.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/Matrix4x4Extensions.cs rename to Assets/VRM/Runtime/LookAt/Matrix4x4Extensions.cs diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/Matrix4x4Extensions.cs.meta b/Assets/VRM/Runtime/LookAt/Matrix4x4Extensions.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/Matrix4x4Extensions.cs.meta rename to Assets/VRM/Runtime/LookAt/Matrix4x4Extensions.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/OffsetOnTransform.cs b/Assets/VRM/Runtime/LookAt/OffsetOnTransform.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/OffsetOnTransform.cs rename to Assets/VRM/Runtime/LookAt/OffsetOnTransform.cs diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/OffsetOnTransform.cs.meta b/Assets/VRM/Runtime/LookAt/OffsetOnTransform.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/OffsetOnTransform.cs.meta rename to Assets/VRM/Runtime/LookAt/OffsetOnTransform.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAt.cs b/Assets/VRM/Runtime/LookAt/VRMLookAt.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAt.cs rename to Assets/VRM/Runtime/LookAt/VRMLookAt.cs diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAt.cs.meta b/Assets/VRM/Runtime/LookAt/VRMLookAt.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAt.cs.meta rename to Assets/VRM/Runtime/LookAt/VRMLookAt.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtBlendShapeApplyer.cs b/Assets/VRM/Runtime/LookAt/VRMLookAtBlendShapeApplyer.cs similarity index 97% rename from Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtBlendShapeApplyer.cs rename to Assets/VRM/Runtime/LookAt/VRMLookAtBlendShapeApplyer.cs index 252fd9350..b605fbc66 100644 --- a/Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtBlendShapeApplyer.cs +++ b/Assets/VRM/Runtime/LookAt/VRMLookAtBlendShapeApplyer.cs @@ -35,7 +35,7 @@ namespace VRM public void OnImported(VRMImporterContext context) { - var gltfFirstPerson = context.GLTF.extensions.VRM.firstPerson; + var gltfFirstPerson = context.VRM.firstPerson; Horizontal.Apply(gltfFirstPerson.lookAtHorizontalOuter); VerticalDown.Apply(gltfFirstPerson.lookAtVerticalDown); VerticalUp.Apply(gltfFirstPerson.lookAtVerticalUp); diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtBlendShapeApplyer.cs.meta b/Assets/VRM/Runtime/LookAt/VRMLookAtBlendShapeApplyer.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtBlendShapeApplyer.cs.meta rename to Assets/VRM/Runtime/LookAt/VRMLookAtBlendShapeApplyer.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtBoneApplyer.cs b/Assets/VRM/Runtime/LookAt/VRMLookAtBoneApplyer.cs similarity index 98% rename from Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtBoneApplyer.cs rename to Assets/VRM/Runtime/LookAt/VRMLookAtBoneApplyer.cs index 5475dd4d2..9dc050066 100644 --- a/Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtBoneApplyer.cs +++ b/Assets/VRM/Runtime/LookAt/VRMLookAtBoneApplyer.cs @@ -36,7 +36,7 @@ namespace VRM RightEye = OffsetOnTransform.Create(animator.GetBoneTransform(HumanBodyBones.RightEye)); } - var gltfFirstPerson = context.GLTF.extensions.VRM.firstPerson; + var gltfFirstPerson = context.VRM.firstPerson; HorizontalInner.Apply(gltfFirstPerson.lookAtHorizontalInner); HorizontalOuter.Apply(gltfFirstPerson.lookAtHorizontalOuter); VerticalDown.Apply(gltfFirstPerson.lookAtVerticalDown); diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtBoneApplyer.cs.meta b/Assets/VRM/Runtime/LookAt/VRMLookAtBoneApplyer.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtBoneApplyer.cs.meta rename to Assets/VRM/Runtime/LookAt/VRMLookAtBoneApplyer.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtHead.cs b/Assets/VRM/Runtime/LookAt/VRMLookAtHead.cs similarity index 98% rename from Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtHead.cs rename to Assets/VRM/Runtime/LookAt/VRMLookAtHead.cs index e93b8acda..ddbd84110 100644 --- a/Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtHead.cs +++ b/Assets/VRM/Runtime/LookAt/VRMLookAtHead.cs @@ -99,7 +99,7 @@ namespace VRM public void OnImported(VRMImporterContext context) { - var gltfFirstPerson = context.GLTF.extensions.VRM.firstPerson; + var gltfFirstPerson = context.VRM.firstPerson; switch (gltfFirstPerson.lookAtType) { case LookAtType.Bone: diff --git a/Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtHead.cs.meta b/Assets/VRM/Runtime/LookAt/VRMLookAtHead.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/LookAt/VRMLookAtHead.cs.meta rename to Assets/VRM/Runtime/LookAt/VRMLookAtHead.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Meta.meta b/Assets/VRM/Runtime/Meta.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Meta.meta rename to Assets/VRM/Runtime/Meta.meta diff --git a/Assets/VRM/UniVRM/Scripts/Meta/VRMMeta.cs b/Assets/VRM/Runtime/Meta/VRMMeta.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Meta/VRMMeta.cs rename to Assets/VRM/Runtime/Meta/VRMMeta.cs diff --git a/Assets/VRM/UniVRM/Scripts/Meta/VRMMeta.cs.meta b/Assets/VRM/Runtime/Meta/VRMMeta.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Meta/VRMMeta.cs.meta rename to Assets/VRM/Runtime/Meta/VRMMeta.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Meta/VRMMetaInformation.cs b/Assets/VRM/Runtime/Meta/VRMMetaInformation.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Meta/VRMMetaInformation.cs rename to Assets/VRM/Runtime/Meta/VRMMetaInformation.cs diff --git a/Assets/VRM/UniVRM/Scripts/Meta/VRMMetaInformation.cs.meta b/Assets/VRM/Runtime/Meta/VRMMetaInformation.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Meta/VRMMetaInformation.cs.meta rename to Assets/VRM/Runtime/Meta/VRMMetaInformation.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/Meta/VRMMetaObject.cs b/Assets/VRM/Runtime/Meta/VRMMetaObject.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Meta/VRMMetaObject.cs rename to Assets/VRM/Runtime/Meta/VRMMetaObject.cs diff --git a/Assets/VRM/UniVRM/Scripts/Meta/VRMMetaObject.cs.meta b/Assets/VRM/Runtime/Meta/VRMMetaObject.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/Meta/VRMMetaObject.cs.meta rename to Assets/VRM/Runtime/Meta/VRMMetaObject.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility.meta b/Assets/VRM/Runtime/SkinnedMeshUtility.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility.meta rename to Assets/VRM/Runtime/SkinnedMeshUtility.meta diff --git a/Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMBoneNormalizer.cs b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMBoneNormalizer.cs rename to Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs diff --git a/Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMBoneNormalizer.cs.meta b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMBoneNormalizer.cs.meta rename to Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs rename to Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs diff --git a/Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs.meta b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs.meta rename to Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/SpringBone.meta b/Assets/VRM/Runtime/SpringBone.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/SpringBone.meta rename to Assets/VRM/Runtime/SpringBone.meta diff --git a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs b/Assets/VRM/Runtime/SpringBone/VRMSpringBone.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs rename to Assets/VRM/Runtime/SpringBone/VRMSpringBone.cs diff --git a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs.meta b/Assets/VRM/Runtime/SpringBone/VRMSpringBone.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs.meta rename to Assets/VRM/Runtime/SpringBone/VRMSpringBone.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBoneColliderGroup.cs b/Assets/VRM/Runtime/SpringBone/VRMSpringBoneColliderGroup.cs similarity index 100% rename from Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBoneColliderGroup.cs rename to Assets/VRM/Runtime/SpringBone/VRMSpringBoneColliderGroup.cs diff --git a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBoneColliderGroup.cs.meta b/Assets/VRM/Runtime/SpringBone/VRMSpringBoneColliderGroup.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBoneColliderGroup.cs.meta rename to Assets/VRM/Runtime/SpringBone/VRMSpringBoneColliderGroup.cs.meta diff --git a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringUtility.cs b/Assets/VRM/Runtime/SpringBone/VRMSpringUtility.cs similarity index 99% rename from Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringUtility.cs rename to Assets/VRM/Runtime/SpringBone/VRMSpringUtility.cs index 7d71909fe..eb216aa0a 100644 --- a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringUtility.cs +++ b/Assets/VRM/Runtime/SpringBone/VRMSpringUtility.cs @@ -59,7 +59,7 @@ namespace VRM spring.boneGroups.Add ); - File.WriteAllText(path, spring.ToJson()); + // File.WriteAllText(path, spring.ToJson()); } #endregion diff --git a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringUtility.cs.meta b/Assets/VRM/Runtime/SpringBone/VRMSpringUtility.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringUtility.cs.meta rename to Assets/VRM/Runtime/SpringBone/VRMSpringUtility.cs.meta diff --git a/Assets/VRM/VRM.asmdef b/Assets/VRM/Runtime/VRM.asmdef similarity index 84% rename from Assets/VRM/VRM.asmdef rename to Assets/VRM/Runtime/VRM.asmdef index 02098b76f..4b1ba93da 100644 --- a/Assets/VRM/VRM.asmdef +++ b/Assets/VRM/Runtime/VRM.asmdef @@ -2,12 +2,11 @@ "name": "VRM", "references": [ "MToon", - "DepthFirstScheduler", "UniUnlit", "UniHumanoid", - "UniJSON", "ShaderProperty.Runtime", - "MeshUtility" + "MeshUtility", + "UniGLTF" ], "optionalUnityReferences": [], "includePlatforms": [], diff --git a/Assets/VRM/VRM.asmdef.meta b/Assets/VRM/Runtime/VRM.asmdef.meta similarity index 100% rename from Assets/VRM/VRM.asmdef.meta rename to Assets/VRM/Runtime/VRM.asmdef.meta diff --git a/Assets/VRM/UniGLTF/Editor/Tests.meta b/Assets/VRM/Tests.meta similarity index 77% rename from Assets/VRM/UniGLTF/Editor/Tests.meta rename to Assets/VRM/Tests.meta index f4fb4691b..85077658c 100644 --- a/Assets/VRM/UniGLTF/Editor/Tests.meta +++ b/Assets/VRM/Tests.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 13108e3e41e195b40a05e62715bd5a50 +guid: d1e29567ae4a748419ddb2c7d1aebfbc folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/VRM/UniVRM/Editor/Tests/EnumUtilTest.cs b/Assets/VRM/Tests/EnumUtilTest.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/EnumUtilTest.cs rename to Assets/VRM/Tests/EnumUtilTest.cs diff --git a/Assets/VRM/UniVRM/Editor/Tests/EnumUtilTest.cs.meta b/Assets/VRM/Tests/EnumUtilTest.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/EnumUtilTest.cs.meta rename to Assets/VRM/Tests/EnumUtilTest.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Tests/InvalidFileNameTest.cs b/Assets/VRM/Tests/InvalidFileNameTest.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/InvalidFileNameTest.cs rename to Assets/VRM/Tests/InvalidFileNameTest.cs diff --git a/Assets/VRM/UniVRM/Editor/Tests/InvalidFileNameTest.cs.meta b/Assets/VRM/Tests/InvalidFileNameTest.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/InvalidFileNameTest.cs.meta rename to Assets/VRM/Tests/InvalidFileNameTest.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Tests/MeshTests.cs b/Assets/VRM/Tests/MeshTests.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/MeshTests.cs rename to Assets/VRM/Tests/MeshTests.cs diff --git a/Assets/VRM/UniVRM/Editor/Tests/MeshTests.cs.meta b/Assets/VRM/Tests/MeshTests.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/MeshTests.cs.meta rename to Assets/VRM/Tests/MeshTests.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Tests/NormalizeTests.cs b/Assets/VRM/Tests/NormalizeTests.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/NormalizeTests.cs rename to Assets/VRM/Tests/NormalizeTests.cs diff --git a/Assets/VRM/UniVRM/Editor/Tests/NormalizeTests.cs.meta b/Assets/VRM/Tests/NormalizeTests.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/NormalizeTests.cs.meta rename to Assets/VRM/Tests/NormalizeTests.cs.meta diff --git a/Assets/VRM/Tests/UniVRMSerializeTests.cs b/Assets/VRM/Tests/UniVRMSerializeTests.cs new file mode 100644 index 000000000..8809c6826 --- /dev/null +++ b/Assets/VRM/Tests/UniVRMSerializeTests.cs @@ -0,0 +1,549 @@ +using NUnit.Framework; +using System; +using System.Collections.Generic; +using UniGLTF; +using UniJSON; +using UnityEngine; + +namespace VRM +{ + static class ToJsonExtensions + { + public static string ToJson(this glTF self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize(f, self); + return f.ToString(); + } + public static string ToJson(this glTFMesh self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_meshes_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTFPrimitives self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_meshes__primitives_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTFAttributes self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_meshes__primitives__attributes(f, self); + return f.ToString(); + } + public static string ToJson(this glTFMaterialBaseColorTextureInfo self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(f, self); + return f.ToString(); + } + public static string ToJson(this glTFMaterial self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_materials_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTFNode self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_nodes_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTFSkin self) + { + var f = new JsonFormatter(); + GltfSerializer.Serialize_gltf_skins_ITEM(f, self); + return f.ToString(); + } + + public static string ToJson(this glTF_VRM_MaterialValueBind self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTF_VRM_BlendShapeBind self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_blendShapeMaster_blendShapeGroups__binds_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTF_VRM_BlendShapeGroup self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_blendShapeMaster_blendShapeGroups_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTF_VRM_DegreeMap self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_firstPerson_lookAtHorizontalInner(f, self); + return f.ToString(); + } + public static string ToJson(this glTF_VRM_MeshAnnotation self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_firstPerson_meshAnnotations_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTF_VRM_Firstperson self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_firstPerson(f, self); + return f.ToString(); + } + public static string ToJson(this glTF_VRM_HumanoidBone self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_humanoid_humanBones_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTF_VRM_Humanoid self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_humanoid(f, self); + return f.ToString(); + } + public static string ToJson(this glTF_VRM_Material self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_materialProperties_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTF_VRM_Meta self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_meta(f, self); + return f.ToString(); + } + public static string ToJson(this glTF_VRM_SecondaryAnimationCollider self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_secondaryAnimation_colliderGroups__colliders_ITEM(f, self); + return f.ToString(); + } + public static string ToJson(this glTF_VRM_SecondaryAnimationColliderGroup self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_secondaryAnimation_colliderGroups_ITEM(f, self); + return f.ToString(); + } + + public static string ToJson(this glTF_VRM_SecondaryAnimationGroup self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_secondaryAnimation_boneGroups_ITEM(f, self); + return f.ToString(); + } + + public static string ToJson(this glTF_VRM_SecondaryAnimation self) + { + var f = new JsonFormatter(); + VRMSerializer.Serialize_vrm_secondaryAnimation(f, self); + return f.ToString(); + } + } + + public class UniVRMSerializeTests + { + [Test] + public void MaterialValueBindTest() + { + var model = new glTF_VRM_MaterialValueBind(); + + var json = model.ToJson(); + Assert.AreEqual(@"{}", json); + Debug.Log(json); + } + + [Test] + public void BlendShapeBindTest() + { + var model = new glTF_VRM_BlendShapeBind() + { + mesh = 1, + weight = 2, + index = 3, + }; + + var json = model.ToJson(); + Assert.AreEqual(@"{""mesh"":1,""index"":3,""weight"":2}", json); + Debug.Log(json); + } + + [Test] + public void BlendShapeBindTestError() + { + var model = new glTF_VRM_BlendShapeBind(); + } + + [Test] + public void BlendShapeGroupTest() + { + var model = new glTF_VRM_BlendShapeGroup() + { + presetName = "neutral", + }; + + var json = model.ToJson(); + Assert.AreEqual(@"{""presetName"":""neutral"",""binds"":[],""materialValues"":[],""isBinary"":false}", json); + Debug.Log(json); + } + + [Test] + public void BlendShapeGroupTestError() + { + var model = new glTF_VRM_BlendShapeGroup() + { + presetName = "aaaaaaaaaaaa_not_exists_", + }; + } + + [Test] + public void DegreeMapTest() + { + var model = new glTF_VRM_DegreeMap(); + + var json = model.ToJson(); + Assert.AreEqual(@"{""xRange"":90,""yRange"":10}", json); + Debug.Log(json); + } + + [Test] + public void MeshAnnotationTest() + { + var model = new glTF_VRM_MeshAnnotation(); + + var json = model.ToJson(); + Assert.AreEqual(@"{""mesh"":0}", json); + Debug.Log(json); + } + + [Test] + public void FirstPersonTest() + { + var model = new glTF_VRM_Firstperson(); + + var json = model.ToJson(); + Assert.AreEqual( + @"{""firstPersonBoneOffset"":{""x"":0,""y"":0,""z"":0},""meshAnnotations"":[],""lookAtTypeName"":""Bone"",""lookAtHorizontalInner"":{""xRange"":90,""yRange"":10},""lookAtHorizontalOuter"":{""xRange"":90,""yRange"":10},""lookAtVerticalDown"":{""xRange"":90,""yRange"":10},""lookAtVerticalUp"":{""xRange"":90,""yRange"":10}}", + json); + Debug.Log(json); + } + + [Test] + public void HumanoidBoneTest() + { + var model = new glTF_VRM_HumanoidBone() + { + bone = "hips", // NOTE: This field must not be null? + node = 0, + }; + + var json = model.ToJson(); + Assert.AreEqual(@"{""bone"":""hips"",""node"":0,""useDefaultValues"":true}", json); + Debug.Log(json); + } + + [Test] + public void HumanoidBoneTestError() + { + var model = new glTF_VRM_HumanoidBone() + { + bone = "hips", // NOTE: This field must not be null? + }; + } + + [Test] + public void HumanoidTest() + { + var model = new glTF_VRM_Humanoid(); + + var json = model.ToJson(); + Assert.AreEqual(@"{""humanBones"":[],""armStretch"":0.05,""legStretch"":0.05,""upperArmTwist"":0.5,""lowerArmTwist"":0.5,""upperLegTwist"":0.5,""lowerLegTwist"":0.5,""feetSpacing"":0,""hasTranslationDoF"":false}", json); + Debug.Log(json); + } + + [Test] + public void MaterialTest() + { + var model = new glTF_VRM_Material + { + floatProperties = new Dictionary + { + {"float", 1.0f} + }, + vectorProperties = new Dictionary + { + {"vector", new float[]{0, 1, 2, 3 }} + }, + textureProperties = new Dictionary + { + {"texture", 0} + }, + keywordMap = new Dictionary + { + {"keyword", true} + }, + tagMap = new Dictionary + { + {"tag", "map"} + }, + }; + + var json = model.ToJson(); + Assert.AreEqual(@"{""renderQueue"":-1,""floatProperties"":{""float"":1},""vectorProperties"":{""vector"":[0,1,2,3]},""textureProperties"":{""texture"":0},""keywordMap"":{""keyword"":true},""tagMap"":{""tag"":""map""}}", json); + Debug.Log(json); + } + + [Test] + public void MetaTest() + { + var model = new glTF_VRM_Meta() + { + allowedUserName = "OnlyAuthor", + violentUssageName = "Disallow", + sexualUssageName = "Disallow", + commercialUssageName = "Disallow", + licenseName = "CC0", + }; + + var json = model.ToJson(); + Assert.AreEqual(@"{""allowedUserName"":""OnlyAuthor"",""violentUssageName"":""Disallow"",""sexualUssageName"":""Disallow"",""commercialUssageName"":""Disallow"",""licenseName"":""CC0""}", json); + Debug.Log(json); + } + + [Test] + public void MetaTestError() + { + { + var model = new glTF_VRM_Meta() + { + allowedUserName = null, + violentUssageName = null, + sexualUssageName = null, + commercialUssageName = null, + }; + } + + { + var model = new glTF_VRM_Meta() + { + allowedUserName = "OnlyAuthor", + violentUssageName = "Disallow", + sexualUssageName = "Disallow", + commercialUssageName = "Disallow", + //licenseName = "CC0", + licenseName = null, + }; + } + + { + var model = new glTF_VRM_Meta() + { + allowedUserName = "OnlyAuthor", + violentUssageName = "Disallow", + sexualUssageName = "Disallow", + commercialUssageName = "Disallow", + licenseName = "_INVALID_SOME_THING_", + }; + } + + { + var model = new glTF_VRM_Meta() + { + // allowedUserName = "OnlyAuthor", + allowedUserName = null, + violentUssageName = "Disallow", + sexualUssageName = "Disallow", + commercialUssageName = "Disallow", + licenseName = "CC0", + }; + } + + { + var model = new glTF_VRM_Meta() + { + allowedUserName = "_INVALID_SOME_THING_", + violentUssageName = "Disallow", + sexualUssageName = "Disallow", + commercialUssageName = "Disallow", + licenseName = "CC0", + }; + } + + { + var model = new glTF_VRM_Meta() + { + allowedUserName = "OnlyAuthor", + //violentUssageName = "Disallow", + violentUssageName = null, + sexualUssageName = "Disallow", + commercialUssageName = "Disallow", + licenseName = "CC0", + }; + } + + { + var model = new glTF_VRM_Meta() + { + allowedUserName = "OnlyAuthor", + violentUssageName = "_INVALID_SOME_THING_", + sexualUssageName = "Disallow", + commercialUssageName = "Disallow", + licenseName = "CC0", + }; + } + + { + var model = new glTF_VRM_Meta() + { + allowedUserName = "OnlyAuthor", + violentUssageName = "Disallow", + //sexualUssageName = "Disallow", + sexualUssageName = null, + commercialUssageName = "Disallow", + licenseName = "CC0", + }; + } + + { + var model = new glTF_VRM_Meta() + { + allowedUserName = "OnlyAuthor", + violentUssageName = "Disallow", + sexualUssageName = "_INVALID_SOME_THING_", + commercialUssageName = "Disallow", + licenseName = "CC0", + }; + } + + { + var model = new glTF_VRM_Meta() + { + allowedUserName = "OnlyAuthor", + violentUssageName = "Disallow", + sexualUssageName = "Disallow", + //commercialUssageName = "Disallow", + commercialUssageName = null, + licenseName = "CC0", + }; + } + + { + var model = new glTF_VRM_Meta() + { + allowedUserName = "OnlyAuthor", + violentUssageName = "Disallow", + sexualUssageName = "Disallow", + commercialUssageName = "_INVALID_SOME_THING_", + licenseName = "CC0", + }; + } + } + + // TODO: Move to another suitable location + [Test] + public void MetaDeserializeTest() + { + var json = @"{}"; + + var model = deserialize(json); + + Assert.AreEqual(-1, model.texture); + } + + [Test] + public void SecondaryAnimationColliderTest() + { + var model = new glTF_VRM_SecondaryAnimationCollider() + { + offset = new Vector3(1, 2, 3), + radius = 42, + }; + + var json = model.ToJson(); + Assert.AreEqual(@"{""offset"":{""x"":1,""y"":2,""z"":3},""radius"":42}", json); + Debug.Log(json); + } + + [Test] + public void SecondaryAnimationColliderGroupTest() + { + var model = new glTF_VRM_SecondaryAnimationColliderGroup(); + + var json = model.ToJson(); + Assert.AreEqual(@"{""node"":0,""colliders"":[]}", json); + Debug.Log(json); + } + + [Test] + public void SecondaryAnimationColliderGroupTestError() + { + var model = new glTF_VRM_SecondaryAnimationColliderGroup() + { + node = -1, + }; + } + + [Test] + public void SecondaryAnimationGroupTest() + { + var model = new glTF_VRM_SecondaryAnimationGroup(); + + var json = model.ToJson(); + Assert.AreEqual(@"{""stiffiness"":0,""gravityPower"":0,""gravityDir"":{""x"":0,""y"":0,""z"":0},""dragForce"":0,""center"":0,""hitRadius"":0,""bones"":[],""colliderGroups"":[]}", json); + Debug.Log(json); + } + + [Test] + public void SecondaryAnimationGroupTestErrorBones() + { + var model = new glTF_VRM_SecondaryAnimationGroup() + { + bones = new int[] { -1 } + }; + } + + [Test] + public void SecondaryAnimationGroupTestErrorColliderGroups() + { + var model = new glTF_VRM_SecondaryAnimationGroup() + { + colliderGroups = new int[] { -1 } + }; + } + + [Test] + public void SecondaryAnimationTest() + { + var model = new glTF_VRM_SecondaryAnimation(); + + var json = model.ToJson(); + Assert.AreEqual(@"{""boneGroups"":[],""colliderGroups"":[]}", json); + Debug.Log(json); + } + + [Test] + public void ExtensionsTest() + { + var model = new glTF_VRM_extensions() + { + meta = null, + humanoid = null, + firstPerson = null, + blendShapeMaster = null, + secondaryAnimation = null, + materialProperties = null, + }; + } + + // TODO: Move to another suitable location + T deserialize(string json) + { + return JsonUtility.FromJson(json); + } + } +} diff --git a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs.meta b/Assets/VRM/Tests/UniVRMSerializeTests.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs.meta rename to Assets/VRM/Tests/UniVRMSerializeTests.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Tests/UniVRM.Editor.Tests.asmdef b/Assets/VRM/Tests/VRM.Tests.asmdef similarity index 83% rename from Assets/VRM/UniVRM/Editor/Tests/UniVRM.Editor.Tests.asmdef rename to Assets/VRM/Tests/VRM.Tests.asmdef index d8e3c96eb..b6e97659c 100644 --- a/Assets/VRM/UniVRM/Editor/Tests/UniVRM.Editor.Tests.asmdef +++ b/Assets/VRM/Tests/VRM.Tests.asmdef @@ -1,9 +1,8 @@ { - "name": "UniVRM.Editor.Tests", + "name": "VRM.Tests", "references": [ "VRM", - "UniJSON", - "UniVRM.Editor", + "UniGLTF", "MeshUtility", "MeshUtility.Editor" ], diff --git a/Assets/VRM/DepthFirstScheduler/DepthFirstScheduler.asmdef.meta b/Assets/VRM/Tests/VRM.Tests.asmdef.meta similarity index 76% rename from Assets/VRM/DepthFirstScheduler/DepthFirstScheduler.asmdef.meta rename to Assets/VRM/Tests/VRM.Tests.asmdef.meta index 57a5b232f..00c256db0 100644 --- a/Assets/VRM/DepthFirstScheduler/DepthFirstScheduler.asmdef.meta +++ b/Assets/VRM/Tests/VRM.Tests.asmdef.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3c1b656429ea86147a4d76b21be3f0c0 +guid: 0eadcadee644f4e4cb96f0c11df10d89 AssemblyDefinitionImporter: externalObjects: {} userData: diff --git a/Assets/VRM/UniVRM/Editor/Tests/VRMBlendShapeKeyTest.cs b/Assets/VRM/Tests/VRMBlendShapeKeyTest.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/VRMBlendShapeKeyTest.cs rename to Assets/VRM/Tests/VRMBlendShapeKeyTest.cs diff --git a/Assets/VRM/UniVRM/Editor/Tests/VRMBlendShapeKeyTest.cs.meta b/Assets/VRM/Tests/VRMBlendShapeKeyTest.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/VRMBlendShapeKeyTest.cs.meta rename to Assets/VRM/Tests/VRMBlendShapeKeyTest.cs.meta diff --git a/Assets/VRM/UniVRM/Editor/Tests/VersionTests.cs b/Assets/VRM/Tests/VersionTests.cs similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/VersionTests.cs rename to Assets/VRM/Tests/VersionTests.cs diff --git a/Assets/VRM/UniVRM/Editor/Tests/VersionTests.cs.meta b/Assets/VRM/Tests/VersionTests.cs.meta similarity index 100% rename from Assets/VRM/UniVRM/Editor/Tests/VersionTests.cs.meta rename to Assets/VRM/Tests/VersionTests.cs.meta diff --git a/Assets/VRM/UniGLTF.meta b/Assets/VRM/UniGLTF.meta deleted file mode 100644 index 67e104771..000000000 --- a/Assets/VRM/UniGLTF.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 4af88ce26d18bd74fb51e2ce9db6da1d -folderAsset: yes -timeCreated: 1521016767 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor.meta b/Assets/VRM/UniGLTF/Editor.meta deleted file mode 100644 index 5bb625d2a..000000000 --- a/Assets/VRM/UniGLTF/Editor.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: d3f12e850b80b874da5050c9599b8abc -folderAsset: yes -timeCreated: 1521096862 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/Serialization.meta b/Assets/VRM/UniGLTF/Editor/Serialization.meta deleted file mode 100644 index 0101c4e43..000000000 --- a/Assets/VRM/UniGLTF/Editor/Serialization.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 43be0cf78be61614cb840cb906de4275 -folderAsset: yes -timeCreated: 1565252168 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/CollectionSerialization.cs b/Assets/VRM/UniGLTF/Editor/Serialization/CollectionSerialization.cs deleted file mode 100644 index 0dbcf723a..000000000 --- a/Assets/VRM/UniGLTF/Editor/Serialization/CollectionSerialization.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.IO; - -namespace UniGLTF -{ - public class ArraySerialization : FunctionSerializationBase - { - IValueSerialization m_inner; - - public ArraySerialization(Type t, IValueSerialization inner) - { - ValueType = t; - m_inner = inner; - } - public override void GenerateDeserializer(StreamWriter writer, string callName) - { - var itemCallName = callName + "_ARRAY"; - - writer.Write(@" -public static $0 $2(ListTreeNode parsed) -{ - var value = new $1[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = $3; - } - return value; -} -" -.Replace("$0", UniJSON.JsonSchemaAttribute.GetTypeName(ValueType)) -.Replace("$1", m_inner.ValueType.Name) -.Replace("$2", callName) -.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "x")) -); - - if (!m_inner.IsInline) - { - m_inner.GenerateDeserializer(writer, itemCallName); - } - } - } - - public class ListSerialization : FunctionSerializationBase - { - IValueSerialization m_inner; - - public ListSerialization(Type t, IValueSerialization inner) - { - ValueType = t; - m_inner = inner; - } - public override void GenerateDeserializer(StreamWriter writer, string callName) - { - var itemCallName = callName + "_LIST"; - writer.Write(@" -public static $0 $2(ListTreeNode parsed) -{ - var value = new List<$1>(); - foreach(var x in parsed.ArrayItems()) - { - value.Add($3); - } - return value; -}" -.Replace("$0", UniJSON.JsonSchemaAttribute.GetTypeName(ValueType)) -.Replace("$1", m_inner.ValueType.Name) -.Replace("$2", callName) -.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "x")) -); - - if (!m_inner.IsInline) - { - m_inner.GenerateDeserializer(writer, itemCallName); - } - } - } - - public class StringKeyDictionarySerialization : FunctionSerializationBase - { - IValueSerialization m_inner; - - public StringKeyDictionarySerialization(Type t, IValueSerialization inner) - { - ValueType = t; - m_inner = inner; - } - public override void GenerateDeserializer(StreamWriter writer, string callName) - { - var itemCallName = callName + "_DICT"; - writer.Write(@" - -public static $0 $2(ListTreeNode parsed) -{ - var value = new Dictionary(); - foreach(var kv in parsed.ObjectItems()) - { - value.Add(kv.Key.GetString(), $3); - } - return value; -} -" -.Replace("$0", UniJSON.JsonSchemaAttribute.GetTypeName(ValueType)) -.Replace("$1", m_inner.ValueType.Name) -.Replace("$2", callName) -.Replace("$3", m_inner.GenerateDeserializerCall(itemCallName, "kv.Value")) -); - - if (!m_inner.IsInline) - { - m_inner.GenerateDeserializer(writer, itemCallName); - } - } - } -} \ No newline at end of file diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/ObjectSerialization.cs b/Assets/VRM/UniGLTF/Editor/Serialization/ObjectSerialization.cs deleted file mode 100644 index 6f9d20da8..000000000 --- a/Assets/VRM/UniGLTF/Editor/Serialization/ObjectSerialization.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Text; - -namespace UniGLTF -{ - public abstract class FunctionSerializationBase : IValueSerialization - { - public Type ValueType - { - get; - protected set; - } - - public bool IsInline - { - get { return false; } - } - - public abstract void GenerateDeserializer(StreamWriter writer, string callName); - - public string GenerateDeserializerCall(string callName, string argName) - { - return string.Format("{0}({1})", callName, argName); - } - } - - public class ObjectSerialization : FunctionSerializationBase - { - string m_path; - FieldSerializationInfo[] m_fsi; - - public ObjectSerialization(Type t, string path) - { - ValueType = t; - m_path = path; - m_fsi = t.GetFields(DeserializerGenerator.FIELD_FLAGS) - .Where(x => - { - if (x.FieldType == typeof(object)) - { - // object. coannot serialize - return false; - } - if (x.IsLiteral && !x.IsInitOnly) - { - // const - return false; - } - return true; - }) - .Select(x => - { - return new FieldSerializationInfo(x, path); - }).ToArray(); - } - - public override string ToString() - { - var sb = new StringBuilder(); - foreach (var x in m_fsi) - { - sb.Append(x.ToString()); - } - return sb.ToString(); - } - - public override void GenerateDeserializer(StreamWriter writer, string parentName) - { - writer.Write(@" -public static $0 $2(ListTreeNode parsed) -{ - var value = new $0(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); -" -.Replace("$0", ValueType.Name) -.Replace("$2", parentName) -); - - foreach (var f in m_fsi) - { - writer.Write(@" - if(key==""$0""){ - value.$0 = $1; - continue; - } -" -.Replace("$0", f.Name) -.Replace("$1", f.Serialization.GenerateDeserializerCall(f.FunctionName, "kv.Value")) -); - } - - writer.Write(@" - } - return value; -} -"); - - foreach (var f in m_fsi) - { - if (!f.Serialization.IsInline) - { - f.Serialization.GenerateDeserializer(writer, f.FunctionName); - } - } - } - } -} diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs deleted file mode 100644 index 25237cfd4..000000000 --- a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs +++ /dev/null @@ -1,330 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text; -using UniJSON; -using UnityEditor; -using UnityEngine; - -namespace UniGLTF -{ - public static class SerializerGenerator - { - const BindingFlags FIELD_FLAGS = BindingFlags.Instance | BindingFlags.Public; - - static string OutPath - { - get - { - return Path.Combine(UnityEngine.Application.dataPath, - "VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs"); - } - } - - /// - /// AOT向けにシリアライザを生成する - /// - [MenuItem(VRM.VRMVersion.MENU + "/Generate Serializer")] - static void GenerateSerializer() - { - var path = OutPath; - - using (var g = new Generator(path)) - { - var rootType = typeof(glTF); - g.Generate(rootType, "gltf"); - } - } - - class Generator : IDisposable - { - String m_path; - Stream m_s; - StreamWriter m_w; - - static Dictionary s_snippets = new Dictionary - { - {"gltf/animations", "if(value.animations!=null && value.animations.Count>0)" }, - {"gltf/cameras", "if(value.cameras!=null && value.cameras.Count>0)" }, - {"gltf/buffers", "if(value.buffers!=null && value.buffers.Count>0)" }, - {"gltf/bufferViews", "if(value.bufferViews!=null && value.bufferViews.Count>0)" }, - {"gltf/bufferViews[]/byteStride", "" }, - {"gltf/bufferViews[]/target", "if(value.target!=0)" }, - {"gltf/animations[]/channels", "if(value.channels!=null && value.channels.Count>0)" }, - {"gltf/animations[]/channels[]/target", "if(value!=null)" }, - {"gltf/animations[]/samplers", "if(value.samplers!=null && value.samplers.Count>0)" }, - {"gltf/accessors", "if(value.accessors!=null && value.accessors.Count>0)" }, - {"gltf/accessors[]/max", "if(value.max!=null && value.max.Length>0)"}, - {"gltf/accessors[]/min", "if(value.min!=null && value.min.Length>0)"}, - {"gltf/accessors[]/sparse", "if(value.sparse!=null && value.sparse.count>0)"}, - {"gltf/accessors[]/bufferView", "if(value.bufferView>=0)"}, - {"gltf/accessors[]/byteOffset", "if(value.bufferView>=0)"}, - - {"gltf/images", "if(value.images!=null && value.images.Count>0)" }, - - {"gltf/meshes", "if(value.meshes!=null && value.meshes.Count>0)" }, - {"gltf/meshes[]/primitives", "if(value.primitives!=null && value.primitives.Count>0)" }, - {"gltf/meshes[]/primitives[]/targets", "if(value.targets!=null && value.targets.Count>0)" }, - - {"gltf/meshes[]/primitives[]/targets[]/POSITION", "if(value.POSITION!=-1)" }, - {"gltf/meshes[]/primitives[]/targets[]/NORMAL", "if(value.NORMAL!=-1)" }, - {"gltf/meshes[]/primitives[]/targets[]/TANGENT", "if(value.TANGENT!=-1)" }, - - {"gltf/meshes[]/primitives[]/attributes/POSITION", "if(value.POSITION!=-1)"}, - {"gltf/meshes[]/primitives[]/attributes/NORMAL", "if(value.NORMAL!=-1)"}, - {"gltf/meshes[]/primitives[]/attributes/TANGENT", "if(value.TANGENT!=-1)"}, - {"gltf/meshes[]/primitives[]/attributes/TEXCOORD_0", "if(value.TEXCOORD_0!=-1)"}, - {"gltf/meshes[]/primitives[]/attributes/TEXCOORD_1", "if(value.TEXCOORD_1!=-1)"}, - {"gltf/meshes[]/primitives[]/attributes/COLOR_0", "if(value.COLOR_0!=-1)"}, - {"gltf/meshes[]/primitives[]/attributes/JOINTS_0", "if(value.JOINTS_0!=-1)"}, - {"gltf/meshes[]/primitives[]/attributes/WEIGHTS_0", "if(value.WEIGHTS_0!=-1)"}, - - {"gltf/meshes[]/primitives[]/extras", "if(value.extras!=null && value.extras.targetNames!=null && value.extras.targetNames.Count>0)"}, - {"gltf/meshes[]/weights", "if(value.weights!=null && value.weights.Length>0)" }, - {"gltf/materials", "if(value.materials!=null && value.materials.Count>0)" }, - {"gltf/materials[]/alphaCutoff", "if(value.alphaMode == \"MASK\")" }, - {"gltf/nodes", "if(value.nodes!=null && value.nodes.Count>0)" }, - {"gltf/nodes[]/camera", "if(value.camera!=-1)"}, - {"gltf/nodes[]/mesh", "if(value.mesh!=-1)"}, - {"gltf/nodes[]/skin", "if(value.skin!=-1)"}, - {"gltf/nodes[]/children", "if(value.children != null && value.children.Length>0)"}, - {"gltf/samplers", "if(value.samplers!=null && value.samplers.Count>0)" }, - {"gltf/scenes", "if(value.scenes!=null && value.scenes.Count>0)" }, - {"gltf/scenes[]/nodes", "if(value.nodes!=null && value.nodes.Length>0)" }, - {"gltf/skins", "if(value.skins!=null && value.skins.Count>0)" }, - {"gltf/skins[]/skeleton", "if(value.skeleton!=-1)"}, - {"gltf/skins[]/joints", "if(value.joints!=null && value.joints.Length>0)"}, - {"gltf/extensionsUsed", "if(value.extensionsUsed!=null && value.extensionsUsed.Count>0)"}, // dummy - {"gltf/extensionsRequired", "if(false && value.extensionsRequired!=null && value.extensionsRequired.Count>0)"}, - {"gltf/extensions/VRM/humanoid/humanBones[]/axisLength", "if(value.axisLength>0)"}, - {"gltf/extensions/VRM/humanoid/humanBones[]/center", "if(value.center!=Vector3.zero)"}, - {"gltf/extensions/VRM/humanoid/humanBones[]/max", "if(value.max!=Vector3.zero)"}, - {"gltf/extensions/VRM/humanoid/humanBones[]/min", "if(value.min!=Vector3.zero)"}, - {"gltf/textures", "if(value.textures!=null && value.textures.Count>0)" }, - }; - - public Generator(string path) - { - m_path = path; - m_s = File.Open(path, FileMode.Create); - m_w = new StreamWriter(m_s, Encoding.UTF8); - - // begin - m_w.Write(@" -using System; -using System.Collections.Generic; -using UniJSON; -using UnityEngine; -using VRM; - -namespace UniGLTF { - - static public class IFormatterExtensionsGltf - { - -"); - } - - public void Dispose() - { - // end - m_w.Write(@" - } // class -} // namespace -"); - - m_w.Dispose(); - m_s.Dispose(); - UnityPath.FromFullpath(m_path).ImportAsset(); - } - - HashSet m_used = new HashSet - { - typeof(object), - }; - - public void Generate(Type t, string path, int level = 0) - { - if (m_used.Contains(t)) - { - // 処理済み - return; - } - m_used.Add(t); - - // primitive - try - { - var mi = typeof(IFormatter).GetMethod("Value", new Type[] { t }); - if (mi != null) - { - m_w.Write(@" - public static void GenSerialize(this IFormatter f, $0 value) - { - f.Value(value); - } -".Replace("$0", t.Name)); - - return; - } - } - catch (AmbiguousMatchException) - { - // skip - } - - if (t.IsEnum) - { - m_w.Write(@" - public static void GenSerialize(this IFormatter f, $0 value) - { - f.Value((int)value); - } -".Replace("$0", t.Name)); - } - else if (t.IsArray) - { - var et = t.GetElementType(); - m_w.Write(@" - /// $1 - public static void GenSerialize(this IFormatter f, $0[] value) - { - f.BeginList(value.Length); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - " - .Replace("$0", et.Name) - .Replace("$1", path) - ); - Generate(et, path + "[]", level + 1); - } - else if (t.IsGenericType) - { - if (t.GetGenericTypeDefinition() == typeof(List<>)) - { - var et = t.GetGenericArguments()[0]; - m_w.Write(@" - /// $1 - public static void GenSerialize(this IFormatter f, List<$0> value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } -" -.Replace("$0", et.Name) -.Replace("$1", path)); - Generate(et, path + "[]", level + 1); - } - else if (t.GetGenericTypeDefinition() == typeof(Dictionary<,>) - && t.GetGenericArguments()[0] == typeof(string)) - { - var et = t.GetGenericArguments()[1]; - m_w.Write(@" - /// $1 - public static void GenSerialize(this IFormatter f, Dictionary value) - { - f.BeginMap(value.Count); - foreach (var kv in value) - { - f.Key(kv.Key); - f.GenSerialize(kv.Value); - } - f.EndMap(); - } - -" -.Replace("$0", et.Name) -.Replace("$1", path)); - Generate(et, path + "{}", level + 1); - } - else - { - Debug.LogWarningFormat("unknown type: {0}", t); - } - } - else - { - Debug.LogFormat("{0}({1})", path, t.Name); - - m_w.Write(@" - /// $1 - public static void GenSerialize(this IFormatter f, $0 value) - { - f.BeginMap(0); // dummy -" -.Replace("$0", t.Name) -.Replace("$1", path) -); - - foreach (var fi in t.GetFields(FIELD_FLAGS)) - { - if (fi.FieldType == typeof(object)) - { - continue; - } - if (fi.IsLiteral && !fi.IsInitOnly) - { - continue; - } - if (fi.FieldType == typeof(string) || fi.FieldType.IsEnum || fi.FieldType.IsArray || fi.FieldType.IsGenericType) - { - - } - else if (fi.FieldType == typeof(glTF_KHR_materials_unlit)) - { - - } - else if (fi.FieldType.IsClass && fi.FieldType.GetFields(FIELD_FLAGS).Length == 0) - { - continue; - } - - var snipet = fi.FieldType.IsClass ? "if(value." + fi.Name + "!=null)" : ""; - var value = default(string); - if (s_snippets.TryGetValue(path + "/" + fi.Name, out value)) - { - snipet = value; - } - - if (value == "") - { - // found, but empty - } - else - { - m_w.Write(@" - $1 - { - f.Key(""$0""); f.GenSerialize(value.$0); - } -" - .Replace("$0", fi.Name) - .Replace("$1", snipet) - ); - } - } - - m_w.Write(@" - f.EndMap(); - } -"); - - foreach (var fi in t.GetFields(FIELD_FLAGS)) - { - Generate(fi.FieldType, path + "/" + fi.Name, level + 1); - } - } - } - } - } -} diff --git a/Assets/VRM/UniGLTF/Editor/Tests/JsonDeserializeTests.cs b/Assets/VRM/UniGLTF/Editor/Tests/JsonDeserializeTests.cs deleted file mode 100644 index e056df6f6..000000000 --- a/Assets/VRM/UniGLTF/Editor/Tests/JsonDeserializeTests.cs +++ /dev/null @@ -1,36 +0,0 @@ -using NUnit.Framework; -using UnityEngine; - -namespace UniGLTF -{ - public class JsonDeserializeTests - { - static T deserialize(string json) - { - return JsonUtility.FromJson(json); - } - - [Test] - public void PrimitivesExtensionsTest() - { - { - var r = deserialize(""); - Assert.AreEqual(null, r); - } - - { - var r = deserialize("{}"); - Assert.NotNull(r); - // This is a curious behaviour of JsonUtility. - // TODO: We should replace a library which treats JSON from JsonUtility - //Assert.Null(r.KHR_draco_mesh_compression); - } - - { - var r = deserialize("{\"KHR_draco_mesh_compression\":{}}"); - Assert.NotNull(r); - //Assert.NotNull(r.KHR_draco_mesh_compression); - } - } - } -} diff --git a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTF.Editor.Tests.asmdef b/Assets/VRM/UniGLTF/Editor/Tests/UniGLTF.Editor.Tests.asmdef deleted file mode 100644 index 55dedf4d2..000000000 --- a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTF.Editor.Tests.asmdef +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "UniGLTF.Editor.Tests", - "references": [ - "VRM", - "UniJSON" - ], - "optionalUnityReferences": [ - "TestAssemblies" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false -} \ No newline at end of file diff --git a/Assets/VRM/UniGLTF/Editor/UniGLTFVersionMenu.cs b/Assets/VRM/UniGLTF/Editor/UniGLTFVersionMenu.cs deleted file mode 100644 index 20579b3da..000000000 --- a/Assets/VRM/UniGLTF/Editor/UniGLTFVersionMenu.cs +++ /dev/null @@ -1,45 +0,0 @@ -#if VRM_DEVELOP -using System.Collections.Generic; -using System.IO; -using System.Linq; -using UnityEditor; - - -namespace UniGLTF -{ - public static class UniGLTFVersionMenu - { - public const int MENU_PRIORITY = 99; - static string path = "Assets/UniGLTF/Core/Scripts/UniGLTFVersion.cs"; - - const string template = @" -namespace UniGLTF -{{ - public static partial class UniGLTFVersion - {{ - public const int MAJOR = {0}; - public const int MINOR = {1}; - - public const string VERSION = ""{0}.{1}""; - }} -}} -"; - - [MenuItem(UniGLTFVersion.MENU + "/Increment", priority = MENU_PRIORITY)] - public static void IncrementVersion() - { - var source = string.Format(template, UniGLTFVersion.MAJOR, UniGLTFVersion.MINOR + 1); - File.WriteAllText(path, source); - AssetDatabase.Refresh(); - } - - [MenuItem(UniGLTFVersion.MENU + "/Decrement", priority = MENU_PRIORITY)] - public static void DecrementVersion() - { - var source = string.Format(template, UniGLTFVersion.MAJOR, UniGLTFVersion.MINOR - 1); - File.WriteAllText(path, source); - AssetDatabase.Refresh(); - } - } -} -#endif diff --git a/Assets/VRM/UniGLTF/Resources.meta b/Assets/VRM/UniGLTF/Resources.meta deleted file mode 100644 index e07979f1d..000000000 --- a/Assets/VRM/UniGLTF/Resources.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: afa37238f2d665b4aba57a3e1714150d -folderAsset: yes -timeCreated: 1528270766 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Resources/Shaders.meta b/Assets/VRM/UniGLTF/Resources/Shaders.meta deleted file mode 100644 index 0f72a33c5..000000000 --- a/Assets/VRM/UniGLTF/Resources/Shaders.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: cbb764710ae3737458696a3ab5a85d14 -folderAsset: yes -timeCreated: 1528269714 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/Extensions/JsonParserExtensions.cs b/Assets/VRM/UniGLTF/Scripts/Extensions/JsonParserExtensions.cs deleted file mode 100644 index 2163a4204..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Extensions/JsonParserExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Linq; -using UnityEngine; -using System.Collections.Generic; - - -namespace UniJSON -{ - public static class JsonParserExtensions - { - public static List DeserializeList(this ListTreeNode jsonList) - { - return jsonList.ArrayItems().Select(x => { - - return JsonUtility.FromJson(new Utf8String(x.Value.Bytes).ToString()); - - }).ToList(); - } - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Extensions/glTFExtensions.cs b/Assets/VRM/UniGLTF/Scripts/Extensions/glTFExtensions.cs deleted file mode 100644 index ffe895ace..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Extensions/glTFExtensions.cs +++ /dev/null @@ -1,203 +0,0 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using UnityEngine; - - -namespace UniGLTF -{ - [Serializable, StructLayout(LayoutKind.Sequential, Pack = 1)] - struct UShort4 - { - public ushort x; - public ushort y; - public ushort z; - public ushort w; - - public UShort4(ushort _x, ushort _y, ushort _z, ushort _w) - { - x = _x; - y = _y; - z = _z; - w = _w; - } - } - - public static class glTFExtensions - { - struct ComponentVec - { - public glComponentType ComponentType; - public int ElementCount; - - public ComponentVec(glComponentType componentType, int elementCount) - { - ComponentType = componentType; - ElementCount = elementCount; - } - } - - static Dictionary ComponentTypeMap = new Dictionary - { - { typeof(Vector2), new ComponentVec(glComponentType.FLOAT, 2) }, - { typeof(Vector3), new ComponentVec(glComponentType.FLOAT, 3) }, - { typeof(Vector4), new ComponentVec(glComponentType.FLOAT, 4) }, - { typeof(UShort4), new ComponentVec(glComponentType.UNSIGNED_SHORT, 4) }, - { typeof(Matrix4x4), new ComponentVec(glComponentType.FLOAT, 16) }, - { typeof(Color), new ComponentVec(glComponentType.FLOAT, 4) }, - }; - - static glComponentType GetComponentType() - { - var cv = default(ComponentVec); - if (ComponentTypeMap.TryGetValue(typeof(T), out cv)) - { - return cv.ComponentType; - } - else if (typeof(T) == typeof(uint)) - { - return glComponentType.UNSIGNED_INT; - } - else if (typeof(T) == typeof(float)) - { - return glComponentType.FLOAT; - } - else - { - throw new NotImplementedException(typeof(T).Name); - } - } - - static string GetAccessorType() - { - var cv = default(ComponentVec); - if (ComponentTypeMap.TryGetValue(typeof(T), out cv)) - { - switch (cv.ElementCount) - { - case 2: return "VEC2"; - case 3: return "VEC3"; - case 4: return "VEC4"; - case 16: return "MAT4"; - default: throw new Exception(); - } - } - else - { - return "SCALAR"; - } - } - - static int GetAccessorElementCount() - { - var cv = default(ComponentVec); - if (ComponentTypeMap.TryGetValue(typeof(T), out cv)) - { - return cv.ElementCount; - } - else - { - return 1; - } - } - - public static int ExtendBufferAndGetAccessorIndex(this glTF gltf, int bufferIndex, T[] array, - glBufferTarget target = glBufferTarget.NONE) where T : struct - { - return gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, new ArraySegment(array), target); - } - - public static int ExtendBufferAndGetAccessorIndex(this glTF gltf, int bufferIndex, - ArraySegment array, - glBufferTarget target = glBufferTarget.NONE) where T : struct - { - if (array.Count == 0) - { - return -1; - } - var viewIndex = ExtendBufferAndGetViewIndex(gltf, bufferIndex, array, target); - - // index buffer's byteStride is unnecessary - gltf.bufferViews[viewIndex].byteStride = 0; - - var accessorIndex = gltf.accessors.Count; - gltf.accessors.Add(new glTFAccessor - { - bufferView = viewIndex, - byteOffset = 0, - componentType = GetComponentType(), - type = GetAccessorType(), - count = array.Count, - }); - return accessorIndex; - } - - public static int ExtendBufferAndGetViewIndex(this glTF gltf, int bufferIndex, - T[] array, - glBufferTarget target = glBufferTarget.NONE) where T : struct - { - return ExtendBufferAndGetViewIndex(gltf, bufferIndex, new ArraySegment(array), target); - } - - public static int ExtendBufferAndGetViewIndex(this glTF gltf, int bufferIndex, - ArraySegment array, - glBufferTarget target = glBufferTarget.NONE) where T : struct - { - if (array.Count == 0) - { - return -1; - } - var view = gltf.buffers[bufferIndex].Append(array, target); - var viewIndex = gltf.bufferViews.Count; - gltf.bufferViews.Add(view); - return viewIndex; - } - - public static int ExtendSparseBufferAndGetAccessorIndex(this glTF gltf, int bufferIndex, - int accessorCount, - T[] sparseValues, int[] sparseIndices, int sparseViewIndex, - glBufferTarget target = glBufferTarget.NONE) where T : struct - { - return ExtendSparseBufferAndGetAccessorIndex(gltf, bufferIndex, - accessorCount, - new ArraySegment(sparseValues), sparseIndices, sparseViewIndex, - target); - } - - public static int ExtendSparseBufferAndGetAccessorIndex(this glTF gltf, int bufferIndex, - int accessorCount, - ArraySegment sparseValues, int[] sparseIndices, int sparseIndicesViewIndex, - glBufferTarget target = glBufferTarget.NONE) where T : struct - { - if (sparseValues.Count == 0) - { - return -1; - } - var sparseValuesViewIndex = ExtendBufferAndGetViewIndex(gltf, bufferIndex, sparseValues, target); - var accessorIndex = gltf.accessors.Count; - gltf.accessors.Add(new glTFAccessor - { - byteOffset = 0, - componentType = GetComponentType(), - type = GetAccessorType(), - count = accessorCount, - - sparse = new glTFSparse - { - count=sparseIndices.Length, - indices = new glTFSparseIndices - { - bufferView = sparseIndicesViewIndex, - componentType = glComponentType.UNSIGNED_INT - }, - values = new glTFSparseValues - { - bufferView = sparseValuesViewIndex, - } - } - }); - return accessorIndex; - } - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras.meta b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras.meta deleted file mode 100644 index 44b87167a..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: ba47ab6d00c723348b9ac86141cb7bfd -folderAsset: yes -timeCreated: 1533605176 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_draco_mesh_compression.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_draco_mesh_compression.cs deleted file mode 100644 index 1e4b9ae48..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_draco_mesh_compression.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using UniJSON; - - -namespace UniGLTF -{ - [Serializable] - public partial class glTFPrimitives_extensions : ExtensionsBase - { - [JsonSerializeMembers] - void SerializeMembers_draco(GLTFJsonFormatter f) - { - //throw new NotImplementedException(); - } - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_draco_mesh_compression.cs.meta b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_draco_mesh_compression.cs.meta deleted file mode 100644 index 3cdd0a83e..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_draco_mesh_compression.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2d21c7591557c7744a6fa34a7acace91 -timeCreated: 1533605595 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_materials_unlit.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_materials_unlit.cs deleted file mode 100644 index 72e28518c..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_materials_unlit.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using UniJSON; - -namespace UniGLTF -{ - [Serializable] - public class glTF_KHR_materials_unlit : JsonSerializableBase - { - public static string ExtensionName - { - get - { - return "KHR_materials_unlit"; - } - } - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - //throw new System.NotImplementedException(); - } - - public static glTFMaterial CreateDefault() - { - return new glTFMaterial - { - pbrMetallicRoughness = new glTFPbrMetallicRoughness - { - baseColorFactor = new float[] { 1.0f, 1.0f, 1.0f, 1.0f }, - roughnessFactor = 0.9f, - metallicFactor = 0.0f, - }, - extensions = new glTFMaterial_extensions - { - KHR_materials_unlit = new glTF_KHR_materials_unlit(), - }, - }; - } - } - - [Serializable] - public partial class glTFMaterial_extensions : ExtensionsBase - { - [JsonSchema(Required = true)] - public glTF_KHR_materials_unlit KHR_materials_unlit; - - [JsonSerializeMembers] - void SerializeMembers_unlit(GLTFJsonFormatter f) - { - if (KHR_materials_unlit != null) - { - f.Key("KHR_materials_unlit"); f.GLTFValue(KHR_materials_unlit); - } - } - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_texture_transform.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_texture_transform.cs deleted file mode 100644 index 8c5034369..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_texture_transform.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UniJSON; - -namespace UniGLTF -{ - [Serializable] - public class glTF_KHR_texture_transform : JsonSerializableBase - { - public static string ExtensionName - { - get - { - return "KHR_texture_transform"; - } - } - - [JsonSchema(MinItems = 2, MaxItems = 2)] - public float[] offset = new float[2] { 0.0f, 0.0f }; - - public float rotation; - - [JsonSchema(MinItems = 2, MaxItems = 2)] - public float[] scale = new float[2] { 1.0f, 1.0f }; - - [ItemJsonSchema(Minimum = 0)] - public int texCoord; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => offset); - f.KeyValue(() => rotation); - f.KeyValue(() => scale); - f.KeyValue(() => texCoord); - } - } - - [Serializable] - public class glTFTextureInfo_extensions : ExtensionsBase - { - [JsonSchema(Required = true)] - public glTF_KHR_texture_transform KHR_texture_transform; - - /// - /// リフレクションでシリアライズする時は使われない - /// - /// - [JsonSerializeMembers] - void SerializeMembers_textureInfo(GLTFJsonFormatter f) - { - if (KHR_texture_transform != null) - { - f.KeyValue(() => KHR_texture_transform); - } - } - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFCameraExtensions.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFCameraExtensions.cs deleted file mode 100644 index f7bae3667..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFCameraExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using UniJSON; - - -namespace UniGLTF -{ - [Serializable] - [ItemJsonSchema(ValueType = ValueNodeType.Object)] - public partial class glTFOrthographic_extensions : ExtensionsBase { } - - [Serializable] - public partial class glTFOrthographic_extras : ExtraBase { } - - [Serializable] - [ItemJsonSchema(ValueType = ValueNodeType.Object)] - public partial class glTFPerspective_extensions : ExtensionsBase { } - - [Serializable] - public partial class glTFPerspective_extras : ExtraBase { } - - [Serializable] - [ItemJsonSchema(ValueType = ValueNodeType.Object)] - public partial class glTFCamera_extensions : ExtensionsBase { } - - [Serializable] - public partial class glTFCamera_extras : ExtraBase { } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFCameraExtensions.cs.meta b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFCameraExtensions.cs.meta deleted file mode 100644 index 3f5c26d33..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFCameraExtensions.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 38f59c64e05855b41be64595c570e366 -timeCreated: 1533605499 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFExtensions.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFExtensions.cs deleted file mode 100644 index 20b649bcc..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFExtensions.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using UniJSON; - - -namespace UniGLTF -{ - #region Base - public class JsonSerializeMembersAttribute : Attribute { } - - public class PartialExtensionBase : JsonSerializableBase - { - protected override void SerializeMembers(GLTFJsonFormatter f) - { - foreach (var method in this.GetType().GetMethods(BindingFlags.Instance | - BindingFlags.Public | BindingFlags.NonPublic)) - { - if (method.GetCustomAttributes(typeof(JsonSerializeMembersAttribute), true).Any()) - { - method.Invoke(this, new[] { f }); - } - } - } - - public int __count - { - get - { - return typeof(T).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) - .Where(x => x.GetCustomAttributes(typeof(JsonSerializeMembersAttribute), true).Any()) - .Count(); - } - } - } - - [ItemJsonSchema(ValueType = ValueNodeType.Object)] - //[JsonSchema(MinProperties = 1)] - public partial class ExtensionsBase : PartialExtensionBase - { - } - - //[JsonSchema(MinProperties = 1)] - public partial class ExtraBase : PartialExtensionBase - { - } - #endregion - - [Serializable] - public partial class glTF_extensions : ExtensionsBase { } - - [Serializable] - public partial class gltf_extras : ExtraBase { } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFExtensions.cs.meta b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFExtensions.cs.meta deleted file mode 100644 index f1fd71eec..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFExtensions.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 356f989283db8c848b851b82c34086d1 -timeCreated: 1532101527 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.Primitives.extras.targetNames.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.Primitives.extras.targetNames.cs deleted file mode 100644 index bbfc18965..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.Primitives.extras.targetNames.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using UniJSON; - - -namespace UniGLTF -{ - /// - /// https://github.com/KhronosGroup/glTF/issues/1036 - /// - [Serializable] - public partial class glTFPrimitives_extras : ExtraBase - { - [JsonSchema(Required = true, MinItems = 1)] - public List targetNames = new List(); - - [JsonSerializeMembers] - void PrimitiveMembers(GLTFJsonFormatter f) - { - if (targetNames.Count > 0) - { - f.Key("targetNames"); - f.BeginList(); - foreach (var x in targetNames) - { - f.Value(x); - } - f.EndList(); - } - } - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.Primitives.extras.targetNames.cs.meta b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.Primitives.extras.targetNames.cs.meta deleted file mode 100644 index 10ec6ee57..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.Primitives.extras.targetNames.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e95762d0b18d11243b32a56f21cef862 -timeCreated: 1533605545 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.extras.targetNames.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.extras.targetNames.cs deleted file mode 100644 index 49e12de51..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.extras.targetNames.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using UniJSON; - - -namespace UniGLTF -{ - /// - /// https://github.com/KhronosGroup/glTF/issues/1036 - /// - [Serializable] - public partial class glTFMesh_extras : ExtraBase - { - [JsonSchema(Required = true, MinItems = 1)] - public List targetNames = new List(); - - [JsonSerializeMembers] - void PrimitiveMembers(GLTFJsonFormatter f) - { - if (targetNames.Count > 0) - { - f.Key("targetNames"); - f.BeginList(); - foreach (var x in targetNames) - { - f.Value(x); - } - f.EndList(); - } - } - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.extras.targetNames.cs.meta b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.extras.targetNames.cs.meta deleted file mode 100644 index 139962cd6..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFMesh.extras.targetNames.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 97b77d4c1c0d44b594e9187e41b3152d -timeCreated: 1582269878 \ No newline at end of file diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFNode.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFNode.cs deleted file mode 100644 index 0c0b9825e..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFNode.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - - -namespace UniGLTF -{ - [Serializable] - public partial class glTFNode_extensions : ExtensionsBase { } - - [Serializable] - public partial class glTFNode_extra : ExtraBase { } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFNode.cs.meta b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFNode.cs.meta deleted file mode 100644 index d68a4cd38..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/glTFNode.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: eef0405c0c9670947ab6fa2034f0343f -timeCreated: 1533605847 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/Format/GLTFJsonFormatter.cs b/Assets/VRM/UniGLTF/Scripts/Format/GLTFJsonFormatter.cs deleted file mode 100644 index 7a6b1b061..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/GLTFJsonFormatter.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Generic; -using UniJSON; - - -namespace UniGLTF -{ - public class GLTFJsonFormatter: UniJSON.JsonFormatter - { - public void GLTFValue(JsonSerializableBase s) - { - CommaCheck(); - Store.Write(s.ToJson()); - } - - public void GLTFValue(IEnumerable values) where T : JsonSerializableBase - { - BeginList(); - foreach (var value in values) - { - GLTFValue(value); - } - EndList(); - } - - public void GLTFValue(List values) - { - BeginList(); - foreach (var value in values) - { - this.Value(value); - } - EndList(); - } - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/GLTFJsonFormatter.cs.meta b/Assets/VRM/UniGLTF/Scripts/Format/GLTFJsonFormatter.cs.meta deleted file mode 100644 index eb52e7f5d..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/GLTFJsonFormatter.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b80a7ee38e762de44a90d60d9d4ff4dd -timeCreated: 1531806259 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/Format/JsonSerializableBase.cs b/Assets/VRM/UniGLTF/Scripts/Format/JsonSerializableBase.cs deleted file mode 100644 index 3d302b1da..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/JsonSerializableBase.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - - -namespace UniGLTF -{ - [Serializable] - public abstract class JsonSerializableBase - { - protected abstract void SerializeMembers(GLTFJsonFormatter f); - - public string ToJson() - { - var f = new GLTFJsonFormatter(); - f.BeginMap(); - - SerializeMembers(f); - - f.EndMap(); - return f.ToString(); - } - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/JsonSerializableBase.cs.meta b/Assets/VRM/UniGLTF/Scripts/Format/JsonSerializableBase.cs.meta deleted file mode 100644 index a21428132..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/JsonSerializableBase.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d169186adbfc59b4b882611d37f0a282 -timeCreated: 1532078625 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/Format/SerializerTypes.cs b/Assets/VRM/UniGLTF/Scripts/Format/SerializerTypes.cs deleted file mode 100644 index fcdee0804..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/SerializerTypes.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace UniGLTF -{ - public enum SerializerTypes - { - Generated, // generated, No AOT Problem - JsonSerializable, // manual, Obsolete - UniJSON, // reflection, Obsolete - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs deleted file mode 100644 index 4180f52be..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs +++ /dev/null @@ -1,525 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using UniJSON; - - -namespace UniGLTF -{ - [Serializable] - public class gltfScene : JsonSerializableBase - { - [JsonSchema(MinItems = 1)] - [ItemJsonSchema(Minimum = 0)] - public int[] nodes; - - public object extensions; - public object extras; - public string name; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => nodes); - } - } - - [Serializable] - public class glTF : JsonSerializableBase, IEquatable - { - [JsonSchema(Required = true)] - public glTFAssets asset = new glTFAssets(); - - #region Buffer - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List buffers = new List(); - public int AddBuffer(IBytesBuffer bytesBuffer) - { - var index = buffers.Count; - buffers.Add(new glTFBuffer(bytesBuffer)); - return index; - } - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List bufferViews = new List(); - public int AddBufferView(glTFBufferView view) - { - var index = bufferViews.Count; - bufferViews.Add(view); - return index; - } - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List accessors = new List(); - - T[] GetAttrib(glTFAccessor accessor, glTFBufferView view) where T : struct - { - return GetAttrib(accessor.count, accessor.byteOffset, view); - } - T[] GetAttrib(int count, int byteOffset, glTFBufferView view) where T : struct - { - var attrib = new T[count]; - var segment = buffers[view.buffer].GetBytes(); - var bytes = new ArraySegment(segment.Array, segment.Offset + view.byteOffset + byteOffset, count * view.byteStride); - bytes.MarshalCopyTo(attrib); - return attrib; - } - - public ArraySegment GetViewBytes(int bufferView) - { - var view = bufferViews[bufferView]; - var segment = buffers[view.buffer].GetBytes(); - return new ArraySegment(segment.Array, segment.Offset + view.byteOffset, view.byteLength); - } - - IEnumerable _GetIndices(glTFAccessor accessor, out int count) - { - count = accessor.count; - var view = bufferViews[accessor.bufferView]; - switch ((glComponentType)accessor.componentType) - { - case glComponentType.UNSIGNED_BYTE: - { - return GetAttrib(accessor, view).Select(x => (int)(x)); - } - - case glComponentType.UNSIGNED_SHORT: - { - return GetAttrib(accessor, view).Select(x => (int)(x)); - } - - case glComponentType.UNSIGNED_INT: - { - return GetAttrib(accessor, view).Select(x => (int)(x)); - } - } - throw new NotImplementedException("GetIndices: unknown componenttype: " + accessor.componentType); - } - - IEnumerable _GetIndices(glTFBufferView view, int count, int byteOffset, glComponentType componentType) - { - switch (componentType) - { - case glComponentType.UNSIGNED_BYTE: - { - return GetAttrib(count, byteOffset, view).Select(x => (int)(x)); - } - - case glComponentType.UNSIGNED_SHORT: - { - return GetAttrib(count, byteOffset, view).Select(x => (int)(x)); - } - - case glComponentType.UNSIGNED_INT: - { - return GetAttrib(count, byteOffset, view).Select(x => (int)(x)); - } - } - throw new NotImplementedException("GetIndices: unknown componenttype: " + componentType); - } - - public int[] GetIndices(int accessorIndex) - { - int count; - var result = _GetIndices(accessors[accessorIndex], out count); - var indices = new int[count]; - - // flip triangles - var it = result.GetEnumerator(); - { - for (int i = 0; i < count; i += 3) - { - it.MoveNext(); indices[i + 2] = it.Current; - it.MoveNext(); indices[i + 1] = it.Current; - it.MoveNext(); indices[i] = it.Current; - } - } - - return indices; - } - - public T[] GetArrayFromAccessor(int accessorIndex) where T : struct - { - var vertexAccessor = accessors[accessorIndex]; - - if (vertexAccessor.count <= 0) return new T[] { }; - - var result = (vertexAccessor.bufferView != -1) - ? GetAttrib(vertexAccessor, bufferViews[vertexAccessor.bufferView]) - : new T[vertexAccessor.count] - ; - - var sparse = vertexAccessor.sparse; - if (sparse != null && sparse.count > 0) - { - // override sparse values - var indices = _GetIndices(bufferViews[sparse.indices.bufferView], sparse.count, sparse.indices.byteOffset, sparse.indices.componentType); - var values = GetAttrib(sparse.count, sparse.values.byteOffset, bufferViews[sparse.values.bufferView]); - - var it = indices.GetEnumerator(); - for (int i = 0; i < sparse.count; ++i) - { - it.MoveNext(); - result[it.Current] = values[i]; - } - } - return result; - } - #endregion - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List textures = new List(); - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List samplers = new List(); - public glTFTextureSampler GetSampler(int index) - { - if (samplers.Count == 0) - { - samplers.Add(new glTFTextureSampler()); // default sampler - } - - return samplers[index]; - } - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List images = new List(); - - public int GetImageIndexFromTextureIndex(int textureIndex) - { - return textures[textureIndex].source; - } - - public glTFImage GetImageFromTextureIndex(int textureIndex) - { - return images[GetImageIndexFromTextureIndex(textureIndex)]; - } - - public glTFTextureSampler GetSamplerFromTextureIndex(int textureIndex) - { - var samplerIndex = textures[textureIndex].sampler; - return GetSampler(samplerIndex); - } - - public ArraySegment GetImageBytes(IStorage storage, int imageIndex, out string textureName) - { - var image = images[imageIndex]; - if (string.IsNullOrEmpty(image.uri)) - { - // - // use buffer view (GLB) - // - //m_imageBytes = ToArray(byteSegment); - textureName = !string.IsNullOrEmpty(image.name) ? image.name : string.Format("{0:00}#GLB", imageIndex); - return GetViewBytes(image.bufferView); - } - else - { - if (image.uri.StartsWith("data:")) - { - textureName = !string.IsNullOrEmpty(image.name) ? image.name : string.Format("{0:00}#Base64Embedded", imageIndex); - } - else - { - textureName = !string.IsNullOrEmpty(image.name) ? image.name : Path.GetFileNameWithoutExtension(image.uri); - } - return storage.Get(image.uri); - } - } - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List materials = new List(); - public string GetUniqueMaterialName(int index) - { - if (materials.Any(x => string.IsNullOrEmpty(x.name)) - || materials.Select(x => x.name).Distinct().Count() != materials.Count) - { - return String.Format("{0:00}_{1}", index, materials[index].name); - } - else - { - return materials[index].name; - } - } - - public bool MaterialHasVertexColor(glTFMaterial material) - { - if (material == null) - { - return false; - } - - var materialIndex = materials.IndexOf(material); - if (materialIndex == -1) - { - return false; - } - - return MaterialHasVertexColor(materialIndex); - } - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List meshes = new List(); - - public bool MaterialHasVertexColor(int materialIndex) - { - if (materialIndex < 0 || materialIndex >= materials.Count) - { - return false; - } - - var hasVertexColor = meshes.SelectMany(x => x.primitives).Any(x => x.material == materialIndex && x.HasVertexColor); - return hasVertexColor; - } - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List nodes = new List(); - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List skins = new List(); - - [JsonSchema(Dependencies = new string[] { "scenes" }, Minimum = 0)] - public int scene; - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List scenes = new List(); - public int[] rootnodes - { - get - { - return scenes[scene].nodes; - } - } - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List animations = new List(); - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List cameras = new List(); - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List extensionsUsed = new List(); - - [JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)] - public List extensionsRequired = new List(); - - public glTF_extensions extensions = new glTF_extensions(); - public gltf_extras extras = new gltf_extras(); - - public override string ToString() - { - return string.Format("{0}", asset); - } - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - if (extensionsUsed.Count > 0) - { - f.Key("extensionsUsed"); f.GLTFValue(extensionsUsed); - } - if (extensions.__count > 0) - { - f.Key("extensions"); f.GLTFValue(extensions); - } - if (extras.__count > 0) - { - f.Key("extras"); f.GLTFValue(extras); - } - - f.Key("asset"); f.GLTFValue(asset); - - // buffer - if (buffers.Any()) - { - f.Key("buffers"); f.GLTFValue(buffers); - } - if (bufferViews.Any()) - { - f.Key("bufferViews"); f.GLTFValue(bufferViews); - } - if (accessors.Any()) - { - f.Key("accessors"); f.GLTFValue(accessors); - } - - // materials - if (images.Any()) - { - f.Key("images"); f.GLTFValue(images); - if (samplers.Count == 0) - { - samplers.Add(new glTFTextureSampler()); - } - } - - if (samplers.Any()) - { - f.Key("samplers"); f.GLTFValue(samplers); - } - - if (textures.Any()) - { - f.Key("textures"); f.GLTFValue(textures); - } - if (materials.Any()) - { - f.Key("materials"); f.GLTFValue(materials); - } - - // meshes - if (meshes.Any()) - { - f.Key("meshes"); f.GLTFValue(meshes); - } - if (skins.Any()) - { - f.Key("skins"); f.GLTFValue(skins); - } - - // scene - if (nodes.Any()) - { - f.Key("nodes"); f.GLTFValue(nodes); - } - if (scenes.Any()) - { - f.Key("scenes"); f.GLTFValue(scenes); - if (scene >= 0) - { - f.KeyValue(() => scene); - } - } - - // animations - if (animations.Any()) - { - f.Key("animations"); f.GLTFValue(animations); - } - } - - public bool Equals(glTF other) - { - return - textures.SequenceEqual(other.textures) - && samplers.SequenceEqual(other.samplers) - && images.SequenceEqual(other.images) - && materials.SequenceEqual(other.materials) - && meshes.SequenceEqual(other.meshes) - && nodes.SequenceEqual(other.nodes) - && skins.SequenceEqual(other.skins) - && scene == other.scene - && scenes.SequenceEqual(other.scenes) - && animations.SequenceEqual(other.animations) - ; - } - - bool UsedExtension(string key) - { - if (extensionsUsed.Contains(key)) - { - return true; - } - - return false; - } - - static Utf8String s_extensions = Utf8String.From("extensions"); - - void Traverse(ListTreeNode node, JsonFormatter f, Utf8String parentKey) - { - if (node.IsMap()) - { - f.BeginMap(); - foreach (var kv in node.ObjectItems()) - { - if (parentKey == s_extensions) - { - if (!UsedExtension(kv.Key.GetString())) - { - continue; - } - } - f.Key(kv.Key.GetUtf8String()); - Traverse(kv.Value, f, kv.Key.GetUtf8String()); - } - f.EndMap(); - } - else if (node.IsArray()) - { - f.BeginList(); - foreach (var x in node.ArrayItems()) - { - Traverse(x, f, default(Utf8String)); - } - f.EndList(); - } - else - { - f.Value(node); - } - } - - string RemoveUnusedExtensions(string json) - { - var f = new JsonFormatter(); - - Traverse(JsonParser.Parse(json), f, default(Utf8String)); - - return f.ToString(); - } - - public byte[] ToGlbBytes(SerializerTypes serializer = SerializerTypes.Generated) - { - string json; - if (serializer == SerializerTypes.UniJSON) - { - // Obsolete - var c = new JsonSchemaValidationContext(this) - { - EnableDiagnosisForNotRequiredFields = true, - }; - json = JsonSchema.FromType(GetType()).Serialize(this, c); - } - else if (serializer == SerializerTypes.Generated) - { - var f = new JsonFormatter(); - f.GenSerialize(this); - json = f.ToString().ParseAsJson().ToString(" "); - } - else if (serializer == SerializerTypes.JsonSerializable) - { - // Obsolete - json = ToJson(); - } - else - { - throw new Exception("[UniVRM Export Error] unknown serializer type"); - } - - RemoveUnusedExtensions(json); - - return Glb.ToBytes(json, buffers[0].GetBytes()); - } - - public (string, List) ToGltf(string gltfPath) - { - var f = new JsonFormatter(); - - // fix buffer path - if (buffers.Count == 1) - { - var withoutExt = Path.GetFileNameWithoutExtension(gltfPath); - buffers[0].uri = $"{withoutExt}.bin"; - } - else - { - throw new NotImplementedException(); - } - - f.GenSerialize(this); - var json = f.ToString().ParseAsJson().ToString(" "); - RemoveUnusedExtensions(json); - return (json, buffers); - } - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFNode.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTFNode.cs deleted file mode 100644 index edef688f7..000000000 --- a/Assets/VRM/UniGLTF/Scripts/Format/glTFNode.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Linq; -using UniJSON; - -namespace UniGLTF -{ - [Serializable] - public class glTFNode : JsonSerializableBase - { - // TODO: need an empty string? - public string name; - - [JsonSchema(MinItems = 1)] - [ItemJsonSchema(Minimum = 0)] - public int[] children; - - [JsonSchema(MinItems = 16, MaxItems = 16)] - public float[] matrix; - - [JsonSchema(MinItems = 3, MaxItems = 3)] - public float[] translation; - - [JsonSchema(MinItems = 4, MaxItems = 4)] - [ItemJsonSchema(Minimum = -1.0, Maximum = 1.0)] - public float[] rotation; - - [JsonSchema(MinItems = 3, MaxItems = 3)] - public float[] scale; - - [JsonSchema(Minimum = 0, ExplicitIgnorableValue = -1)] - public int mesh = -1; - - [JsonSchema(Dependencies = new string[] { "mesh" }, Minimum = 0, ExplicitIgnorableValue = -1)] - public int skin = -1; - - [JsonSchema(Dependencies = new string[] { "mesh" }, MinItems = 1)] - public float[] weights; - - [JsonSchema(Minimum = 0, ExplicitIgnorableValue = -1)] - public int camera = -1; - - // empty schemas - public glTFNode_extensions extensions; - - public glTFNode_extra extras = new glTFNode_extra(); - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - if (children != null && children.Any()) - { - f.Key("children"); f.BeginList(); - foreach (var child in children) - { - f.Value(child); - } - f.EndList(); - } - - if (!string.IsNullOrEmpty(name)) f.KeyValue(() => name); - if (matrix != null) f.KeyValue(() => matrix); - if (translation != null) f.KeyValue(() => translation); - if (rotation != null) f.KeyValue(() => rotation); - if (scale != null) f.KeyValue(() => scale); - - if (mesh >= 0) f.KeyValue(() => mesh); - if (camera >= 0) f.KeyValue(() => camera); - if (skin >= 0) - { - f.KeyValue(() => skin); - - if (extras.__count > 0) - { - f.Key("extras"); f.GLTFValue(extras); - } - } - } - } -} diff --git a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs deleted file mode 100644 index 7bd0d6a47..000000000 --- a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs +++ /dev/null @@ -1,2207 +0,0 @@ - -using System; -using System.Collections.Generic; -using UniJSON; -using UnityEngine; -using VRM; - -namespace UniGLTF { - - static public class IFormatterExtensionsGltf - { - - - /// gltf - public static void GenSerialize(this IFormatter f, glTF value) - { - f.BeginMap(0); // dummy - - if(value.asset!=null) - { - f.Key("asset"); f.GenSerialize(value.asset); - } - - if(value.buffers!=null && value.buffers.Count>0) - { - f.Key("buffers"); f.GenSerialize(value.buffers); - } - - if(value.bufferViews!=null && value.bufferViews.Count>0) - { - f.Key("bufferViews"); f.GenSerialize(value.bufferViews); - } - - if(value.accessors!=null && value.accessors.Count>0) - { - f.Key("accessors"); f.GenSerialize(value.accessors); - } - - if(value.textures!=null && value.textures.Count>0) - { - f.Key("textures"); f.GenSerialize(value.textures); - } - - if(value.samplers!=null && value.samplers.Count>0) - { - f.Key("samplers"); f.GenSerialize(value.samplers); - } - - if(value.images!=null && value.images.Count>0) - { - f.Key("images"); f.GenSerialize(value.images); - } - - if(value.materials!=null && value.materials.Count>0) - { - f.Key("materials"); f.GenSerialize(value.materials); - } - - if(value.meshes!=null && value.meshes.Count>0) - { - f.Key("meshes"); f.GenSerialize(value.meshes); - } - - if(value.nodes!=null && value.nodes.Count>0) - { - f.Key("nodes"); f.GenSerialize(value.nodes); - } - - if(value.skins!=null && value.skins.Count>0) - { - f.Key("skins"); f.GenSerialize(value.skins); - } - - - { - f.Key("scene"); f.GenSerialize(value.scene); - } - - if(value.scenes!=null && value.scenes.Count>0) - { - f.Key("scenes"); f.GenSerialize(value.scenes); - } - - if(value.animations!=null && value.animations.Count>0) - { - f.Key("animations"); f.GenSerialize(value.animations); - } - - if(value.cameras!=null && value.cameras.Count>0) - { - f.Key("cameras"); f.GenSerialize(value.cameras); - } - - if(value.extensionsUsed!=null && value.extensionsUsed.Count>0) - { - f.Key("extensionsUsed"); f.GenSerialize(value.extensionsUsed); - } - - if(false && value.extensionsRequired!=null && value.extensionsRequired.Count>0) - { - f.Key("extensionsRequired"); f.GenSerialize(value.extensionsRequired); - } - - if(value.extensions!=null) - { - f.Key("extensions"); f.GenSerialize(value.extensions); - } - - f.EndMap(); - } - - /// gltf/asset - public static void GenSerialize(this IFormatter f, glTFAssets value) - { - f.BeginMap(0); // dummy - - if(value.generator!=null) - { - f.Key("generator"); f.GenSerialize(value.generator); - } - - if(value.version!=null) - { - f.Key("version"); f.GenSerialize(value.version); - } - - if(value.copyright!=null) - { - f.Key("copyright"); f.GenSerialize(value.copyright); - } - - if(value.minVersion!=null) - { - f.Key("minVersion"); f.GenSerialize(value.minVersion); - } - - f.EndMap(); - } - - public static void GenSerialize(this IFormatter f, String value) - { - f.Value(value); - } - - /// gltf/buffers - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/buffers[] - public static void GenSerialize(this IFormatter f, glTFBuffer value) - { - f.BeginMap(0); // dummy - - if(value.uri!=null) - { - f.Key("uri"); f.GenSerialize(value.uri); - } - - - { - f.Key("byteLength"); f.GenSerialize(value.byteLength); - } - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - f.EndMap(); - } - - public static void GenSerialize(this IFormatter f, Int32 value) - { - f.Value(value); - } - - /// gltf/bufferViews - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/bufferViews[] - public static void GenSerialize(this IFormatter f, glTFBufferView value) - { - f.BeginMap(0); // dummy - - - { - f.Key("buffer"); f.GenSerialize(value.buffer); - } - - - { - f.Key("byteOffset"); f.GenSerialize(value.byteOffset); - } - - - { - f.Key("byteLength"); f.GenSerialize(value.byteLength); - } - - if(value.target!=0) - { - f.Key("target"); f.GenSerialize(value.target); - } - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - f.EndMap(); - } - - public static void GenSerialize(this IFormatter f, glBufferTarget value) - { - f.Value((int)value); - } - - /// gltf/accessors - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/accessors[] - public static void GenSerialize(this IFormatter f, glTFAccessor value) - { - f.BeginMap(0); // dummy - - if(value.bufferView>=0) - { - f.Key("bufferView"); f.GenSerialize(value.bufferView); - } - - if(value.bufferView>=0) - { - f.Key("byteOffset"); f.GenSerialize(value.byteOffset); - } - - if(value.type!=null) - { - f.Key("type"); f.GenSerialize(value.type); - } - - - { - f.Key("componentType"); f.GenSerialize(value.componentType); - } - - - { - f.Key("count"); f.GenSerialize(value.count); - } - - if(value.max!=null && value.max.Length>0) - { - f.Key("max"); f.GenSerialize(value.max); - } - - if(value.min!=null && value.min.Length>0) - { - f.Key("min"); f.GenSerialize(value.min); - } - - - { - f.Key("normalized"); f.GenSerialize(value.normalized); - } - - if(value.sparse!=null && value.sparse.count>0) - { - f.Key("sparse"); f.GenSerialize(value.sparse); - } - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - f.EndMap(); - } - - public static void GenSerialize(this IFormatter f, glComponentType value) - { - f.Value((int)value); - } - - /// gltf/accessors[]/max - public static void GenSerialize(this IFormatter f, Single[] value) - { - f.BeginList(value.Length); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - public static void GenSerialize(this IFormatter f, Single value) - { - f.Value(value); - } - - public static void GenSerialize(this IFormatter f, Boolean value) - { - f.Value(value); - } - - /// gltf/accessors[]/sparse - public static void GenSerialize(this IFormatter f, glTFSparse value) - { - f.BeginMap(0); // dummy - - - { - f.Key("count"); f.GenSerialize(value.count); - } - - if(value.indices!=null) - { - f.Key("indices"); f.GenSerialize(value.indices); - } - - if(value.values!=null) - { - f.Key("values"); f.GenSerialize(value.values); - } - - f.EndMap(); - } - - /// gltf/accessors[]/sparse/indices - public static void GenSerialize(this IFormatter f, glTFSparseIndices value) - { - f.BeginMap(0); // dummy - - - { - f.Key("bufferView"); f.GenSerialize(value.bufferView); - } - - - { - f.Key("byteOffset"); f.GenSerialize(value.byteOffset); - } - - - { - f.Key("componentType"); f.GenSerialize(value.componentType); - } - - f.EndMap(); - } - - /// gltf/accessors[]/sparse/values - public static void GenSerialize(this IFormatter f, glTFSparseValues value) - { - f.BeginMap(0); // dummy - - - { - f.Key("bufferView"); f.GenSerialize(value.bufferView); - } - - - { - f.Key("byteOffset"); f.GenSerialize(value.byteOffset); - } - - f.EndMap(); - } - - /// gltf/textures - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/textures[] - public static void GenSerialize(this IFormatter f, glTFTexture value) - { - f.BeginMap(0); // dummy - - - { - f.Key("sampler"); f.GenSerialize(value.sampler); - } - - - { - f.Key("source"); f.GenSerialize(value.source); - } - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - f.EndMap(); - } - - /// gltf/samplers - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/samplers[] - public static void GenSerialize(this IFormatter f, glTFTextureSampler value) - { - f.BeginMap(0); // dummy - - - { - f.Key("magFilter"); f.GenSerialize(value.magFilter); - } - - - { - f.Key("minFilter"); f.GenSerialize(value.minFilter); - } - - - { - f.Key("wrapS"); f.GenSerialize(value.wrapS); - } - - - { - f.Key("wrapT"); f.GenSerialize(value.wrapT); - } - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - f.EndMap(); - } - - public static void GenSerialize(this IFormatter f, glFilter value) - { - f.Value((int)value); - } - - public static void GenSerialize(this IFormatter f, glWrap value) - { - f.Value((int)value); - } - - /// gltf/images - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/images[] - public static void GenSerialize(this IFormatter f, glTFImage value) - { - f.BeginMap(0); // dummy - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - if(value.uri!=null) - { - f.Key("uri"); f.GenSerialize(value.uri); - } - - - { - f.Key("bufferView"); f.GenSerialize(value.bufferView); - } - - if(value.mimeType!=null) - { - f.Key("mimeType"); f.GenSerialize(value.mimeType); - } - - f.EndMap(); - } - - /// gltf/materials - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/materials[] - public static void GenSerialize(this IFormatter f, glTFMaterial value) - { - f.BeginMap(0); // dummy - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - if(value.pbrMetallicRoughness!=null) - { - f.Key("pbrMetallicRoughness"); f.GenSerialize(value.pbrMetallicRoughness); - } - - if(value.normalTexture!=null) - { - f.Key("normalTexture"); f.GenSerialize(value.normalTexture); - } - - if(value.occlusionTexture!=null) - { - f.Key("occlusionTexture"); f.GenSerialize(value.occlusionTexture); - } - - if(value.emissiveTexture!=null) - { - f.Key("emissiveTexture"); f.GenSerialize(value.emissiveTexture); - } - - if(value.emissiveFactor!=null) - { - f.Key("emissiveFactor"); f.GenSerialize(value.emissiveFactor); - } - - if(value.alphaMode!=null) - { - f.Key("alphaMode"); f.GenSerialize(value.alphaMode); - } - - if(value.alphaMode == "MASK") - { - f.Key("alphaCutoff"); f.GenSerialize(value.alphaCutoff); - } - - - { - f.Key("doubleSided"); f.GenSerialize(value.doubleSided); - } - - if(value.extensions!=null) - { - f.Key("extensions"); f.GenSerialize(value.extensions); - } - - f.EndMap(); - } - - /// gltf/materials[]/pbrMetallicRoughness - public static void GenSerialize(this IFormatter f, glTFPbrMetallicRoughness value) - { - f.BeginMap(0); // dummy - - if(value.baseColorTexture!=null) - { - f.Key("baseColorTexture"); f.GenSerialize(value.baseColorTexture); - } - - if(value.baseColorFactor!=null) - { - f.Key("baseColorFactor"); f.GenSerialize(value.baseColorFactor); - } - - if(value.metallicRoughnessTexture!=null) - { - f.Key("metallicRoughnessTexture"); f.GenSerialize(value.metallicRoughnessTexture); - } - - - { - f.Key("metallicFactor"); f.GenSerialize(value.metallicFactor); - } - - - { - f.Key("roughnessFactor"); f.GenSerialize(value.roughnessFactor); - } - - f.EndMap(); - } - - /// gltf/materials[]/pbrMetallicRoughness/baseColorTexture - public static void GenSerialize(this IFormatter f, glTFMaterialBaseColorTextureInfo value) - { - f.BeginMap(0); // dummy - - - { - f.Key("index"); f.GenSerialize(value.index); - } - - - { - f.Key("texCoord"); f.GenSerialize(value.texCoord); - } - - if(value.extensions!=null) - { - f.Key("extensions"); f.GenSerialize(value.extensions); - } - - f.EndMap(); - } - - /// gltf/materials[]/pbrMetallicRoughness/baseColorTexture/extensions - public static void GenSerialize(this IFormatter f, glTFTextureInfo_extensions value) - { - f.BeginMap(0); // dummy - - if(value.KHR_texture_transform!=null) - { - f.Key("KHR_texture_transform"); f.GenSerialize(value.KHR_texture_transform); - } - - f.EndMap(); - } - - /// gltf/materials[]/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform - public static void GenSerialize(this IFormatter f, glTF_KHR_texture_transform value) - { - f.BeginMap(0); // dummy - - if(value.offset!=null) - { - f.Key("offset"); f.GenSerialize(value.offset); - } - - - { - f.Key("rotation"); f.GenSerialize(value.rotation); - } - - if(value.scale!=null) - { - f.Key("scale"); f.GenSerialize(value.scale); - } - - - { - f.Key("texCoord"); f.GenSerialize(value.texCoord); - } - - f.EndMap(); - } - - /// gltf/materials[]/pbrMetallicRoughness/metallicRoughnessTexture - public static void GenSerialize(this IFormatter f, glTFMaterialMetallicRoughnessTextureInfo value) - { - f.BeginMap(0); // dummy - - - { - f.Key("index"); f.GenSerialize(value.index); - } - - - { - f.Key("texCoord"); f.GenSerialize(value.texCoord); - } - - if(value.extensions!=null) - { - f.Key("extensions"); f.GenSerialize(value.extensions); - } - - f.EndMap(); - } - - /// gltf/materials[]/normalTexture - public static void GenSerialize(this IFormatter f, glTFMaterialNormalTextureInfo value) - { - f.BeginMap(0); // dummy - - - { - f.Key("scale"); f.GenSerialize(value.scale); - } - - - { - f.Key("index"); f.GenSerialize(value.index); - } - - - { - f.Key("texCoord"); f.GenSerialize(value.texCoord); - } - - if(value.extensions!=null) - { - f.Key("extensions"); f.GenSerialize(value.extensions); - } - - f.EndMap(); - } - - /// gltf/materials[]/occlusionTexture - public static void GenSerialize(this IFormatter f, glTFMaterialOcclusionTextureInfo value) - { - f.BeginMap(0); // dummy - - - { - f.Key("strength"); f.GenSerialize(value.strength); - } - - - { - f.Key("index"); f.GenSerialize(value.index); - } - - - { - f.Key("texCoord"); f.GenSerialize(value.texCoord); - } - - if(value.extensions!=null) - { - f.Key("extensions"); f.GenSerialize(value.extensions); - } - - f.EndMap(); - } - - /// gltf/materials[]/emissiveTexture - public static void GenSerialize(this IFormatter f, glTFMaterialEmissiveTextureInfo value) - { - f.BeginMap(0); // dummy - - - { - f.Key("index"); f.GenSerialize(value.index); - } - - - { - f.Key("texCoord"); f.GenSerialize(value.texCoord); - } - - if(value.extensions!=null) - { - f.Key("extensions"); f.GenSerialize(value.extensions); - } - - f.EndMap(); - } - - /// gltf/materials[]/extensions - public static void GenSerialize(this IFormatter f, glTFMaterial_extensions value) - { - f.BeginMap(0); // dummy - - if(value.KHR_materials_unlit!=null) - { - f.Key("KHR_materials_unlit"); f.GenSerialize(value.KHR_materials_unlit); - } - - f.EndMap(); - } - - /// gltf/materials[]/extensions/KHR_materials_unlit - public static void GenSerialize(this IFormatter f, glTF_KHR_materials_unlit value) - { - f.BeginMap(0); // dummy - - f.EndMap(); - } - - /// gltf/meshes - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/meshes[] - public static void GenSerialize(this IFormatter f, glTFMesh value) - { - f.BeginMap(0); // dummy - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - if(value.primitives!=null && value.primitives.Count>0) - { - f.Key("primitives"); f.GenSerialize(value.primitives); - } - - if(value.weights!=null && value.weights.Length>0) - { - f.Key("weights"); f.GenSerialize(value.weights); - } - - if(value.extras!=null) - { - f.Key("extras"); f.GenSerialize(value.extras); - } - - f.EndMap(); - } - - /// gltf/meshes[]/primitives - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/meshes[]/primitives[] - public static void GenSerialize(this IFormatter f, glTFPrimitives value) - { - f.BeginMap(0); // dummy - - - { - f.Key("mode"); f.GenSerialize(value.mode); - } - - - { - f.Key("indices"); f.GenSerialize(value.indices); - } - - if(value.attributes!=null) - { - f.Key("attributes"); f.GenSerialize(value.attributes); - } - - - { - f.Key("material"); f.GenSerialize(value.material); - } - - if(value.targets!=null && value.targets.Count>0) - { - f.Key("targets"); f.GenSerialize(value.targets); - } - - if(value.extras!=null && value.extras.targetNames!=null && value.extras.targetNames.Count>0) - { - f.Key("extras"); f.GenSerialize(value.extras); - } - - f.EndMap(); - } - - /// gltf/meshes[]/primitives[]/attributes - public static void GenSerialize(this IFormatter f, glTFAttributes value) - { - f.BeginMap(0); // dummy - - if(value.POSITION!=-1) - { - f.Key("POSITION"); f.GenSerialize(value.POSITION); - } - - if(value.NORMAL!=-1) - { - f.Key("NORMAL"); f.GenSerialize(value.NORMAL); - } - - if(value.TANGENT!=-1) - { - f.Key("TANGENT"); f.GenSerialize(value.TANGENT); - } - - if(value.TEXCOORD_0!=-1) - { - f.Key("TEXCOORD_0"); f.GenSerialize(value.TEXCOORD_0); - } - - if(value.COLOR_0!=-1) - { - f.Key("COLOR_0"); f.GenSerialize(value.COLOR_0); - } - - if(value.JOINTS_0!=-1) - { - f.Key("JOINTS_0"); f.GenSerialize(value.JOINTS_0); - } - - if(value.WEIGHTS_0!=-1) - { - f.Key("WEIGHTS_0"); f.GenSerialize(value.WEIGHTS_0); - } - - f.EndMap(); - } - - /// gltf/meshes[]/primitives[]/targets - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/meshes[]/primitives[]/targets[] - public static void GenSerialize(this IFormatter f, gltfMorphTarget value) - { - f.BeginMap(0); // dummy - - if(value.POSITION!=-1) - { - f.Key("POSITION"); f.GenSerialize(value.POSITION); - } - - if(value.NORMAL!=-1) - { - f.Key("NORMAL"); f.GenSerialize(value.NORMAL); - } - - if(value.TANGENT!=-1) - { - f.Key("TANGENT"); f.GenSerialize(value.TANGENT); - } - - f.EndMap(); - } - - /// gltf/meshes[]/primitives[]/extras - public static void GenSerialize(this IFormatter f, glTFPrimitives_extras value) - { - f.BeginMap(0); // dummy - - if(value.targetNames!=null) - { - f.Key("targetNames"); f.GenSerialize(value.targetNames); - } - - f.EndMap(); - } - - /// gltf/meshes[]/primitives[]/extras/targetNames - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/meshes[]/primitives[]/extensions - public static void GenSerialize(this IFormatter f, glTFPrimitives_extensions value) - { - f.BeginMap(0); // dummy - - f.EndMap(); - } - - /// gltf/meshes[]/extras - public static void GenSerialize(this IFormatter f, glTFMesh_extras value) - { - f.BeginMap(0); // dummy - - if(value.targetNames!=null) - { - f.Key("targetNames"); f.GenSerialize(value.targetNames); - } - - f.EndMap(); - } - - /// gltf/nodes - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/nodes[] - public static void GenSerialize(this IFormatter f, glTFNode value) - { - f.BeginMap(0); // dummy - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - if(value.children != null && value.children.Length>0) - { - f.Key("children"); f.GenSerialize(value.children); - } - - if(value.matrix!=null) - { - f.Key("matrix"); f.GenSerialize(value.matrix); - } - - if(value.translation!=null) - { - f.Key("translation"); f.GenSerialize(value.translation); - } - - if(value.rotation!=null) - { - f.Key("rotation"); f.GenSerialize(value.rotation); - } - - if(value.scale!=null) - { - f.Key("scale"); f.GenSerialize(value.scale); - } - - if(value.mesh!=-1) - { - f.Key("mesh"); f.GenSerialize(value.mesh); - } - - if(value.skin!=-1) - { - f.Key("skin"); f.GenSerialize(value.skin); - } - - if(value.weights!=null) - { - f.Key("weights"); f.GenSerialize(value.weights); - } - - if(value.camera!=-1) - { - f.Key("camera"); f.GenSerialize(value.camera); - } - - f.EndMap(); - } - - /// gltf/nodes[]/children - public static void GenSerialize(this IFormatter f, Int32[] value) - { - f.BeginList(value.Length); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/nodes[]/extensions - public static void GenSerialize(this IFormatter f, glTFNode_extensions value) - { - f.BeginMap(0); // dummy - - f.EndMap(); - } - - /// gltf/nodes[]/extras - public static void GenSerialize(this IFormatter f, glTFNode_extra value) - { - f.BeginMap(0); // dummy - - f.EndMap(); - } - - /// gltf/skins - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/skins[] - public static void GenSerialize(this IFormatter f, glTFSkin value) - { - f.BeginMap(0); // dummy - - - { - f.Key("inverseBindMatrices"); f.GenSerialize(value.inverseBindMatrices); - } - - if(value.joints!=null && value.joints.Length>0) - { - f.Key("joints"); f.GenSerialize(value.joints); - } - - if(value.skeleton!=-1) - { - f.Key("skeleton"); f.GenSerialize(value.skeleton); - } - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - f.EndMap(); - } - - /// gltf/scenes - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/scenes[] - public static void GenSerialize(this IFormatter f, gltfScene value) - { - f.BeginMap(0); // dummy - - if(value.nodes!=null && value.nodes.Length>0) - { - f.Key("nodes"); f.GenSerialize(value.nodes); - } - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - f.EndMap(); - } - - /// gltf/animations - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/animations[] - public static void GenSerialize(this IFormatter f, glTFAnimation value) - { - f.BeginMap(0); // dummy - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - if(value.channels!=null && value.channels.Count>0) - { - f.Key("channels"); f.GenSerialize(value.channels); - } - - if(value.samplers!=null && value.samplers.Count>0) - { - f.Key("samplers"); f.GenSerialize(value.samplers); - } - - f.EndMap(); - } - - /// gltf/animations[]/channels - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/animations[]/channels[] - public static void GenSerialize(this IFormatter f, glTFAnimationChannel value) - { - f.BeginMap(0); // dummy - - - { - f.Key("sampler"); f.GenSerialize(value.sampler); - } - - if(value!=null) - { - f.Key("target"); f.GenSerialize(value.target); - } - - f.EndMap(); - } - - /// gltf/animations[]/channels[]/target - public static void GenSerialize(this IFormatter f, glTFAnimationTarget value) - { - f.BeginMap(0); // dummy - - - { - f.Key("node"); f.GenSerialize(value.node); - } - - if(value.path!=null) - { - f.Key("path"); f.GenSerialize(value.path); - } - - f.EndMap(); - } - - /// gltf/animations[]/samplers - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/animations[]/samplers[] - public static void GenSerialize(this IFormatter f, glTFAnimationSampler value) - { - f.BeginMap(0); // dummy - - - { - f.Key("input"); f.GenSerialize(value.input); - } - - if(value.interpolation!=null) - { - f.Key("interpolation"); f.GenSerialize(value.interpolation); - } - - - { - f.Key("output"); f.GenSerialize(value.output); - } - - f.EndMap(); - } - - /// gltf/cameras - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/cameras[] - public static void GenSerialize(this IFormatter f, glTFCamera value) - { - f.BeginMap(0); // dummy - - if(value.orthographic!=null) - { - f.Key("orthographic"); f.GenSerialize(value.orthographic); - } - - if(value.perspective!=null) - { - f.Key("perspective"); f.GenSerialize(value.perspective); - } - - - { - f.Key("type"); f.GenSerialize(value.type); - } - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - f.EndMap(); - } - - /// gltf/cameras[]/orthographic - public static void GenSerialize(this IFormatter f, glTFOrthographic value) - { - f.BeginMap(0); // dummy - - - { - f.Key("xmag"); f.GenSerialize(value.xmag); - } - - - { - f.Key("ymag"); f.GenSerialize(value.ymag); - } - - - { - f.Key("zfar"); f.GenSerialize(value.zfar); - } - - - { - f.Key("znear"); f.GenSerialize(value.znear); - } - - f.EndMap(); - } - - /// gltf/cameras[]/orthographic/extensions - public static void GenSerialize(this IFormatter f, glTFOrthographic_extensions value) - { - f.BeginMap(0); // dummy - - f.EndMap(); - } - - /// gltf/cameras[]/orthographic/extras - public static void GenSerialize(this IFormatter f, glTFOrthographic_extras value) - { - f.BeginMap(0); // dummy - - f.EndMap(); - } - - /// gltf/cameras[]/perspective - public static void GenSerialize(this IFormatter f, glTFPerspective value) - { - f.BeginMap(0); // dummy - - - { - f.Key("aspectRatio"); f.GenSerialize(value.aspectRatio); - } - - - { - f.Key("yfov"); f.GenSerialize(value.yfov); - } - - - { - f.Key("zfar"); f.GenSerialize(value.zfar); - } - - - { - f.Key("znear"); f.GenSerialize(value.znear); - } - - f.EndMap(); - } - - /// gltf/cameras[]/perspective/extensions - public static void GenSerialize(this IFormatter f, glTFPerspective_extensions value) - { - f.BeginMap(0); // dummy - - f.EndMap(); - } - - /// gltf/cameras[]/perspective/extras - public static void GenSerialize(this IFormatter f, glTFPerspective_extras value) - { - f.BeginMap(0); // dummy - - f.EndMap(); - } - - public static void GenSerialize(this IFormatter f, ProjectionType value) - { - f.Value((int)value); - } - - /// gltf/cameras[]/extensions - public static void GenSerialize(this IFormatter f, glTFCamera_extensions value) - { - f.BeginMap(0); // dummy - - f.EndMap(); - } - - /// gltf/cameras[]/extras - public static void GenSerialize(this IFormatter f, glTFCamera_extras value) - { - f.BeginMap(0); // dummy - - f.EndMap(); - } - - /// gltf/extensions - public static void GenSerialize(this IFormatter f, glTF_extensions value) - { - f.BeginMap(0); // dummy - - if(value.VRM!=null) - { - f.Key("VRM"); f.GenSerialize(value.VRM); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM - public static void GenSerialize(this IFormatter f, glTF_VRM_extensions value) - { - f.BeginMap(0); // dummy - - if(value.exporterVersion!=null) - { - f.Key("exporterVersion"); f.GenSerialize(value.exporterVersion); - } - - if(value.specVersion!=null) - { - f.Key("specVersion"); f.GenSerialize(value.specVersion); - } - - if(value.meta!=null) - { - f.Key("meta"); f.GenSerialize(value.meta); - } - - if(value.humanoid!=null) - { - f.Key("humanoid"); f.GenSerialize(value.humanoid); - } - - if(value.firstPerson!=null) - { - f.Key("firstPerson"); f.GenSerialize(value.firstPerson); - } - - if(value.blendShapeMaster!=null) - { - f.Key("blendShapeMaster"); f.GenSerialize(value.blendShapeMaster); - } - - if(value.secondaryAnimation!=null) - { - f.Key("secondaryAnimation"); f.GenSerialize(value.secondaryAnimation); - } - - if(value.materialProperties!=null) - { - f.Key("materialProperties"); f.GenSerialize(value.materialProperties); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/meta - public static void GenSerialize(this IFormatter f, glTF_VRM_Meta value) - { - f.BeginMap(0); // dummy - - if(value.title!=null) - { - f.Key("title"); f.GenSerialize(value.title); - } - - if(value.version!=null) - { - f.Key("version"); f.GenSerialize(value.version); - } - - if(value.author!=null) - { - f.Key("author"); f.GenSerialize(value.author); - } - - if(value.contactInformation!=null) - { - f.Key("contactInformation"); f.GenSerialize(value.contactInformation); - } - - if(value.reference!=null) - { - f.Key("reference"); f.GenSerialize(value.reference); - } - - - { - f.Key("texture"); f.GenSerialize(value.texture); - } - - if(value.allowedUserName!=null) - { - f.Key("allowedUserName"); f.GenSerialize(value.allowedUserName); - } - - if(value.violentUssageName!=null) - { - f.Key("violentUssageName"); f.GenSerialize(value.violentUssageName); - } - - if(value.sexualUssageName!=null) - { - f.Key("sexualUssageName"); f.GenSerialize(value.sexualUssageName); - } - - if(value.commercialUssageName!=null) - { - f.Key("commercialUssageName"); f.GenSerialize(value.commercialUssageName); - } - - if(value.otherPermissionUrl!=null) - { - f.Key("otherPermissionUrl"); f.GenSerialize(value.otherPermissionUrl); - } - - if(value.licenseName!=null) - { - f.Key("licenseName"); f.GenSerialize(value.licenseName); - } - - if(value.otherLicenseUrl!=null) - { - f.Key("otherLicenseUrl"); f.GenSerialize(value.otherLicenseUrl); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/humanoid - public static void GenSerialize(this IFormatter f, glTF_VRM_Humanoid value) - { - f.BeginMap(0); // dummy - - if(value.humanBones!=null) - { - f.Key("humanBones"); f.GenSerialize(value.humanBones); - } - - - { - f.Key("armStretch"); f.GenSerialize(value.armStretch); - } - - - { - f.Key("legStretch"); f.GenSerialize(value.legStretch); - } - - - { - f.Key("upperArmTwist"); f.GenSerialize(value.upperArmTwist); - } - - - { - f.Key("lowerArmTwist"); f.GenSerialize(value.lowerArmTwist); - } - - - { - f.Key("upperLegTwist"); f.GenSerialize(value.upperLegTwist); - } - - - { - f.Key("lowerLegTwist"); f.GenSerialize(value.lowerLegTwist); - } - - - { - f.Key("feetSpacing"); f.GenSerialize(value.feetSpacing); - } - - - { - f.Key("hasTranslationDoF"); f.GenSerialize(value.hasTranslationDoF); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/humanoid/humanBones - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/extensions/VRM/humanoid/humanBones[] - public static void GenSerialize(this IFormatter f, glTF_VRM_HumanoidBone value) - { - f.BeginMap(0); // dummy - - if(value.bone!=null) - { - f.Key("bone"); f.GenSerialize(value.bone); - } - - - { - f.Key("node"); f.GenSerialize(value.node); - } - - - { - f.Key("useDefaultValues"); f.GenSerialize(value.useDefaultValues); - } - - if(value.min!=Vector3.zero) - { - f.Key("min"); f.GenSerialize(value.min); - } - - if(value.max!=Vector3.zero) - { - f.Key("max"); f.GenSerialize(value.max); - } - - if(value.center!=Vector3.zero) - { - f.Key("center"); f.GenSerialize(value.center); - } - - if(value.axisLength>0) - { - f.Key("axisLength"); f.GenSerialize(value.axisLength); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/humanoid/humanBones[]/min - public static void GenSerialize(this IFormatter f, Vector3 value) - { - f.BeginMap(0); // dummy - - - { - f.Key("x"); f.GenSerialize(value.x); - } - - - { - f.Key("y"); f.GenSerialize(value.y); - } - - - { - f.Key("z"); f.GenSerialize(value.z); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/firstPerson - public static void GenSerialize(this IFormatter f, glTF_VRM_Firstperson value) - { - f.BeginMap(0); // dummy - - - { - f.Key("firstPersonBone"); f.GenSerialize(value.firstPersonBone); - } - - - { - f.Key("firstPersonBoneOffset"); f.GenSerialize(value.firstPersonBoneOffset); - } - - if(value.meshAnnotations!=null) - { - f.Key("meshAnnotations"); f.GenSerialize(value.meshAnnotations); - } - - if(value.lookAtTypeName!=null) - { - f.Key("lookAtTypeName"); f.GenSerialize(value.lookAtTypeName); - } - - if(value.lookAtHorizontalInner!=null) - { - f.Key("lookAtHorizontalInner"); f.GenSerialize(value.lookAtHorizontalInner); - } - - if(value.lookAtHorizontalOuter!=null) - { - f.Key("lookAtHorizontalOuter"); f.GenSerialize(value.lookAtHorizontalOuter); - } - - if(value.lookAtVerticalDown!=null) - { - f.Key("lookAtVerticalDown"); f.GenSerialize(value.lookAtVerticalDown); - } - - if(value.lookAtVerticalUp!=null) - { - f.Key("lookAtVerticalUp"); f.GenSerialize(value.lookAtVerticalUp); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/firstPerson/meshAnnotations - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/extensions/VRM/firstPerson/meshAnnotations[] - public static void GenSerialize(this IFormatter f, glTF_VRM_MeshAnnotation value) - { - f.BeginMap(0); // dummy - - - { - f.Key("mesh"); f.GenSerialize(value.mesh); - } - - if(value.firstPersonFlag!=null) - { - f.Key("firstPersonFlag"); f.GenSerialize(value.firstPersonFlag); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/firstPerson/lookAtHorizontalInner - public static void GenSerialize(this IFormatter f, glTF_VRM_DegreeMap value) - { - f.BeginMap(0); // dummy - - if(value.curve!=null) - { - f.Key("curve"); f.GenSerialize(value.curve); - } - - - { - f.Key("xRange"); f.GenSerialize(value.xRange); - } - - - { - f.Key("yRange"); f.GenSerialize(value.yRange); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/blendShapeMaster - public static void GenSerialize(this IFormatter f, glTF_VRM_BlendShapeMaster value) - { - f.BeginMap(0); // dummy - - if(value.blendShapeGroups!=null) - { - f.Key("blendShapeGroups"); f.GenSerialize(value.blendShapeGroups); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[] - public static void GenSerialize(this IFormatter f, glTF_VRM_BlendShapeGroup value) - { - f.BeginMap(0); // dummy - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - if(value.presetName!=null) - { - f.Key("presetName"); f.GenSerialize(value.presetName); - } - - if(value.binds!=null) - { - f.Key("binds"); f.GenSerialize(value.binds); - } - - if(value.materialValues!=null) - { - f.Key("materialValues"); f.GenSerialize(value.materialValues); - } - - - { - f.Key("isBinary"); f.GenSerialize(value.isBinary); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/binds - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/binds[] - public static void GenSerialize(this IFormatter f, glTF_VRM_BlendShapeBind value) - { - f.BeginMap(0); // dummy - - - { - f.Key("mesh"); f.GenSerialize(value.mesh); - } - - - { - f.Key("index"); f.GenSerialize(value.index); - } - - - { - f.Key("weight"); f.GenSerialize(value.weight); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/materialValues - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/materialValues[] - public static void GenSerialize(this IFormatter f, glTF_VRM_MaterialValueBind value) - { - f.BeginMap(0); // dummy - - if(value.materialName!=null) - { - f.Key("materialName"); f.GenSerialize(value.materialName); - } - - if(value.propertyName!=null) - { - f.Key("propertyName"); f.GenSerialize(value.propertyName); - } - - if(value.targetValue!=null) - { - f.Key("targetValue"); f.GenSerialize(value.targetValue); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/secondaryAnimation - public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimation value) - { - f.BeginMap(0); // dummy - - if(value.boneGroups!=null) - { - f.Key("boneGroups"); f.GenSerialize(value.boneGroups); - } - - if(value.colliderGroups!=null) - { - f.Key("colliderGroups"); f.GenSerialize(value.colliderGroups); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/secondaryAnimation/boneGroups - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/extensions/VRM/secondaryAnimation/boneGroups[] - public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimationGroup value) - { - f.BeginMap(0); // dummy - - if(value.comment!=null) - { - f.Key("comment"); f.GenSerialize(value.comment); - } - - - { - f.Key("stiffiness"); f.GenSerialize(value.stiffiness); - } - - - { - f.Key("gravityPower"); f.GenSerialize(value.gravityPower); - } - - - { - f.Key("gravityDir"); f.GenSerialize(value.gravityDir); - } - - - { - f.Key("dragForce"); f.GenSerialize(value.dragForce); - } - - - { - f.Key("center"); f.GenSerialize(value.center); - } - - - { - f.Key("hitRadius"); f.GenSerialize(value.hitRadius); - } - - if(value.bones!=null) - { - f.Key("bones"); f.GenSerialize(value.bones); - } - - if(value.colliderGroups!=null) - { - f.Key("colliderGroups"); f.GenSerialize(value.colliderGroups); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/secondaryAnimation/colliderGroups - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/extensions/VRM/secondaryAnimation/colliderGroups[] - public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimationColliderGroup value) - { - f.BeginMap(0); // dummy - - - { - f.Key("node"); f.GenSerialize(value.node); - } - - if(value.colliders!=null) - { - f.Key("colliders"); f.GenSerialize(value.colliders); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/secondaryAnimation/colliderGroups[]/colliders - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/extensions/VRM/secondaryAnimation/colliderGroups[]/colliders[] - public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimationCollider value) - { - f.BeginMap(0); // dummy - - - { - f.Key("offset"); f.GenSerialize(value.offset); - } - - - { - f.Key("radius"); f.GenSerialize(value.radius); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/materialProperties - public static void GenSerialize(this IFormatter f, List value) - { - f.BeginList(value.Count); - foreach (var x in value) - { - f.GenSerialize(x); - } - f.EndList(); - } - - /// gltf/extensions/VRM/materialProperties[] - public static void GenSerialize(this IFormatter f, glTF_VRM_Material value) - { - f.BeginMap(0); // dummy - - if(value.name!=null) - { - f.Key("name"); f.GenSerialize(value.name); - } - - if(value.shader!=null) - { - f.Key("shader"); f.GenSerialize(value.shader); - } - - - { - f.Key("renderQueue"); f.GenSerialize(value.renderQueue); - } - - if(value.floatProperties!=null) - { - f.Key("floatProperties"); f.GenSerialize(value.floatProperties); - } - - if(value.vectorProperties!=null) - { - f.Key("vectorProperties"); f.GenSerialize(value.vectorProperties); - } - - if(value.textureProperties!=null) - { - f.Key("textureProperties"); f.GenSerialize(value.textureProperties); - } - - if(value.keywordMap!=null) - { - f.Key("keywordMap"); f.GenSerialize(value.keywordMap); - } - - if(value.tagMap!=null) - { - f.Key("tagMap"); f.GenSerialize(value.tagMap); - } - - f.EndMap(); - } - - /// gltf/extensions/VRM/materialProperties[]/floatProperties - public static void GenSerialize(this IFormatter f, Dictionary value) - { - f.BeginMap(value.Count); - foreach (var kv in value) - { - f.Key(kv.Key); - f.GenSerialize(kv.Value); - } - f.EndMap(); - } - - - /// gltf/extensions/VRM/materialProperties[]/vectorProperties - public static void GenSerialize(this IFormatter f, Dictionary value) - { - f.BeginMap(value.Count); - foreach (var kv in value) - { - f.Key(kv.Key); - f.GenSerialize(kv.Value); - } - f.EndMap(); - } - - - /// gltf/extensions/VRM/materialProperties[]/textureProperties - public static void GenSerialize(this IFormatter f, Dictionary value) - { - f.BeginMap(value.Count); - foreach (var kv in value) - { - f.Key(kv.Key); - f.GenSerialize(kv.Value); - } - f.EndMap(); - } - - - /// gltf/extensions/VRM/materialProperties[]/keywordMap - public static void GenSerialize(this IFormatter f, Dictionary value) - { - f.BeginMap(value.Count); - foreach (var kv in value) - { - f.Key(kv.Key); - f.GenSerialize(kv.Value); - } - f.EndMap(); - } - - - /// gltf/extensions/VRM/materialProperties[]/tagMap - public static void GenSerialize(this IFormatter f, Dictionary value) - { - f.BeginMap(value.Count); - foreach (var kv in value) - { - f.Key(kv.Key); - f.GenSerialize(kv.Value); - } - f.EndMap(); - } - - - /// gltf/extras - public static void GenSerialize(this IFormatter f, gltf_extras value) - { - f.BeginMap(0); // dummy - - f.EndMap(); - } - - } // class -} // namespace diff --git a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs.meta b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs.meta deleted file mode 100644 index 71ef3c0ad..000000000 --- a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 972f1c538db788042863a4ac753dbc04 -timeCreated: 1564987956 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs b/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs deleted file mode 100644 index 2912ba9b1..000000000 --- a/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs +++ /dev/null @@ -1,3175 +0,0 @@ - -using UniJSON; -using System; -using System.Collections.Generic; -using VRM; -using UnityEngine; - -namespace UniGLTF { - -public static class GltfDeserializer -{ - - -public static glTF Deserialize(ListTreeNode parsed) -{ - var value = new glTF(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="asset"){ - value.asset = Deserialize_gltf_asset(kv.Value); - continue; - } - - if(key=="buffers"){ - value.buffers = Deserialize_gltf_buffers(kv.Value); - continue; - } - - if(key=="bufferViews"){ - value.bufferViews = Deserialize_gltf_bufferViews(kv.Value); - continue; - } - - if(key=="accessors"){ - value.accessors = Deserialize_gltf_accessors(kv.Value); - continue; - } - - if(key=="textures"){ - value.textures = Deserialize_gltf_textures(kv.Value); - continue; - } - - if(key=="samplers"){ - value.samplers = Deserialize_gltf_samplers(kv.Value); - continue; - } - - if(key=="images"){ - value.images = Deserialize_gltf_images(kv.Value); - continue; - } - - if(key=="materials"){ - value.materials = Deserialize_gltf_materials(kv.Value); - continue; - } - - if(key=="meshes"){ - value.meshes = Deserialize_gltf_meshes(kv.Value); - continue; - } - - if(key=="nodes"){ - value.nodes = Deserialize_gltf_nodes(kv.Value); - continue; - } - - if(key=="skins"){ - value.skins = Deserialize_gltf_skins(kv.Value); - continue; - } - - if(key=="scene"){ - value.scene = kv.Value.GetInt32(); - continue; - } - - if(key=="scenes"){ - value.scenes = Deserialize_gltf_scenes(kv.Value); - continue; - } - - if(key=="animations"){ - value.animations = Deserialize_gltf_animations(kv.Value); - continue; - } - - if(key=="cameras"){ - value.cameras = Deserialize_gltf_cameras(kv.Value); - continue; - } - - if(key=="extensionsUsed"){ - value.extensionsUsed = Deserialize_gltf_extensionsUsed(kv.Value); - continue; - } - - if(key=="extensionsRequired"){ - value.extensionsRequired = Deserialize_gltf_extensionsRequired(kv.Value); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_extensions(kv.Value); - continue; - } - - if(key=="extras"){ - value.extras = Deserialize_gltf_extras(kv.Value); - continue; - } - - } - return value; -} - -public static glTFAssets Deserialize_gltf_asset(ListTreeNode parsed) -{ - var value = new glTFAssets(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="generator"){ - value.generator = kv.Value.GetString(); - continue; - } - - if(key=="version"){ - value.version = kv.Value.GetString(); - continue; - } - - if(key=="copyright"){ - value.copyright = kv.Value.GetString(); - continue; - } - - if(key=="minVersion"){ - value.minVersion = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_buffers(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_buffers_LIST(x)); - } - return value; -} -public static glTFBuffer Deserialize_gltf_buffers_LIST(ListTreeNode parsed) -{ - var value = new glTFBuffer(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="uri"){ - value.uri = kv.Value.GetString(); - continue; - } - - if(key=="byteLength"){ - value.byteLength = kv.Value.GetInt32(); - continue; - } - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_bufferViews(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_bufferViews_LIST(x)); - } - return value; -} -public static glTFBufferView Deserialize_gltf_bufferViews_LIST(ListTreeNode parsed) -{ - var value = new glTFBufferView(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="buffer"){ - value.buffer = kv.Value.GetInt32(); - continue; - } - - if(key=="byteOffset"){ - value.byteOffset = kv.Value.GetInt32(); - continue; - } - - if(key=="byteLength"){ - value.byteLength = kv.Value.GetInt32(); - continue; - } - - if(key=="byteStride"){ - value.byteStride = kv.Value.GetInt32(); - continue; - } - - if(key=="target"){ - value.target = (glBufferTarget)kv.Value.GetInt32(); - continue; - } - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_accessors(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_accessors_LIST(x)); - } - return value; -} -public static glTFAccessor Deserialize_gltf_accessors_LIST(ListTreeNode parsed) -{ - var value = new glTFAccessor(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="bufferView"){ - value.bufferView = kv.Value.GetInt32(); - continue; - } - - if(key=="byteOffset"){ - value.byteOffset = kv.Value.GetInt32(); - continue; - } - - if(key=="type"){ - value.type = kv.Value.GetString(); - continue; - } - - if(key=="componentType"){ - value.componentType = (glComponentType)kv.Value.GetInt32(); - continue; - } - - if(key=="count"){ - value.count = kv.Value.GetInt32(); - continue; - } - - if(key=="max"){ - value.max = Deserialize_gltf_accessors__max(kv.Value); - continue; - } - - if(key=="min"){ - value.min = Deserialize_gltf_accessors__min(kv.Value); - continue; - } - - if(key=="normalized"){ - value.normalized = kv.Value.GetBoolean(); - continue; - } - - if(key=="sparse"){ - value.sparse = Deserialize_gltf_accessors__sparse(kv.Value); - continue; - } - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static Single[] Deserialize_gltf_accessors__max(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_accessors__min(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTFSparse Deserialize_gltf_accessors__sparse(ListTreeNode parsed) -{ - var value = new glTFSparse(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="count"){ - value.count = kv.Value.GetInt32(); - continue; - } - - if(key=="indices"){ - value.indices = Deserialize_gltf_accessors__sparse_indices(kv.Value); - continue; - } - - if(key=="values"){ - value.values = Deserialize_gltf_accessors__sparse_values(kv.Value); - continue; - } - - } - return value; -} - -public static glTFSparseIndices Deserialize_gltf_accessors__sparse_indices(ListTreeNode parsed) -{ - var value = new glTFSparseIndices(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="bufferView"){ - value.bufferView = kv.Value.GetInt32(); - continue; - } - - if(key=="byteOffset"){ - value.byteOffset = kv.Value.GetInt32(); - continue; - } - - if(key=="componentType"){ - value.componentType = (glComponentType)kv.Value.GetInt32(); - continue; - } - - } - return value; -} - -public static glTFSparseValues Deserialize_gltf_accessors__sparse_values(ListTreeNode parsed) -{ - var value = new glTFSparseValues(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="bufferView"){ - value.bufferView = kv.Value.GetInt32(); - continue; - } - - if(key=="byteOffset"){ - value.byteOffset = kv.Value.GetInt32(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_textures(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_textures_LIST(x)); - } - return value; -} -public static glTFTexture Deserialize_gltf_textures_LIST(ListTreeNode parsed) -{ - var value = new glTFTexture(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="sampler"){ - value.sampler = kv.Value.GetInt32(); - continue; - } - - if(key=="source"){ - value.source = kv.Value.GetInt32(); - continue; - } - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_samplers(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_samplers_LIST(x)); - } - return value; -} -public static glTFTextureSampler Deserialize_gltf_samplers_LIST(ListTreeNode parsed) -{ - var value = new glTFTextureSampler(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="magFilter"){ - value.magFilter = (glFilter)kv.Value.GetInt32(); - continue; - } - - if(key=="minFilter"){ - value.minFilter = (glFilter)kv.Value.GetInt32(); - continue; - } - - if(key=="wrapS"){ - value.wrapS = (glWrap)kv.Value.GetInt32(); - continue; - } - - if(key=="wrapT"){ - value.wrapT = (glWrap)kv.Value.GetInt32(); - continue; - } - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_images(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_images_LIST(x)); - } - return value; -} -public static glTFImage Deserialize_gltf_images_LIST(ListTreeNode parsed) -{ - var value = new glTFImage(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - if(key=="uri"){ - value.uri = kv.Value.GetString(); - continue; - } - - if(key=="bufferView"){ - value.bufferView = kv.Value.GetInt32(); - continue; - } - - if(key=="mimeType"){ - value.mimeType = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_materials(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_materials_LIST(x)); - } - return value; -} -public static glTFMaterial Deserialize_gltf_materials_LIST(ListTreeNode parsed) -{ - var value = new glTFMaterial(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - if(key=="pbrMetallicRoughness"){ - value.pbrMetallicRoughness = Deserialize_gltf_materials__pbrMetallicRoughness(kv.Value); - continue; - } - - if(key=="normalTexture"){ - value.normalTexture = Deserialize_gltf_materials__normalTexture(kv.Value); - continue; - } - - if(key=="occlusionTexture"){ - value.occlusionTexture = Deserialize_gltf_materials__occlusionTexture(kv.Value); - continue; - } - - if(key=="emissiveTexture"){ - value.emissiveTexture = Deserialize_gltf_materials__emissiveTexture(kv.Value); - continue; - } - - if(key=="emissiveFactor"){ - value.emissiveFactor = Deserialize_gltf_materials__emissiveFactor(kv.Value); - continue; - } - - if(key=="alphaMode"){ - value.alphaMode = kv.Value.GetString(); - continue; - } - - if(key=="alphaCutoff"){ - value.alphaCutoff = kv.Value.GetSingle(); - continue; - } - - if(key=="doubleSided"){ - value.doubleSided = kv.Value.GetBoolean(); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_materials__extensions(kv.Value); - continue; - } - - } - return value; -} - -public static glTFPbrMetallicRoughness Deserialize_gltf_materials__pbrMetallicRoughness(ListTreeNode parsed) -{ - var value = new glTFPbrMetallicRoughness(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="baseColorTexture"){ - value.baseColorTexture = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(kv.Value); - continue; - } - - if(key=="baseColorFactor"){ - value.baseColorFactor = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(kv.Value); - continue; - } - - if(key=="metallicRoughnessTexture"){ - value.metallicRoughnessTexture = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture(kv.Value); - continue; - } - - if(key=="metallicFactor"){ - value.metallicFactor = kv.Value.GetSingle(); - continue; - } - - if(key=="roughnessFactor"){ - value.roughnessFactor = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static glTFMaterialBaseColorTextureInfo Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture(ListTreeNode parsed) -{ - var value = new glTFMaterialBaseColorTextureInfo(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="index"){ - value.index = kv.Value.GetInt32(); - continue; - } - - if(key=="texCoord"){ - value.texCoord = kv.Value.GetInt32(); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions(kv.Value); - continue; - } - - } - return value; -} - -public static glTFTextureInfo_extensions Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions(ListTreeNode parsed) -{ - var value = new glTFTextureInfo_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="KHR_texture_transform"){ - value.KHR_texture_transform = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform(kv.Value); - continue; - } - - } - return value; -} - -public static glTF_KHR_texture_transform Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform(ListTreeNode parsed) -{ - var value = new glTF_KHR_texture_transform(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="offset"){ - value.offset = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform_offset(kv.Value); - continue; - } - - if(key=="rotation"){ - value.rotation = kv.Value.GetSingle(); - continue; - } - - if(key=="scale"){ - value.scale = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform_scale(kv.Value); - continue; - } - - if(key=="texCoord"){ - value.texCoord = kv.Value.GetInt32(); - continue; - } - - } - return value; -} - -public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform_offset(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform_scale(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_baseColorFactor(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTFMaterialMetallicRoughnessTextureInfo Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture(ListTreeNode parsed) -{ - var value = new glTFMaterialMetallicRoughnessTextureInfo(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="index"){ - value.index = kv.Value.GetInt32(); - continue; - } - - if(key=="texCoord"){ - value.texCoord = kv.Value.GetInt32(); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions(kv.Value); - continue; - } - - } - return value; -} - -public static glTFTextureInfo_extensions Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions(ListTreeNode parsed) -{ - var value = new glTFTextureInfo_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="KHR_texture_transform"){ - value.KHR_texture_transform = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform(kv.Value); - continue; - } - - } - return value; -} - -public static glTF_KHR_texture_transform Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform(ListTreeNode parsed) -{ - var value = new glTF_KHR_texture_transform(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="offset"){ - value.offset = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform_offset(kv.Value); - continue; - } - - if(key=="rotation"){ - value.rotation = kv.Value.GetSingle(); - continue; - } - - if(key=="scale"){ - value.scale = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform_scale(kv.Value); - continue; - } - - if(key=="texCoord"){ - value.texCoord = kv.Value.GetInt32(); - continue; - } - - } - return value; -} - -public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform_offset(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform_scale(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTFMaterialNormalTextureInfo Deserialize_gltf_materials__normalTexture(ListTreeNode parsed) -{ - var value = new glTFMaterialNormalTextureInfo(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="scale"){ - value.scale = kv.Value.GetSingle(); - continue; - } - - if(key=="index"){ - value.index = kv.Value.GetInt32(); - continue; - } - - if(key=="texCoord"){ - value.texCoord = kv.Value.GetInt32(); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_materials__normalTexture_extensions(kv.Value); - continue; - } - - } - return value; -} - -public static glTFTextureInfo_extensions Deserialize_gltf_materials__normalTexture_extensions(ListTreeNode parsed) -{ - var value = new glTFTextureInfo_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="KHR_texture_transform"){ - value.KHR_texture_transform = Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform(kv.Value); - continue; - } - - } - return value; -} - -public static glTF_KHR_texture_transform Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform(ListTreeNode parsed) -{ - var value = new glTF_KHR_texture_transform(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="offset"){ - value.offset = Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform_offset(kv.Value); - continue; - } - - if(key=="rotation"){ - value.rotation = kv.Value.GetSingle(); - continue; - } - - if(key=="scale"){ - value.scale = Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform_scale(kv.Value); - continue; - } - - if(key=="texCoord"){ - value.texCoord = kv.Value.GetInt32(); - continue; - } - - } - return value; -} - -public static Single[] Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform_offset(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform_scale(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTFMaterialOcclusionTextureInfo Deserialize_gltf_materials__occlusionTexture(ListTreeNode parsed) -{ - var value = new glTFMaterialOcclusionTextureInfo(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="strength"){ - value.strength = kv.Value.GetSingle(); - continue; - } - - if(key=="index"){ - value.index = kv.Value.GetInt32(); - continue; - } - - if(key=="texCoord"){ - value.texCoord = kv.Value.GetInt32(); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_materials__occlusionTexture_extensions(kv.Value); - continue; - } - - } - return value; -} - -public static glTFTextureInfo_extensions Deserialize_gltf_materials__occlusionTexture_extensions(ListTreeNode parsed) -{ - var value = new glTFTextureInfo_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="KHR_texture_transform"){ - value.KHR_texture_transform = Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform(kv.Value); - continue; - } - - } - return value; -} - -public static glTF_KHR_texture_transform Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform(ListTreeNode parsed) -{ - var value = new glTF_KHR_texture_transform(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="offset"){ - value.offset = Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform_offset(kv.Value); - continue; - } - - if(key=="rotation"){ - value.rotation = kv.Value.GetSingle(); - continue; - } - - if(key=="scale"){ - value.scale = Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform_scale(kv.Value); - continue; - } - - if(key=="texCoord"){ - value.texCoord = kv.Value.GetInt32(); - continue; - } - - } - return value; -} - -public static Single[] Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform_offset(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform_scale(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTFMaterialEmissiveTextureInfo Deserialize_gltf_materials__emissiveTexture(ListTreeNode parsed) -{ - var value = new glTFMaterialEmissiveTextureInfo(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="index"){ - value.index = kv.Value.GetInt32(); - continue; - } - - if(key=="texCoord"){ - value.texCoord = kv.Value.GetInt32(); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_materials__emissiveTexture_extensions(kv.Value); - continue; - } - - } - return value; -} - -public static glTFTextureInfo_extensions Deserialize_gltf_materials__emissiveTexture_extensions(ListTreeNode parsed) -{ - var value = new glTFTextureInfo_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="KHR_texture_transform"){ - value.KHR_texture_transform = Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform(kv.Value); - continue; - } - - } - return value; -} - -public static glTF_KHR_texture_transform Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform(ListTreeNode parsed) -{ - var value = new glTF_KHR_texture_transform(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="offset"){ - value.offset = Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform_offset(kv.Value); - continue; - } - - if(key=="rotation"){ - value.rotation = kv.Value.GetSingle(); - continue; - } - - if(key=="scale"){ - value.scale = Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform_scale(kv.Value); - continue; - } - - if(key=="texCoord"){ - value.texCoord = kv.Value.GetInt32(); - continue; - } - - } - return value; -} - -public static Single[] Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform_offset(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform_scale(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_materials__emissiveFactor(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTFMaterial_extensions Deserialize_gltf_materials__extensions(ListTreeNode parsed) -{ - var value = new glTFMaterial_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="KHR_materials_unlit"){ - value.KHR_materials_unlit = Deserialize_gltf_materials__extensions_KHR_materials_unlit(kv.Value); - continue; - } - - } - return value; -} - -public static glTF_KHR_materials_unlit Deserialize_gltf_materials__extensions_KHR_materials_unlit(ListTreeNode parsed) -{ - var value = new glTF_KHR_materials_unlit(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - } - return value; -} - -public static List Deserialize_gltf_meshes(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_meshes_LIST(x)); - } - return value; -} -public static glTFMesh Deserialize_gltf_meshes_LIST(ListTreeNode parsed) -{ - var value = new glTFMesh(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - if(key=="primitives"){ - value.primitives = Deserialize_gltf_meshes__primitives(kv.Value); - continue; - } - - if(key=="weights"){ - value.weights = Deserialize_gltf_meshes__weights(kv.Value); - continue; - } - - if(key=="extras"){ - value.extras = Deserialize_gltf_meshes__extras(kv.Value); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_meshes__primitives(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_meshes__primitives_LIST(x)); - } - return value; -} -public static glTFPrimitives Deserialize_gltf_meshes__primitives_LIST(ListTreeNode parsed) -{ - var value = new glTFPrimitives(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="mode"){ - value.mode = kv.Value.GetInt32(); - continue; - } - - if(key=="indices"){ - value.indices = kv.Value.GetInt32(); - continue; - } - - if(key=="attributes"){ - value.attributes = Deserialize_gltf_meshes__primitives__attributes(kv.Value); - continue; - } - - if(key=="material"){ - value.material = kv.Value.GetInt32(); - continue; - } - - if(key=="targets"){ - value.targets = Deserialize_gltf_meshes__primitives__targets(kv.Value); - continue; - } - - if(key=="extras"){ - value.extras = Deserialize_gltf_meshes__primitives__extras(kv.Value); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_meshes__primitives__extensions(kv.Value); - continue; - } - - } - return value; -} - -public static glTFAttributes Deserialize_gltf_meshes__primitives__attributes(ListTreeNode parsed) -{ - var value = new glTFAttributes(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="POSITION"){ - value.POSITION = kv.Value.GetInt32(); - continue; - } - - if(key=="NORMAL"){ - value.NORMAL = kv.Value.GetInt32(); - continue; - } - - if(key=="TANGENT"){ - value.TANGENT = kv.Value.GetInt32(); - continue; - } - - if(key=="TEXCOORD_0"){ - value.TEXCOORD_0 = kv.Value.GetInt32(); - continue; - } - - if(key=="COLOR_0"){ - value.COLOR_0 = kv.Value.GetInt32(); - continue; - } - - if(key=="JOINTS_0"){ - value.JOINTS_0 = kv.Value.GetInt32(); - continue; - } - - if(key=="WEIGHTS_0"){ - value.WEIGHTS_0 = kv.Value.GetInt32(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_meshes__primitives__targets(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_meshes__primitives__targets_LIST(x)); - } - return value; -} -public static gltfMorphTarget Deserialize_gltf_meshes__primitives__targets_LIST(ListTreeNode parsed) -{ - var value = new gltfMorphTarget(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="POSITION"){ - value.POSITION = kv.Value.GetInt32(); - continue; - } - - if(key=="NORMAL"){ - value.NORMAL = kv.Value.GetInt32(); - continue; - } - - if(key=="TANGENT"){ - value.TANGENT = kv.Value.GetInt32(); - continue; - } - - } - return value; -} - -public static glTFPrimitives_extras Deserialize_gltf_meshes__primitives__extras(ListTreeNode parsed) -{ - var value = new glTFPrimitives_extras(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="targetNames"){ - value.targetNames = Deserialize_gltf_meshes__primitives__extras_targetNames(kv.Value); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_meshes__primitives__extras_targetNames(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(x.GetString()); - } - return value; -} -public static glTFPrimitives_extensions Deserialize_gltf_meshes__primitives__extensions(ListTreeNode parsed) -{ - var value = new glTFPrimitives_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - } - return value; -} - -public static Single[] Deserialize_gltf_meshes__weights(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTFMesh_extras Deserialize_gltf_meshes__extras(ListTreeNode parsed) -{ - var value = new glTFMesh_extras(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="targetNames"){ - value.targetNames = Deserialize_gltf_meshes__extras_targetNames(kv.Value); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_meshes__extras_targetNames(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(x.GetString()); - } - return value; -} -public static List Deserialize_gltf_nodes(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_nodes_LIST(x)); - } - return value; -} -public static glTFNode Deserialize_gltf_nodes_LIST(ListTreeNode parsed) -{ - var value = new glTFNode(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - if(key=="children"){ - value.children = Deserialize_gltf_nodes__children(kv.Value); - continue; - } - - if(key=="matrix"){ - value.matrix = Deserialize_gltf_nodes__matrix(kv.Value); - continue; - } - - if(key=="translation"){ - value.translation = Deserialize_gltf_nodes__translation(kv.Value); - continue; - } - - if(key=="rotation"){ - value.rotation = Deserialize_gltf_nodes__rotation(kv.Value); - continue; - } - - if(key=="scale"){ - value.scale = Deserialize_gltf_nodes__scale(kv.Value); - continue; - } - - if(key=="mesh"){ - value.mesh = kv.Value.GetInt32(); - continue; - } - - if(key=="skin"){ - value.skin = kv.Value.GetInt32(); - continue; - } - - if(key=="weights"){ - value.weights = Deserialize_gltf_nodes__weights(kv.Value); - continue; - } - - if(key=="camera"){ - value.camera = kv.Value.GetInt32(); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_nodes__extensions(kv.Value); - continue; - } - - if(key=="extras"){ - value.extras = Deserialize_gltf_nodes__extras(kv.Value); - continue; - } - - } - return value; -} - -public static Int32[] Deserialize_gltf_nodes__children(ListTreeNode parsed) -{ - var value = new Int32[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetInt32(); - } - return value; -} - -public static Single[] Deserialize_gltf_nodes__matrix(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_nodes__translation(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_nodes__rotation(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_nodes__scale(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static Single[] Deserialize_gltf_nodes__weights(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTFNode_extensions Deserialize_gltf_nodes__extensions(ListTreeNode parsed) -{ - var value = new glTFNode_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - } - return value; -} - -public static glTFNode_extra Deserialize_gltf_nodes__extras(ListTreeNode parsed) -{ - var value = new glTFNode_extra(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - } - return value; -} - -public static List Deserialize_gltf_skins(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_skins_LIST(x)); - } - return value; -} -public static glTFSkin Deserialize_gltf_skins_LIST(ListTreeNode parsed) -{ - var value = new glTFSkin(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="inverseBindMatrices"){ - value.inverseBindMatrices = kv.Value.GetInt32(); - continue; - } - - if(key=="joints"){ - value.joints = Deserialize_gltf_skins__joints(kv.Value); - continue; - } - - if(key=="skeleton"){ - value.skeleton = kv.Value.GetInt32(); - continue; - } - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static Int32[] Deserialize_gltf_skins__joints(ListTreeNode parsed) -{ - var value = new Int32[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetInt32(); - } - return value; -} - -public static List Deserialize_gltf_scenes(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_scenes_LIST(x)); - } - return value; -} -public static gltfScene Deserialize_gltf_scenes_LIST(ListTreeNode parsed) -{ - var value = new gltfScene(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="nodes"){ - value.nodes = Deserialize_gltf_scenes__nodes(kv.Value); - continue; - } - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static Int32[] Deserialize_gltf_scenes__nodes(ListTreeNode parsed) -{ - var value = new Int32[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetInt32(); - } - return value; -} - -public static List Deserialize_gltf_animations(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_animations_LIST(x)); - } - return value; -} -public static glTFAnimation Deserialize_gltf_animations_LIST(ListTreeNode parsed) -{ - var value = new glTFAnimation(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - if(key=="channels"){ - value.channels = Deserialize_gltf_animations__channels(kv.Value); - continue; - } - - if(key=="samplers"){ - value.samplers = Deserialize_gltf_animations__samplers(kv.Value); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_animations__channels(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_animations__channels_LIST(x)); - } - return value; -} -public static glTFAnimationChannel Deserialize_gltf_animations__channels_LIST(ListTreeNode parsed) -{ - var value = new glTFAnimationChannel(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="sampler"){ - value.sampler = kv.Value.GetInt32(); - continue; - } - - if(key=="target"){ - value.target = Deserialize_gltf_animations__channels__target(kv.Value); - continue; - } - - } - return value; -} - -public static glTFAnimationTarget Deserialize_gltf_animations__channels__target(ListTreeNode parsed) -{ - var value = new glTFAnimationTarget(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="node"){ - value.node = kv.Value.GetInt32(); - continue; - } - - if(key=="path"){ - value.path = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_animations__samplers(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_animations__samplers_LIST(x)); - } - return value; -} -public static glTFAnimationSampler Deserialize_gltf_animations__samplers_LIST(ListTreeNode parsed) -{ - var value = new glTFAnimationSampler(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="input"){ - value.input = kv.Value.GetInt32(); - continue; - } - - if(key=="interpolation"){ - value.interpolation = kv.Value.GetString(); - continue; - } - - if(key=="output"){ - value.output = kv.Value.GetInt32(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_cameras(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_cameras_LIST(x)); - } - return value; -} -public static glTFCamera Deserialize_gltf_cameras_LIST(ListTreeNode parsed) -{ - var value = new glTFCamera(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="orthographic"){ - value.orthographic = Deserialize_gltf_cameras__orthographic(kv.Value); - continue; - } - - if(key=="perspective"){ - value.perspective = Deserialize_gltf_cameras__perspective(kv.Value); - continue; - } - - if(key=="type"){ - value.type = (ProjectionType)Enum.Parse(typeof(ProjectionType), kv.Value.GetString(), true); - continue; - } - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_cameras__extensions(kv.Value); - continue; - } - - if(key=="extras"){ - value.extras = Deserialize_gltf_cameras__extras(kv.Value); - continue; - } - - } - return value; -} - -public static glTFOrthographic Deserialize_gltf_cameras__orthographic(ListTreeNode parsed) -{ - var value = new glTFOrthographic(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="xmag"){ - value.xmag = kv.Value.GetSingle(); - continue; - } - - if(key=="ymag"){ - value.ymag = kv.Value.GetSingle(); - continue; - } - - if(key=="zfar"){ - value.zfar = kv.Value.GetSingle(); - continue; - } - - if(key=="znear"){ - value.znear = kv.Value.GetSingle(); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_cameras__orthographic_extensions(kv.Value); - continue; - } - - if(key=="extras"){ - value.extras = Deserialize_gltf_cameras__orthographic_extras(kv.Value); - continue; - } - - } - return value; -} - -public static glTFOrthographic_extensions Deserialize_gltf_cameras__orthographic_extensions(ListTreeNode parsed) -{ - var value = new glTFOrthographic_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - } - return value; -} - -public static glTFOrthographic_extras Deserialize_gltf_cameras__orthographic_extras(ListTreeNode parsed) -{ - var value = new glTFOrthographic_extras(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - } - return value; -} - -public static glTFPerspective Deserialize_gltf_cameras__perspective(ListTreeNode parsed) -{ - var value = new glTFPerspective(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="aspectRatio"){ - value.aspectRatio = kv.Value.GetSingle(); - continue; - } - - if(key=="yfov"){ - value.yfov = kv.Value.GetSingle(); - continue; - } - - if(key=="zfar"){ - value.zfar = kv.Value.GetSingle(); - continue; - } - - if(key=="znear"){ - value.znear = kv.Value.GetSingle(); - continue; - } - - if(key=="extensions"){ - value.extensions = Deserialize_gltf_cameras__perspective_extensions(kv.Value); - continue; - } - - if(key=="extras"){ - value.extras = Deserialize_gltf_cameras__perspective_extras(kv.Value); - continue; - } - - } - return value; -} - -public static glTFPerspective_extensions Deserialize_gltf_cameras__perspective_extensions(ListTreeNode parsed) -{ - var value = new glTFPerspective_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - } - return value; -} - -public static glTFPerspective_extras Deserialize_gltf_cameras__perspective_extras(ListTreeNode parsed) -{ - var value = new glTFPerspective_extras(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - } - return value; -} - -public static glTFCamera_extensions Deserialize_gltf_cameras__extensions(ListTreeNode parsed) -{ - var value = new glTFCamera_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - } - return value; -} - -public static glTFCamera_extras Deserialize_gltf_cameras__extras(ListTreeNode parsed) -{ - var value = new glTFCamera_extras(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - } - return value; -} - -public static List Deserialize_gltf_extensionsUsed(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(x.GetString()); - } - return value; -} -public static List Deserialize_gltf_extensionsRequired(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(x.GetString()); - } - return value; -} -public static glTF_extensions Deserialize_gltf_extensions(ListTreeNode parsed) -{ - var value = new glTF_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="VRM"){ - value.VRM = Deserialize_gltf_extensions_VRM(kv.Value); - continue; - } - - } - return value; -} - -public static glTF_VRM_extensions Deserialize_gltf_extensions_VRM(ListTreeNode parsed) -{ - var value = new glTF_VRM_extensions(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="exporterVersion"){ - value.exporterVersion = kv.Value.GetString(); - continue; - } - - if(key=="specVersion"){ - value.specVersion = kv.Value.GetString(); - continue; - } - - if(key=="meta"){ - value.meta = Deserialize_gltf_extensions_VRM_meta(kv.Value); - continue; - } - - if(key=="humanoid"){ - value.humanoid = Deserialize_gltf_extensions_VRM_humanoid(kv.Value); - continue; - } - - if(key=="firstPerson"){ - value.firstPerson = Deserialize_gltf_extensions_VRM_firstPerson(kv.Value); - continue; - } - - if(key=="blendShapeMaster"){ - value.blendShapeMaster = Deserialize_gltf_extensions_VRM_blendShapeMaster(kv.Value); - continue; - } - - if(key=="secondaryAnimation"){ - value.secondaryAnimation = Deserialize_gltf_extensions_VRM_secondaryAnimation(kv.Value); - continue; - } - - if(key=="materialProperties"){ - value.materialProperties = Deserialize_gltf_extensions_VRM_materialProperties(kv.Value); - continue; - } - - } - return value; -} - -public static glTF_VRM_Meta Deserialize_gltf_extensions_VRM_meta(ListTreeNode parsed) -{ - var value = new glTF_VRM_Meta(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="title"){ - value.title = kv.Value.GetString(); - continue; - } - - if(key=="version"){ - value.version = kv.Value.GetString(); - continue; - } - - if(key=="author"){ - value.author = kv.Value.GetString(); - continue; - } - - if(key=="contactInformation"){ - value.contactInformation = kv.Value.GetString(); - continue; - } - - if(key=="reference"){ - value.reference = kv.Value.GetString(); - continue; - } - - if(key=="texture"){ - value.texture = kv.Value.GetInt32(); - continue; - } - - if(key=="allowedUserName"){ - value.allowedUserName = kv.Value.GetString(); - continue; - } - - if(key=="violentUssageName"){ - value.violentUssageName = kv.Value.GetString(); - continue; - } - - if(key=="sexualUssageName"){ - value.sexualUssageName = kv.Value.GetString(); - continue; - } - - if(key=="commercialUssageName"){ - value.commercialUssageName = kv.Value.GetString(); - continue; - } - - if(key=="otherPermissionUrl"){ - value.otherPermissionUrl = kv.Value.GetString(); - continue; - } - - if(key=="licenseName"){ - value.licenseName = kv.Value.GetString(); - continue; - } - - if(key=="otherLicenseUrl"){ - value.otherLicenseUrl = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static glTF_VRM_Humanoid Deserialize_gltf_extensions_VRM_humanoid(ListTreeNode parsed) -{ - var value = new glTF_VRM_Humanoid(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="humanBones"){ - value.humanBones = Deserialize_gltf_extensions_VRM_humanoid_humanBones(kv.Value); - continue; - } - - if(key=="armStretch"){ - value.armStretch = kv.Value.GetSingle(); - continue; - } - - if(key=="legStretch"){ - value.legStretch = kv.Value.GetSingle(); - continue; - } - - if(key=="upperArmTwist"){ - value.upperArmTwist = kv.Value.GetSingle(); - continue; - } - - if(key=="lowerArmTwist"){ - value.lowerArmTwist = kv.Value.GetSingle(); - continue; - } - - if(key=="upperLegTwist"){ - value.upperLegTwist = kv.Value.GetSingle(); - continue; - } - - if(key=="lowerLegTwist"){ - value.lowerLegTwist = kv.Value.GetSingle(); - continue; - } - - if(key=="feetSpacing"){ - value.feetSpacing = kv.Value.GetSingle(); - continue; - } - - if(key=="hasTranslationDoF"){ - value.hasTranslationDoF = kv.Value.GetBoolean(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_extensions_VRM_humanoid_humanBones(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_extensions_VRM_humanoid_humanBones_LIST(x)); - } - return value; -} -public static glTF_VRM_HumanoidBone Deserialize_gltf_extensions_VRM_humanoid_humanBones_LIST(ListTreeNode parsed) -{ - var value = new glTF_VRM_HumanoidBone(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="bone"){ - value.bone = kv.Value.GetString(); - continue; - } - - if(key=="node"){ - value.node = kv.Value.GetInt32(); - continue; - } - - if(key=="useDefaultValues"){ - value.useDefaultValues = kv.Value.GetBoolean(); - continue; - } - - if(key=="min"){ - value.min = Deserialize_gltf_extensions_VRM_humanoid_humanBones__min(kv.Value); - continue; - } - - if(key=="max"){ - value.max = Deserialize_gltf_extensions_VRM_humanoid_humanBones__max(kv.Value); - continue; - } - - if(key=="center"){ - value.center = Deserialize_gltf_extensions_VRM_humanoid_humanBones__center(kv.Value); - continue; - } - - if(key=="axisLength"){ - value.axisLength = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static Vector3 Deserialize_gltf_extensions_VRM_humanoid_humanBones__min(ListTreeNode parsed) -{ - var value = new Vector3(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="x"){ - value.x = kv.Value.GetSingle(); - continue; - } - - if(key=="y"){ - value.y = kv.Value.GetSingle(); - continue; - } - - if(key=="z"){ - value.z = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static Vector3 Deserialize_gltf_extensions_VRM_humanoid_humanBones__max(ListTreeNode parsed) -{ - var value = new Vector3(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="x"){ - value.x = kv.Value.GetSingle(); - continue; - } - - if(key=="y"){ - value.y = kv.Value.GetSingle(); - continue; - } - - if(key=="z"){ - value.z = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static Vector3 Deserialize_gltf_extensions_VRM_humanoid_humanBones__center(ListTreeNode parsed) -{ - var value = new Vector3(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="x"){ - value.x = kv.Value.GetSingle(); - continue; - } - - if(key=="y"){ - value.y = kv.Value.GetSingle(); - continue; - } - - if(key=="z"){ - value.z = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static glTF_VRM_Firstperson Deserialize_gltf_extensions_VRM_firstPerson(ListTreeNode parsed) -{ - var value = new glTF_VRM_Firstperson(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="firstPersonBone"){ - value.firstPersonBone = kv.Value.GetInt32(); - continue; - } - - if(key=="firstPersonBoneOffset"){ - value.firstPersonBoneOffset = Deserialize_gltf_extensions_VRM_firstPerson_firstPersonBoneOffset(kv.Value); - continue; - } - - if(key=="meshAnnotations"){ - value.meshAnnotations = Deserialize_gltf_extensions_VRM_firstPerson_meshAnnotations(kv.Value); - continue; - } - - if(key=="lookAtTypeName"){ - value.lookAtTypeName = kv.Value.GetString(); - continue; - } - - if(key=="lookAtHorizontalInner"){ - value.lookAtHorizontalInner = Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalInner(kv.Value); - continue; - } - - if(key=="lookAtHorizontalOuter"){ - value.lookAtHorizontalOuter = Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalOuter(kv.Value); - continue; - } - - if(key=="lookAtVerticalDown"){ - value.lookAtVerticalDown = Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalDown(kv.Value); - continue; - } - - if(key=="lookAtVerticalUp"){ - value.lookAtVerticalUp = Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalUp(kv.Value); - continue; - } - - } - return value; -} - -public static Vector3 Deserialize_gltf_extensions_VRM_firstPerson_firstPersonBoneOffset(ListTreeNode parsed) -{ - var value = new Vector3(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="x"){ - value.x = kv.Value.GetSingle(); - continue; - } - - if(key=="y"){ - value.y = kv.Value.GetSingle(); - continue; - } - - if(key=="z"){ - value.z = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_extensions_VRM_firstPerson_meshAnnotations(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_extensions_VRM_firstPerson_meshAnnotations_LIST(x)); - } - return value; -} -public static glTF_VRM_MeshAnnotation Deserialize_gltf_extensions_VRM_firstPerson_meshAnnotations_LIST(ListTreeNode parsed) -{ - var value = new glTF_VRM_MeshAnnotation(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="mesh"){ - value.mesh = kv.Value.GetInt32(); - continue; - } - - if(key=="firstPersonFlag"){ - value.firstPersonFlag = kv.Value.GetString(); - continue; - } - - } - return value; -} - -public static glTF_VRM_DegreeMap Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalInner(ListTreeNode parsed) -{ - var value = new glTF_VRM_DegreeMap(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="curve"){ - value.curve = Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalInner_curve(kv.Value); - continue; - } - - if(key=="xRange"){ - value.xRange = kv.Value.GetSingle(); - continue; - } - - if(key=="yRange"){ - value.yRange = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static Single[] Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalInner_curve(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTF_VRM_DegreeMap Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalOuter(ListTreeNode parsed) -{ - var value = new glTF_VRM_DegreeMap(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="curve"){ - value.curve = Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalOuter_curve(kv.Value); - continue; - } - - if(key=="xRange"){ - value.xRange = kv.Value.GetSingle(); - continue; - } - - if(key=="yRange"){ - value.yRange = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static Single[] Deserialize_gltf_extensions_VRM_firstPerson_lookAtHorizontalOuter_curve(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTF_VRM_DegreeMap Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalDown(ListTreeNode parsed) -{ - var value = new glTF_VRM_DegreeMap(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="curve"){ - value.curve = Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalDown_curve(kv.Value); - continue; - } - - if(key=="xRange"){ - value.xRange = kv.Value.GetSingle(); - continue; - } - - if(key=="yRange"){ - value.yRange = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static Single[] Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalDown_curve(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTF_VRM_DegreeMap Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalUp(ListTreeNode parsed) -{ - var value = new glTF_VRM_DegreeMap(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="curve"){ - value.curve = Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalUp_curve(kv.Value); - continue; - } - - if(key=="xRange"){ - value.xRange = kv.Value.GetSingle(); - continue; - } - - if(key=="yRange"){ - value.yRange = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static Single[] Deserialize_gltf_extensions_VRM_firstPerson_lookAtVerticalUp_curve(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTF_VRM_BlendShapeMaster Deserialize_gltf_extensions_VRM_blendShapeMaster(ListTreeNode parsed) -{ - var value = new glTF_VRM_BlendShapeMaster(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="blendShapeGroups"){ - value.blendShapeGroups = Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups(kv.Value); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups_LIST(x)); - } - return value; -} -public static glTF_VRM_BlendShapeGroup Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups_LIST(ListTreeNode parsed) -{ - var value = new glTF_VRM_BlendShapeGroup(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - if(key=="presetName"){ - value.presetName = kv.Value.GetString(); - continue; - } - - if(key=="binds"){ - value.binds = Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__binds(kv.Value); - continue; - } - - if(key=="materialValues"){ - value.materialValues = Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues(kv.Value); - continue; - } - - if(key=="isBinary"){ - value.isBinary = kv.Value.GetBoolean(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__binds(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__binds_LIST(x)); - } - return value; -} -public static glTF_VRM_BlendShapeBind Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__binds_LIST(ListTreeNode parsed) -{ - var value = new glTF_VRM_BlendShapeBind(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="mesh"){ - value.mesh = kv.Value.GetInt32(); - continue; - } - - if(key=="index"){ - value.index = kv.Value.GetInt32(); - continue; - } - - if(key=="weight"){ - value.weight = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues_LIST(x)); - } - return value; -} -public static glTF_VRM_MaterialValueBind Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues_LIST(ListTreeNode parsed) -{ - var value = new glTF_VRM_MaterialValueBind(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="materialName"){ - value.materialName = kv.Value.GetString(); - continue; - } - - if(key=="propertyName"){ - value.propertyName = kv.Value.GetString(); - continue; - } - - if(key=="targetValue"){ - value.targetValue = Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues__targetValue(kv.Value); - continue; - } - - } - return value; -} - -public static Single[] Deserialize_gltf_extensions_VRM_blendShapeMaster_blendShapeGroups__materialValues__targetValue(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - -public static glTF_VRM_SecondaryAnimation Deserialize_gltf_extensions_VRM_secondaryAnimation(ListTreeNode parsed) -{ - var value = new glTF_VRM_SecondaryAnimation(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="boneGroups"){ - value.boneGroups = Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups(kv.Value); - continue; - } - - if(key=="colliderGroups"){ - value.colliderGroups = Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups(kv.Value); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups_LIST(x)); - } - return value; -} -public static glTF_VRM_SecondaryAnimationGroup Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups_LIST(ListTreeNode parsed) -{ - var value = new glTF_VRM_SecondaryAnimationGroup(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="comment"){ - value.comment = kv.Value.GetString(); - continue; - } - - if(key=="stiffiness"){ - value.stiffiness = kv.Value.GetSingle(); - continue; - } - - if(key=="gravityPower"){ - value.gravityPower = kv.Value.GetSingle(); - continue; - } - - if(key=="gravityDir"){ - value.gravityDir = Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__gravityDir(kv.Value); - continue; - } - - if(key=="dragForce"){ - value.dragForce = kv.Value.GetSingle(); - continue; - } - - if(key=="center"){ - value.center = kv.Value.GetInt32(); - continue; - } - - if(key=="hitRadius"){ - value.hitRadius = kv.Value.GetSingle(); - continue; - } - - if(key=="bones"){ - value.bones = Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__bones(kv.Value); - continue; - } - - if(key=="colliderGroups"){ - value.colliderGroups = Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__colliderGroups(kv.Value); - continue; - } - - } - return value; -} - -public static Vector3 Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__gravityDir(ListTreeNode parsed) -{ - var value = new Vector3(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="x"){ - value.x = kv.Value.GetSingle(); - continue; - } - - if(key=="y"){ - value.y = kv.Value.GetSingle(); - continue; - } - - if(key=="z"){ - value.z = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static Int32[] Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__bones(ListTreeNode parsed) -{ - var value = new Int32[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetInt32(); - } - return value; -} - -public static Int32[] Deserialize_gltf_extensions_VRM_secondaryAnimation_boneGroups__colliderGroups(ListTreeNode parsed) -{ - var value = new Int32[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetInt32(); - } - return value; -} - -public static List Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups_LIST(x)); - } - return value; -} -public static glTF_VRM_SecondaryAnimationColliderGroup Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups_LIST(ListTreeNode parsed) -{ - var value = new glTF_VRM_SecondaryAnimationColliderGroup(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="node"){ - value.node = kv.Value.GetInt32(); - continue; - } - - if(key=="colliders"){ - value.colliders = Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders(kv.Value); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders_LIST(x)); - } - return value; -} -public static glTF_VRM_SecondaryAnimationCollider Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders_LIST(ListTreeNode parsed) -{ - var value = new glTF_VRM_SecondaryAnimationCollider(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="offset"){ - value.offset = Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders__offset(kv.Value); - continue; - } - - if(key=="radius"){ - value.radius = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static Vector3 Deserialize_gltf_extensions_VRM_secondaryAnimation_colliderGroups__colliders__offset(ListTreeNode parsed) -{ - var value = new Vector3(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="x"){ - value.x = kv.Value.GetSingle(); - continue; - } - - if(key=="y"){ - value.y = kv.Value.GetSingle(); - continue; - } - - if(key=="z"){ - value.z = kv.Value.GetSingle(); - continue; - } - - } - return value; -} - -public static List Deserialize_gltf_extensions_VRM_materialProperties(ListTreeNode parsed) -{ - var value = new List(); - foreach(var x in parsed.ArrayItems()) - { - value.Add(Deserialize_gltf_extensions_VRM_materialProperties_LIST(x)); - } - return value; -} -public static glTF_VRM_Material Deserialize_gltf_extensions_VRM_materialProperties_LIST(ListTreeNode parsed) -{ - var value = new glTF_VRM_Material(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - if(key=="name"){ - value.name = kv.Value.GetString(); - continue; - } - - if(key=="shader"){ - value.shader = kv.Value.GetString(); - continue; - } - - if(key=="renderQueue"){ - value.renderQueue = kv.Value.GetInt32(); - continue; - } - - if(key=="floatProperties"){ - value.floatProperties = Deserialize_gltf_extensions_VRM_materialProperties__floatProperties(kv.Value); - continue; - } - - if(key=="vectorProperties"){ - value.vectorProperties = Deserialize_gltf_extensions_VRM_materialProperties__vectorProperties(kv.Value); - continue; - } - - if(key=="textureProperties"){ - value.textureProperties = Deserialize_gltf_extensions_VRM_materialProperties__textureProperties(kv.Value); - continue; - } - - if(key=="keywordMap"){ - value.keywordMap = Deserialize_gltf_extensions_VRM_materialProperties__keywordMap(kv.Value); - continue; - } - - if(key=="tagMap"){ - value.tagMap = Deserialize_gltf_extensions_VRM_materialProperties__tagMap(kv.Value); - continue; - } - - } - return value; -} - - -public static Dictionary Deserialize_gltf_extensions_VRM_materialProperties__floatProperties(ListTreeNode parsed) -{ - var value = new Dictionary(); - foreach(var kv in parsed.ObjectItems()) - { - value.Add(kv.Key.GetString(), kv.Value.GetSingle()); - } - return value; -} - - -public static Dictionary Deserialize_gltf_extensions_VRM_materialProperties__vectorProperties(ListTreeNode parsed) -{ - var value = new Dictionary(); - foreach(var kv in parsed.ObjectItems()) - { - value.Add(kv.Key.GetString(), Deserialize_gltf_extensions_VRM_materialProperties__vectorProperties_DICT(kv.Value)); - } - return value; -} - -public static Single[] Deserialize_gltf_extensions_VRM_materialProperties__vectorProperties_DICT(ListTreeNode parsed) -{ - var value = new Single[parsed.GetArrayCount()]; - int i=0; - foreach(var x in parsed.ArrayItems()) - { - value[i++] = x.GetSingle(); - } - return value; -} - - -public static Dictionary Deserialize_gltf_extensions_VRM_materialProperties__textureProperties(ListTreeNode parsed) -{ - var value = new Dictionary(); - foreach(var kv in parsed.ObjectItems()) - { - value.Add(kv.Key.GetString(), kv.Value.GetInt32()); - } - return value; -} - - -public static Dictionary Deserialize_gltf_extensions_VRM_materialProperties__keywordMap(ListTreeNode parsed) -{ - var value = new Dictionary(); - foreach(var kv in parsed.ObjectItems()) - { - value.Add(kv.Key.GetString(), kv.Value.GetBoolean()); - } - return value; -} - - -public static Dictionary Deserialize_gltf_extensions_VRM_materialProperties__tagMap(ListTreeNode parsed) -{ - var value = new Dictionary(); - foreach(var kv in parsed.ObjectItems()) - { - value.Add(kv.Key.GetString(), kv.Value.GetString()); - } - return value; -} - -public static gltf_extras Deserialize_gltf_extras(ListTreeNode parsed) -{ - var value = new gltf_extras(); - - foreach(var kv in parsed.ObjectItems()) - { - var key = kv.Key.GetString(); - - } - return value; -} - -} // GltfDeserializer -} // UniGLTF diff --git a/Assets/VRM/UniGLTF/Scripts/IO/IStorage.cs.meta b/Assets/VRM/UniGLTF/Scripts/IO/IStorage.cs.meta deleted file mode 100644 index 0eb53f3c4..000000000 --- a/Assets/VRM/UniGLTF/Scripts/IO/IStorage.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9cb8b6f878e36a74f90d172daee60bed -timeCreated: 1529327531 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniGLTF/Scripts/UniGLTFVersion.cs b/Assets/VRM/UniGLTF/Scripts/UniGLTFVersion.cs deleted file mode 100644 index 6cc577069..000000000 --- a/Assets/VRM/UniGLTF/Scripts/UniGLTFVersion.cs +++ /dev/null @@ -1,11 +0,0 @@ - -namespace UniGLTF -{ - public static partial class UniGLTFVersion - { - public const int MAJOR = 1; - public const int MINOR = 28; - - public const string VERSION = "1.28"; - } -} diff --git a/Assets/VRM/UniJSON.meta b/Assets/VRM/UniJSON.meta deleted file mode 100644 index d922262f2..000000000 --- a/Assets/VRM/UniJSON.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 47d19c13efe508f4aa9da50723805710 -folderAsset: yes -timeCreated: 1545997158 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor.meta b/Assets/VRM/UniJSON/Editor.meta deleted file mode 100644 index 32892f94e..000000000 --- a/Assets/VRM/UniJSON/Editor.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 8feecbeea973dde4f944d365dc93e92c -folderAsset: yes -timeCreated: 1540820131 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests.meta b/Assets/VRM/UniJSON/Editor/Tests.meta deleted file mode 100644 index 64bd65103..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: d7288f19b28ff044ba00cefdb6458340 -folderAsset: yes -timeCreated: 1526055787 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json.meta b/Assets/VRM/UniJSON/Editor/Tests/Json.meta deleted file mode 100644 index b1d1c9c5b..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/Json.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 7467ac74a97f50646b5e954a34682bae -folderAsset: yes -timeCreated: 1543250519 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/SchemaTests.cs b/Assets/VRM/UniJSON/Editor/Tests/Json/SchemaTests.cs deleted file mode 100644 index 1f51b07a0..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/Json/SchemaTests.cs +++ /dev/null @@ -1,150 +0,0 @@ -#pragma warning disable 0649 -using NUnit.Framework; - -namespace UniJSON -{ - public class SchemaTests - { - /// - /// http://json-schema.org/examples.html - /// - [JsonSchema(Title="Person")] - public class Person - { - [JsonSchema(Required = true)] - public string firstName; - - [JsonSchema(Required = true)] - public string lastName; - - [JsonSchema(Description = "Age in years", Minimum = 0)] - public int age; - } - - [Test] - public void CreateFromClass() - { - var s = JsonSchema.FromType(); - Assert.AreEqual("Person", s.Title); - - var v = s.Validator as JsonObjectValidator; - Assert.AreEqual("Age in years", v.Properties["age"].Description); - Assert.AreEqual(new[] { "firstName", "lastName" }, v.Required); - - var f = new JsonFormatter(2); - s.ToJson(f); - var json = f.ToString(); - - var parsed = JsonParser.Parse(json); - Assert.AreEqual(0, parsed["properties"]["age"]["minimum"].GetInt32()); - } - - [JsonSchema(Title="MultipleConstraints")] - public class MultipleConstraints - { - [JsonSchema(Required = true, Minimum = 0, Maximum = 100)] - public int ranged; - } - - [Test] - public void CreateFromClassWithMultipleConstraints() - { - var s = JsonSchema.FromType(); - - var v = s.Validator as JsonObjectValidator; - var rangedV = v.Properties["ranged"].Validator as JsonIntValidator; - Assert.AreEqual(0, rangedV.Minimum); - Assert.AreEqual(100, rangedV.Maximum); - } - - public enum ProjectionType - { - Perspective, - Orthographic - } - - class EnumStringTest - { - [JsonSchema(EnumSerializationType = EnumSerializationType.AsLowerString)] - public ProjectionType type; - } - - class EnumIntTest - { - [JsonSchema(EnumSerializationType = EnumSerializationType.AsInt)] - public ProjectionType type; - } - - [Test] - public void TestEnumAsString() - { - var json = @" -{ - ""type"": ""object"", - ""properties"": { - - ""type"": { - - ""anyOf"": [ - { - ""enum"": [ ""perspective"" ] - }, - { - ""enum"": [ ""orthographic"" ] - }, - { - ""type"": ""string"" - } - ] - - } - - } -} -"; - - var fromJson = new JsonSchema(); - fromJson.Parse(null, JsonParser.Parse(json), "enum test"); - - var fromType = JsonSchema.FromType(); - - Assert.AreEqual(fromJson, fromType); - } - - [Test] - public void TestEnumAsInt() - { - var json = @" -{ - ""type"": ""object"", - ""properties"": { - - ""type"": { - - ""anyOf"": [ - { - ""enum"": [ 0 ] - }, - { - ""enum"": [ 1 ] - }, - { - ""type"": ""integer"" - } - ] - - } - - } -} -"; - - var fromJson = new JsonSchema(); - fromJson.Parse(null, JsonParser.Parse(json), "enum test"); - - var fromType = JsonSchema.FromType(); - - Assert.AreEqual(fromJson, fromType); - } - } -} diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/SchemaTests.cs.meta b/Assets/VRM/UniJSON/Editor/Tests/Json/SchemaTests.cs.meta deleted file mode 100644 index c11d56f02..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/Json/SchemaTests.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: d4dfd16b1b05c8640898b955df61c51b -timeCreated: 1526055801 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/SerializeWithSchemaTests.cs b/Assets/VRM/UniJSON/Editor/Tests/Json/SerializeWithSchemaTests.cs deleted file mode 100644 index 1d022739e..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/Json/SerializeWithSchemaTests.cs +++ /dev/null @@ -1,200 +0,0 @@ -using NUnit.Framework; - -namespace UniJSON -{ - public class SerializeWithSchemaTests - { - [JsonSchema(Title="CheckConstraintsTest")] - public class CheckConstraintsTest - { - [JsonSchema(Minimum = 0)] - public int X; - - [JsonSchema(Minimum = 10, ExplicitIgnorableValue = 0)] // Not required, thus ignored when the value violates the constraints - public int Y; - } - - [Test] - public void TestCheckConstraints() - { - var obj = new CheckConstraintsTest() - { - X = 0, - Y = 0, // Will be excluded because 0 doesn't satisfy a requirement of "Minimum = 10" - }; - - var s = JsonSchema.FromType(); - { - var c = new JsonSchemaValidationContext(obj); - Assert.Null(s.Validator.Validate(c, s)); - } - var actual = s.Serialize(obj); - - var expected = @"{""X"":0}"; - - Assert.AreEqual(expected, actual); - } - - [JsonSchema(Title="ObjectNestedTest")] - public class ObjectNestedTest - { - public CheckConstraintsTest C; - } - - [Test] - public void TestObjectNested() - { - var obj = new ObjectNestedTest() - { - C = new CheckConstraintsTest(), - }; - - var s = JsonSchema.FromType(); - { - var c = new JsonSchemaValidationContext(obj); - Assert.Null(s.Validator.Validate(c, s)); - } - var actual = s.Serialize(obj); - - var expected = @"{""C"":{""X"":0}}"; - - Assert.AreEqual(expected, actual); - } - - [Test] - public void TestObjectNestedWithNull() - { - var obj = new ObjectNestedTest(); - - var s = JsonSchema.FromType(); - { - var c = new JsonSchemaValidationContext(obj); - Assert.Null(s.Validator.Validate(c, s)); - } - var actual = s.Serialize(obj); - - var expected = @"{}"; - - Assert.AreEqual(expected, actual); - } - - public class HasDepsTest - { - [JsonSchema(Minimum = 0, ExplicitIgnorableValue = -1)] - public int X; - - [JsonSchema(Dependencies = new string[] {"X"})] - public int Y; - } - - [Test] - public void TestHasDeps() - { - var obj = new HasDepsTest(); - - var s = JsonSchema.FromType(); - { - var c = new JsonSchemaValidationContext(obj); - Assert.Null(s.Validator.Validate(c, s)); - } - var actual = s.Serialize(obj); - - var expected = @"{""X"":0,""Y"":0}"; - - Assert.AreEqual(expected, actual); - } - - [Test] - public void TestHasDepsHasViolation() - { - var obj = new HasDepsTest() - { - X = -1, - }; - - var s = JsonSchema.FromType(); - { - var c = new JsonSchemaValidationContext(obj); - Assert.Null(s.Validator.Validate(c, s)); - } - var actual = s.Serialize(obj); - - var expected = @"{}"; - - Assert.AreEqual(expected, actual); - } - - public class HasStringTest - { - public string X; - } - - [Test] - public void TestHasString() - { - var obj = new HasStringTest() - { - X = "a", - }; - - var s = JsonSchema.FromType(); - { - var c = new JsonSchemaValidationContext(obj); - Assert.Null(s.Validator.Validate(c, s)); - } - var actual = s.Serialize(obj); - - var expected = @"{""X"":""a""}"; - - Assert.AreEqual(expected, actual); - } - - [Test] - public void TestHasStringWithNull() - { - var obj = new HasStringTest(); - - var s = JsonSchema.FromType(); - { - var c = new JsonSchemaValidationContext(obj); - Assert.Null(s.Validator.Validate(c, s)); - } - var actual = s.Serialize(obj); - - var expected = @"{}"; - - Assert.AreEqual(expected, actual); - } - - public class NestedRequiredTestParent - { - [JsonSchema(Required = true)] - public NestedRequiredTestChild C; - } - - public class NestedRequiredTestChild - { - public string X; - } - - [Test] - public void TestNestedRequired() - { - var obj = new NestedRequiredTestParent() - { - C = new NestedRequiredTestChild(), - }; - - var s = JsonSchema.FromType(); - { - var c = new JsonSchemaValidationContext(obj); - Assert.Null(s.Validator.Validate(c, s)); - } - var actual = s.Serialize(obj); - - var expected = @"{""C"":{}}"; - - Assert.AreEqual(expected, actual); - } - } -} diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/SerializeWithSchemaTests.cs.meta b/Assets/VRM/UniJSON/Editor/Tests/Json/SerializeWithSchemaTests.cs.meta deleted file mode 100644 index b0c9e7173..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/Json/SerializeWithSchemaTests.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f1d1c3d9d4d20db409e9d5d9d671abbe -timeCreated: 1546930461 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/ValidatorTests.cs b/Assets/VRM/UniJSON/Editor/Tests/Json/ValidatorTests.cs deleted file mode 100644 index 3a02610fe..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/Json/ValidatorTests.cs +++ /dev/null @@ -1,441 +0,0 @@ -using NUnit.Framework; -using System.Collections.Generic; - -namespace UniJSON -{ - public class ValidatorTests - { - [Test] - public void IntValidator() - { - var c = new JsonSchemaValidationContext("test"); - - { - var v = new JsonIntValidator(); - v.Maximum = 0; - Assert.NotNull(v.Validate(c, 1)); - Assert.Null(v.Validate(c, 0)); - Assert.Null(v.Validate(c, -1)); - } - { - var v = new JsonIntValidator(); - v.Maximum = 0; - v.ExclusiveMaximum = true; - Assert.NotNull(v.Validate(c, 1)); - Assert.NotNull(v.Validate(c, 0)); - Assert.Null(v.Validate(c, -1)); - } - { - var v = new JsonIntValidator(); - v.Minimum = 0; - Assert.Null(v.Validate(c, 1)); - Assert.Null(v.Validate(c, 0)); - Assert.NotNull(v.Validate(c, -1)); - } - { - var v = new JsonIntValidator(); - v.Minimum = 0; - v.ExclusiveMinimum = true; - Assert.Null(v.Validate(c, 1)); - Assert.NotNull(v.Validate(c, 0)); - Assert.NotNull(v.Validate(c, -1)); - } - { - var v = new JsonIntValidator(); - v.MultipleOf = 4; - Assert.Null(v.Validate(c, 4)); - Assert.NotNull(v.Validate(c, 5)); - } - - Assert.True(c.IsEmpty()); - } - - [Test] - public void NumberValidator() - { - var c = new JsonSchemaValidationContext("test"); - - { - var v = new JsonNumberValidator(); - v.Maximum = 0.1; - Assert.NotNull(v.Validate(c, 1)); - Assert.Null(v.Validate(c, 0.1)); - Assert.Null(v.Validate(c, -1)); - } - { - var v = new JsonNumberValidator(); - v.Maximum = 0.1; - v.ExclusiveMaximum = true; - Assert.NotNull(v.Validate(c, 1)); - Assert.NotNull(v.Validate(c, 0.1)); - Assert.Null(v.Validate(c, -1)); - } - { - var v = new JsonNumberValidator(); - v.Minimum = 0.1; - Assert.Null(v.Validate(c, 1)); - Assert.Null(v.Validate(c, 0.1)); - Assert.NotNull(v.Validate(c, -1)); - } - { - var v = new JsonNumberValidator(); - v.Minimum = 0.1; - v.ExclusiveMinimum = true; - Assert.Null(v.Validate(c, 1)); - Assert.NotNull(v.Validate(c, 0.1)); - Assert.NotNull(v.Validate(c, -1)); - } - - Assert.True(c.IsEmpty()); - } - - [Test] - public void BoolValidator() - { - // ??? - } - - [Test] - public void StringValidator() - { - var c = new JsonSchemaValidationContext("test"); - - { - var v = new JsonStringValidator(); - Assert.Null(v.Validate(c, "")); - Assert.Null(v.Validate(c, "a")); - } - - { - var v = new JsonStringValidator(); - v.MinLength = 1; - Assert.Null(v.Validate(c, "a")); - Assert.NotNull(v.Validate(c, "")); - } - { - var v = new JsonStringValidator(); - v.MaxLength = 1; - Assert.Null(v.Validate(c, "a")); - Assert.NotNull(v.Validate(c, "ab")); - } - { - var v = new JsonStringValidator(); - v.Pattern = new System.Text.RegularExpressions.Regex("abc"); - Assert.Null(v.Validate(c, "abc")); - Assert.NotNull(v.Validate(c, "ab")); - } - { - var v = new JsonStringValidator(); - v.Pattern = new System.Text.RegularExpressions.Regex("ab+"); - Assert.Null(v.Validate(c, "abb")); - Assert.Null(v.Validate(c, "ab")); - Assert.NotNull(v.Validate(c, "a")); - } - - Assert.True(c.IsEmpty()); - } - - [Test] - public void StringEnumValidator() - { - var c = new JsonSchemaValidationContext("test"); - - { - var v = JsonStringEnumValidator.Create(new string[] { "a", "b" }, EnumSerializationType.AsString); - Assert.Null(v.Validate(c, "a")); - Assert.NotNull(v.Validate(c, "c")); - } - - Assert.True(c.IsEmpty()); - } - - [Test] - public void IntEnumValidator() - { - var c = new JsonSchemaValidationContext("test"); - - { - var v = new JsonIntEnumValidator(); - v.Values = new int[] { 1, 2 }; - Assert.Null(v.Validate(c, 1)); - Assert.NotNull(v.Validate(c, 3)); - } - - Assert.True(c.IsEmpty()); - } - - [Test] - public void ArrayValidator() - { - var c = new JsonSchemaValidationContext("test"); - - { - var v = new JsonArrayValidator(); - v.MaxItems = 1; - Assert.Null(v.Validate(c, new object[] { 0 })); - Assert.NotNull(v.Validate(c, new object[] { 0, 1 })); - } - - { - var v = new JsonArrayValidator(); - v.MinItems = 1; - Assert.Null(v.Validate(c, new object[] { 0 })); - Assert.NotNull(v.Validate(c, new object[] { })); - } - - Assert.True(c.IsEmpty()); - } - - class Hoge - { - [JsonSchema(Required = true, Minimum = 1)] - public int Value; - } - - [Test] - public void ObjectValidator() - { - var c = new JsonSchemaValidationContext("test"); - { - var s = JsonSchema.FromType(); - Assert.Null(s.Validator.Validate(c, new Hoge { Value = 1 })); - Assert.NotNull(s.Validator.Validate(c, new Hoge { Value = 0 })); - } - - Assert.True(c.IsEmpty()); - } - - class NotRequired - { - [JsonSchema(Minimum = 1)] - public int Value; - } - - [Test] - public void ObjectValidatorForNotRequired() - { - { - var c = new JsonSchemaValidationContext("test") - { - EnableDiagnosisForNotRequiredFields = false, // Default behaviour - }; - - var s = JsonSchema.FromType(); - // An error is not returned because Value is not 'Required' and the diagnosis is not enabled - Assert.Null(s.Validator.Validate(c, new NotRequired { Value = 0 })); - - Assert.True(c.IsEmpty()); - } - - { - var c = new JsonSchemaValidationContext("test") - { - EnableDiagnosisForNotRequiredFields = true, - }; - - var s = JsonSchema.FromType(); - Assert.NotNull(s.Validator.Validate(c, new NotRequired { Value = 0 })); - - Assert.True(c.IsEmpty()); - } - } - - class NotRequiredWithIgnorable - { - [JsonSchema(Minimum = 2, ExplicitIgnorableValue = -1)] - public int Value; - } - - [Test] - public void ObjectValidatorForNotRequiredWithIgnorable() - { - { - var c = new JsonSchemaValidationContext("test") - { - EnableDiagnosisForNotRequiredFields = false, // Default behaviour - }; - - var s = JsonSchema.FromType(); - // An error is not returned because Value is not 'Required' and the diagnosis is not enabled - Assert.Null(s.Validator.Validate(c, new NotRequiredWithIgnorable { Value = 0 })); - - Assert.True(c.IsEmpty()); - } - - { - var c = new JsonSchemaValidationContext("test") - { - EnableDiagnosisForNotRequiredFields = true, - }; - - var s = JsonSchema.FromType(); - Assert.NotNull(s.Validator.Validate(c, new NotRequiredWithIgnorable { Value = 0 })); - - Assert.True(c.IsEmpty()); - } - - { - var c = new JsonSchemaValidationContext("test") - { - EnableDiagnosisForNotRequiredFields = true, - }; - - var s = JsonSchema.FromType(); - // An error is NOT returned even though diagnosis is enabled because of an ignorable value is matched - Assert.Null(s.Validator.Validate(c, new NotRequiredWithIgnorable { Value = -1 })); - - Assert.True(c.IsEmpty()); - } - } - - [Test] - public void DictionaryValidator() - { - var c = new JsonSchemaValidationContext("test"); - - { - var s = JsonSchema.FromType>(); - Assert.True(s.Validator is JsonDictionaryValidator); - - var v = s.Validator as JsonDictionaryValidator; - v.MinProperties = 1; - v.AdditionalProperties = JsonSchema.FromType(); - (v.AdditionalProperties.Validator as JsonIntValidator).Minimum = 0; - - Assert.Null(s.Validator.Validate(c, new Dictionary - { - {"POSITION", 0} - })); - - var result = s.Validator.Validate(c, new Dictionary - { - {"POSITION", -1} - }); - Assert.NotNull(result); - } - - Assert.True(c.IsEmpty()); - } - - class HasDictionary - { - public Dictionary primitiveProperties = new Dictionary(); - // TODO: fix - // public Dictionary nestedProperties = new Dictionary(); - } - - [Test] - public void HasDictionaryObjectValidator() - { - var c = new JsonSchemaValidationContext("test"); - - { - var s = JsonSchema.FromType(); - Assert.Null(s.Validator.Validate(c, new HasDictionary())); - } - - Assert.True(c.IsEmpty()); - } - - class HasArrayObject - { - [ItemJsonSchema(Minimum = 0.0, Maximum = 1.0)] - public float[] xs; - } - - [Test] - public void HasArrayObjectValidator() - { - { - var c = new JsonSchemaValidationContext("test") - { - EnableDiagnosisForNotRequiredFields = true, - }; - - var s = JsonSchema.FromType(); - - Assert.Null(s.Validator.Validate(c, new HasArrayObject { xs = new float[] { } })); - Assert.Null(s.Validator.Validate(c, new HasArrayObject { xs = new float[] { 0.5f } })); - Assert.NotNull(s.Validator.Validate(c, new HasArrayObject { xs = new float[] { 1.5f } })); - - Assert.True(c.IsEmpty()); - } - } - - class HasListObject - { - [ItemJsonSchema(Minimum = 0.0, Maximum = 1.0)] - public List xs; - } - - [Test] - public void HasListObjectValidator() - { - { - var c = new JsonSchemaValidationContext("test") - { - EnableDiagnosisForNotRequiredFields = true, - }; - - var s = JsonSchema.FromType(); - - Assert.Null(s.Validator.Validate(c, new HasListObject { xs = new List { } })); - Assert.Null(s.Validator.Validate(c, new HasListObject { xs = new List { 0.5f } })); - Assert.NotNull(s.Validator.Validate(c, new HasListObject { xs = new List { 1.5f } })); - - Assert.True(c.IsEmpty()); - } - } - - class HasRequiredListObject - { - [JsonSchema(Required = true, MinItems = 1)] - [ItemJsonSchema(Minimum = 0)] - public int[] xs; - } - - [Test] - public void HasRequiredListObjectValidator() - { - { - var c = new JsonSchemaValidationContext("test") - { - EnableDiagnosisForNotRequiredFields = true, - }; - - var s = JsonSchema.FromType(); - - Assert.NotNull(s.Validator.Validate(c, new HasRequiredListObject())); - Assert.NotNull(s.Validator.Validate(c, new HasRequiredListObject { xs = new int[] {} })); - Assert.NotNull(s.Validator.Validate(c, new HasRequiredListObject { xs = new int[] { -1 } })); - Assert.Null(s.Validator.Validate(c, new HasRequiredListObject { xs = new int[] { 0 } })); - - Assert.True(c.IsEmpty()); - } - } - - class HasRequiredStringObject - { - [JsonSchema(Required = true)] - public string s; - } - - [Test] - public void HasRequiredStringObjectValidator() - { - { - var c = new JsonSchemaValidationContext("test") - { - EnableDiagnosisForNotRequiredFields = true, - }; - - var s = JsonSchema.FromType(); - - Assert.NotNull(s.Validator.Validate(c, new HasRequiredStringObject())); - Assert.Null(s.Validator.Validate(c, new HasRequiredStringObject { s = "" })); - - Assert.True(c.IsEmpty()); - } - } - } -} diff --git a/Assets/VRM/UniJSON/Editor/Tests/Json/ValidatorTests.cs.meta b/Assets/VRM/UniJSON/Editor/Tests/Json/ValidatorTests.cs.meta deleted file mode 100644 index 66ad4caea..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/Json/ValidatorTests.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 16d778a50d1c9374894ef42f892210dd -timeCreated: 1531900562 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/MsgPack.meta b/Assets/VRM/UniJSON/Editor/Tests/MsgPack.meta deleted file mode 100644 index 187193c44..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/MsgPack.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 0bcf0d9b7cba67c42ba04c530aa7cd38 -folderAsset: yes -timeCreated: 1540812199 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/RPCTests.cs b/Assets/VRM/UniJSON/Editor/Tests/RPCTests.cs deleted file mode 100644 index 69023e8b0..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/RPCTests.cs +++ /dev/null @@ -1,98 +0,0 @@ -using NUnit.Framework; -using UniJSON.MsgPack; - -namespace UniJSON -{ - public class RPCTests - { - [Test] - public void JsonRpcRequestTest() - { - var f = new JsonFormatter(); - - { - f.Clear(); - var l = JsonParser.Parse("{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"num1\",\"params\":[1]}"); - f.Request("num1", 1); - var u = new Utf8String(f.GetStoreBytes()); - var r = JsonParser.Parse(u); - Assert.AreEqual( - l, - r); - } - { - f.Clear(); - f.Request("num2", 2, true); - Assert.AreEqual( - JsonParser.Parse("{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"num2\",\"params\":[2,true]}"), - JsonParser.Parse(new Utf8String(f.GetStoreBytes()))); - } - { - f.Clear(); - f.Request("num3", - 3, true, "abc", false, (string)null, new[] { 1, 2 }); - Assert.AreEqual( - JsonParser.Parse("{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"num3\",\"params\":[3,true,\"abc\",false,null,[1,2]]}"), - JsonParser.Parse(new Utf8String(f.GetStoreBytes()))); - } - } - - [Test] - public void JsonRpcDispatcherTest() - { - var dispatcher = new RpcDispatcher(); - var f = new JsonFormatter(); - - { - f.Clear(); - dispatcher.Register("add", (int a, int b) => a + b); - f.Request("add", 1, 2); - - var parsed = JsonParser.Parse(new Utf8String(f.GetStoreBytes())); - - f.Clear(); - dispatcher.Call(f, parsed["id"].GetInt32(), parsed["method"].GetString(), parsed["params"]); - var response = JsonParser.Parse(new Utf8String(f.GetStoreBytes())); - Assert.AreEqual(3, response["result"].GetInt32()); - } - - { - string msg = null; - dispatcher.Register("print", (string _msg) => { msg = _msg; }); - f.Clear(); - f.Request("print", "hoge"); - - var parsed = JsonParser.Parse(new Utf8String(f.GetStoreBytes())); - f.Clear(); - dispatcher.Call(f, parsed["id"].GetInt32(), parsed["method"].GetString(), parsed["params"]); - - Assert.AreEqual("hoge", msg); - } - } - - [Test] - public void MsgPackRpcDispatcherTest() - { - var dispatcher = new RpcDispatcher(); - var f = new MsgPackFormatter(); - - { - f.GetStore().Clear(); - dispatcher.Register("add", (int a, int b) => a + b); - f.Request("add", 1, 2); - - var request = MsgPackParser.Parse(f.GetStoreBytes()); - Assert.AreEqual(4, request.GetArrayCount()); - Assert.AreEqual(MsgPackFormatter.REQUEST_TYPE, request[0].GetInt32()); - - f.GetStore().Clear(); - dispatcher.Call(f, request[1].GetInt32(), request[2].GetString(), request[3]); - var response = MsgPackParser.Parse(f.GetStoreBytes()); - Assert.AreEqual(4, response.GetArrayCount()); - Assert.AreEqual(MsgPackFormatter.RESPONSE_TYPE, response[0].GetInt32()); - Assert.True(response[2].IsNull()); - Assert.AreEqual(3, response[3].GetInt32()); - } - } - } -} diff --git a/Assets/VRM/UniJSON/Editor/Tests/RPCTests.cs.meta b/Assets/VRM/UniJSON/Editor/Tests/RPCTests.cs.meta deleted file mode 100644 index e29355505..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/RPCTests.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 05698e8d4a5f5f64c8482d2d6899301d -timeCreated: 1543250712 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/Toml.meta b/Assets/VRM/UniJSON/Editor/Tests/Toml.meta deleted file mode 100644 index fcfdc8753..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/Toml.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 6a719ea2a10120c48959e1fe817301af -folderAsset: yes -timeCreated: 1545735556 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Editor/Tests/UniJSON.Editor.Tests.asmdef b/Assets/VRM/UniJSON/Editor/Tests/UniJSON.Editor.Tests.asmdef deleted file mode 100644 index 7b5a55039..000000000 --- a/Assets/VRM/UniJSON/Editor/Tests/UniJSON.Editor.Tests.asmdef +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "UniJSON.Editor.Tests", - "references": [ - "UniJSON" - ], - "optionalUnityReferences": [ - "TestAssemblies" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false -} \ No newline at end of file diff --git a/Assets/VRM/UniJSON/LICENSE b/Assets/VRM/UniJSON/LICENSE deleted file mode 100644 index 3299d454f..000000000 --- a/Assets/VRM/UniJSON/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 ousttrue - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Assets/VRM/UniJSON/LICENSE.meta b/Assets/VRM/UniJSON/LICENSE.meta deleted file mode 100644 index 0f8b70179..000000000 --- a/Assets/VRM/UniJSON/LICENSE.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d0cd28905c8909143a42de7256c727e7 -timeCreated: 1526055773 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts.meta b/Assets/VRM/UniJSON/Scripts.meta deleted file mode 100644 index 55a5d2226..000000000 --- a/Assets/VRM/UniJSON/Scripts.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 817581cb4547fa04e877a77b4888dcc8 -folderAsset: yes -timeCreated: 1526055856 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Extensions.meta b/Assets/VRM/UniJSON/Scripts/Extensions.meta deleted file mode 100644 index c0f932bd0..000000000 --- a/Assets/VRM/UniJSON/Scripts/Extensions.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 64b77fe68ca869c40b77ae2f19862579 -folderAsset: yes -timeCreated: 1526057063 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/GenericDeserializer.cs b/Assets/VRM/UniJSON/Scripts/GenericDeserializer.cs deleted file mode 100644 index d5fa043ba..000000000 --- a/Assets/VRM/UniJSON/Scripts/GenericDeserializer.cs +++ /dev/null @@ -1,256 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - - -namespace UniJSON -{ - public static class GenericDeserializer - where T : IListTreeItem, IValue - { - public static V[] GenericArrayDeserializer(ListTreeNode s) - { - if (!s.IsArray()) - { - throw new ArgumentException("not array: " + s.Value.ValueType); - } - var u = new V[s.GetArrayCount()]; - int i = 0; - foreach (var x in s.ArrayItems()) - { - x.Deserialize(ref u[i++]); - } - return u; - } - - public static List GenericListDeserializer(ListTreeNode s) - { - if (!s.IsArray()) - { - throw new ArgumentException("not array: " + s.Value.ValueType); - } - var u = new List(s.GetArrayCount()); - foreach (var x in s.ArrayItems()) - { - var e = default(V); - x.Deserialize(ref e); - u.Add(e); - } - return u; - } - - public static object DefaultDictionaryDeserializer(ListTreeNode s) - { - switch (s.Value.ValueType) - { - case ValueNodeType.Object: - { - var u = new Dictionary(); - foreach (var kv in s.ObjectItems()) - { - //var e = default(object); - //kv.Value.Deserialize(ref e); - u.Add(kv.Key.GetString(), DefaultDictionaryDeserializer(kv.Value)); - } - return u; - } - - case ValueNodeType.Null: - return null; - - case ValueNodeType.Boolean: - return s.GetBoolean(); - - case ValueNodeType.Integer: - return s.GetInt32(); - - case ValueNodeType.Number: - return s.GetDouble(); - - case ValueNodeType.String: - return s.GetString(); - - default: - throw new NotImplementedException(s.Value.ValueType.ToString()); - } - } - - /// - /// Deserialize Dictionary only string key - /// - /// - /// - /// - public static Dictionary DictionaryDeserializer(ListTreeNode s) - { - var d = new Dictionary(); - foreach (var kv in s.ObjectItems()) - { - var value = default(V); - GenericDeserializer.Deserialize(kv.Value, ref value); - d.Add(kv.Key.GetString(), value); - } - return d; - } - - delegate void FieldSetter(ListTreeNode s, object o); - static FieldSetter GetFieldDeserializer(FieldInfo fi) - { - return (s, o) => - { - var u = default(V); - s.Deserialize(ref u); - fi.SetValue(o, u); - }; - } - - static Func, U> GetDeserializer() - { - // primitive - { - var mi = typeof(ListTreeNode).GetMethods().FirstOrDefault(x => - { - if (!x.Name.StartsWith("Get")) - { - return false; - } - - if (!x.Name.EndsWith(typeof(U).Name)) - { - return false; - } - - var parameters = x.GetParameters(); - if (parameters.Length != 0) - { - return false; - } - - if (x.ReturnType != typeof(U)) - { - return false; - } - - return true; - }); - - if (mi != null) - { - return GenericInvokeCallFactory.StaticFunc, U>(mi); - } - } - - var target = typeof(U); - - if (target.IsArray) - { - var mi = typeof(GenericDeserializer).GetMethod("GenericArrayDeserializer", - BindingFlags.Static | BindingFlags.Public); - var g = mi.MakeGenericMethod(target.GetElementType()); - return GenericInvokeCallFactory.StaticFunc, U>(g); - } - - if (target.IsGenericType) - { - if (target.GetGenericTypeDefinition() == typeof(List<>)) - { - var mi = typeof(GenericDeserializer).GetMethod("GenericListDeserializer", - BindingFlags.Static | BindingFlags.Public); - var g = mi.MakeGenericMethod(target.GetGenericArguments()); - return GenericInvokeCallFactory.StaticFunc, U>(g); - } - - if (target == typeof(Dictionary)) - { - - var mi = typeof(GenericDeserializer).GetMethod("DefaultDictionaryDeserializer", - BindingFlags.Static | BindingFlags.Public); - return GenericInvokeCallFactory.StaticFunc, U>(mi); - } - else - if (target.GetGenericTypeDefinition() == typeof(Dictionary<,>) && - target.GetGenericArguments()[0] == typeof(string)) - { - var mi = typeof(GenericDeserializer).GetMethod("DictionaryDeserializer", - BindingFlags.Static | BindingFlags.Public); - var g = mi.MakeGenericMethod(target.GetGenericArguments()[1]); - return GenericInvokeCallFactory.StaticFunc, U>(g); - } - } - - { - var schema = JsonSchema.FromType(); - return s => - { - var t = default(U); - schema.Validator.Deserialize(s, ref t); - return t; - }; - } - -#if false - if (target.IsEnum) - { - var value = Expression.Parameter(typeof(int), "value"); - var cast = Expression.Convert(value, target); - var func = Expression.Lambda(cast, value); - var compiled = (Func)func.Compile(); - return s => - { - return compiled(s.GetInt32()); - }; - } - - { - var fields = target.GetFields(BindingFlags.Instance | BindingFlags.Public); - var fieldDeserializers = fields.ToDictionary(x => Utf8String.From(x.Name), x => - { - var mi = typeof(GenericDeserializer).GetMethod("GetFieldDeserializer", - BindingFlags.Static|BindingFlags.NonPublic); - var g = mi.MakeGenericMethod(x.FieldType); - return (FieldSetter)g.Invoke(null, new object[] { x }); - }); - - return (S s) => - { - if (!s.IsMap()) - { - throw new ArgumentException(s.ValueType.ToString()); - } - - var t = (object)default(GenericCreator).Create(s); - foreach(var kv in s.ObjectItems()) - { - FieldSetter setter; - if (fieldDeserializers.TryGetValue(kv.Key, out setter)) - { - setter(kv.Value, t); - } - } - return (T)t; - }; - } -#endif - } - - public delegate U Deserializer(ListTreeNode node); - - public static Deserializer s_deserializer; - - public static void Deserialize(ListTreeNode node, ref U value) - { - if (s_deserializer == null) - { - var d = GetDeserializer(); - s_deserializer = new Deserializer(d); - } - value = s_deserializer(node); - } - - public static void SetCustomDeserializer(Deserializer deserializer) - { - s_deserializer = deserializer; - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/GenericDeserializer.cs.meta b/Assets/VRM/UniJSON/Scripts/GenericDeserializer.cs.meta deleted file mode 100644 index 2efc295d6..000000000 --- a/Assets/VRM/UniJSON/Scripts/GenericDeserializer.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 74625bf2a3d6bc64d9d92b08221a8a3d -timeCreated: 1549450914 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/IStore.meta b/Assets/VRM/UniJSON/Scripts/IStore.meta deleted file mode 100644 index 7cb52dbd8..000000000 --- a/Assets/VRM/UniJSON/Scripts/IStore.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 2596156c052e9eb4d888f01f13445446 -folderAsset: yes -timeCreated: 1531806172 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Json.meta b/Assets/VRM/UniJSON/Scripts/Json.meta deleted file mode 100644 index b2b05c2e0..000000000 --- a/Assets/VRM/UniJSON/Scripts/Json.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: f4bf1a4860dc23244837e31091692c3c -folderAsset: yes -timeCreated: 1540897217 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonSchema.cs b/Assets/VRM/UniJSON/Scripts/Json/JsonSchema.cs deleted file mode 100644 index 6e5734671..000000000 --- a/Assets/VRM/UniJSON/Scripts/Json/JsonSchema.cs +++ /dev/null @@ -1,445 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace UniJSON -{ - public class JsonSchema : IEquatable - { - public string Schema; // http://json-schema.org/draft-04/schema - - #region Annotations - string m_title; - public string Title - { - get { return m_title; } - private set - { - if (value == null) - { - m_title = ""; - } - else - { - m_title = value.Trim(); - } - } - } - - string m_desc; - public string Description - { - get { return m_desc; } - private set - { - if (value == null) - { - m_desc = ""; - } - else - { - m_desc = value.Trim(); - } - } - } - - public object Default - { - get; - private set; - } - #endregion - - public IJsonSchemaValidator Validator { get; set; } - - /// - /// Skip validator comparison - /// - public bool SkipComparison { get; set; } - - public object ExplicitIgnorableValue { private get; set; } - public int ExplicitIgnorableItemLength { private get; set; } - - public override string ToString() - { - return string.Format("<{0}>", Title); - } - - public override int GetHashCode() - { - return 1; - } - - public override bool Equals(object obj) - { - var rhs = obj as JsonSchema; - if (rhs == null) return false; - return Equals(rhs); - } - - public bool Equals(JsonSchema rhs) - { - // skip comparison - if (SkipComparison) return true; - if (rhs.SkipComparison) return true; - return Validator.Equals(rhs.Validator); - } - - public static bool operator ==(JsonSchema obj1, JsonSchema obj2) - { - if (ReferenceEquals(obj1, obj2)) - { - return true; - } - - if (ReferenceEquals(obj1, null)) - { - return false; - } - - if (ReferenceEquals(obj2, null)) - { - return false; - } - - return obj1.Equals(obj2); - } - - public static bool operator !=(JsonSchema obj1, JsonSchema obj2) - { - return !(obj1 == obj2); - } - - #region FromType - public static JsonSchema FromType() - { - return FromType(typeof(T), null, null); - } - - public static JsonSchema FromType(Type t, - BaseJsonSchemaAttribute a = null, // field attribute - ItemJsonSchemaAttribute ia = null - ) - { - // class attribute - var aa = t.GetCustomAttributes(typeof(JsonSchemaAttribute), true) - .FirstOrDefault() as JsonSchemaAttribute; - if (a != null) - { - a.Merge(aa); - } - else - { - if (aa == null) - { - a = new JsonSchemaAttribute(); - } - else - { - a = aa; - } - } - - if (ia == null) - { - ia = t.GetCustomAttributes(typeof(ItemJsonSchemaAttribute), true) - .FirstOrDefault() as ItemJsonSchemaAttribute; - } - - IJsonSchemaValidator validator = null; - bool skipComparison = a.SkipSchemaComparison; - if (t == typeof(object)) - { - skipComparison = true; - } - - if (a.EnumValues != null) - { - try - { - validator = JsonEnumValidator.Create(a.EnumValues, a.EnumSerializationType); - } - catch (Exception) - { - throw new Exception(String.Join(", ", a.EnumValues.Select(x => x.ToString()).ToArray())); - } - } - else if (t.IsEnum) - { - validator = JsonEnumValidator.Create(t, a.EnumSerializationType, a.EnumExcludes); - } - else - { - validator = JsonSchemaValidatorFactory.Create(t, a, ia); - } - - var schema = new JsonSchema - { - Title = a.Title, - Description = a.Description, - Validator = validator, - SkipComparison = skipComparison, - ExplicitIgnorableValue = a.ExplicitIgnorableValue, - ExplicitIgnorableItemLength = a.ExplicitIgnorableItemLength, - }; - - return schema; - } - #endregion - - #region FromJson - static ValueNodeType ParseValueType(string type) - { - try - { - return (ValueNodeType)Enum.Parse(typeof(ValueNodeType), type, true); - } - catch (ArgumentException) - { - throw new ArgumentException(string.Format("unknown type: {0}", type)); - } - } - - Stack m_context = new Stack(); - - static Utf8String s_ref = Utf8String.From("$ref"); - - public void Parse(IFileSystemAccessor fs, ListTreeNode root, string Key) - { - m_context.Push(Key); - - var compositionType = default(CompositionType); - var composition = new List(); - foreach (var kv in root.ObjectItems()) - { - switch (kv.Key.GetString()) - { - case "$schema": - Schema = kv.Value.GetString(); - break; - - case "$ref": - { - var refFs = fs.Get(kv.Value.GetString()); - - // parse JSON - var json = refFs.ReadAllText(); - var refRoot = JsonParser.Parse(json); - - Parse(refFs, refRoot, "$ref"); - } - break; - - #region Annotation - case "title": - Title = kv.Value.GetString(); - break; - - case "description": - Description = kv.Value.GetString(); - break; - - case "default": - Default = kv.Value; - break; - #endregion - - #region Validation - // http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1 - case "type": - if (Validator == null) - { - Validator = JsonSchemaValidatorFactory.Create(kv.Value.GetString()); - } - break; - - case "enum": - Validator = JsonEnumValidator.Create(kv.Value); - break; - - case "const": - break; - #endregion - - #region Composite - // http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.7 - case "oneOf": - break; - - case "not": - break; - - case "anyOf": // composition - case "allOf": // composition - { - compositionType = (CompositionType)Enum.Parse(typeof(CompositionType), kv.Key.GetString(), true); - foreach (var item in kv.Value.ArrayItems()) - { - if (item.ContainsKey(s_ref)) - { - var sub = JsonSchema.ParseFromPath(fs.Get(item[s_ref].GetString())); - composition.Add(sub); - } - else - { - var sub = new JsonSchema(); - sub.Parse(fs, item, compositionType.ToString()); - composition.Add(sub); - } - } - Composite(compositionType, composition); - } - break; - #endregion - - // http://json-schema.org/latest/json-schema-validation.html#rfc.section.7 - case "format": - break; - - #region Gltf - case "gltf_detailedDescription": - break; - - case "gltf_webgl": - break; - - case "gltf_uriType": - break; - #endregion - - default: - { - if (Validator != null) - { - if (Validator.FromJsonSchema(fs, kv.Key.GetString(), kv.Value)) - { - continue; - } - } - throw new NotImplementedException(string.Format("unknown key: {0}", kv.Key)); - } - } - } - m_context.Pop(); - - if (Validator == null) - { - SkipComparison = true; - } - } - - void Composite(CompositionType compositionType, List composition) - { - switch (compositionType) - { - case CompositionType.AllOf: - if (composition.Count == 1) - { - // inheritance - if (Validator == null) - { - //Validator = JsonSchemaValidatorFactory.Create(composition[0].Validator.ValueNodeType); - Validator = composition[0].Validator; - } - else - { - Validator.Merge(composition[0].Validator); - } - } - else - { - throw new NotImplementedException(); - } - break; - - case CompositionType.AnyOf: - if (Validator == null) - { - if (composition.Count == 1) - { - throw new NotImplementedException(); - //Validator = composition[0].Validator; - } - else - { - // extend enum - // enum, enum..., type - Validator = JsonEnumValidator.Create(composition, EnumSerializationType.AsString); - } - } - //throw new NotImplementedException(); - break; - - default: - throw new NotImplementedException(); - } - } - - public static JsonSchema ParseFromPath(IFileSystemAccessor fs) - { - // parse JSON - var json = fs.ReadAllText(); - var root = JsonParser.Parse(json); - - // create schema - var schema = new JsonSchema(); - schema.Parse(fs, root, "__ParseFromPath__" + fs.ToString()); - return schema; - } - #endregion - - public void Serialize(IFormatter f, T o, JsonSchemaValidationContext c = null) - { - if (c == null) - { - c = new JsonSchemaValidationContext(o) - { - EnableDiagnosisForNotRequiredFields = true, - }; - } - - var ex = Validator.Validate(c, o); - if (ex != null) - { - throw ex; - } - - Validator.Serialize(f, c, o); - } - - public void ToJson(IFormatter f) - { - f.BeginMap(2); - if (!string.IsNullOrEmpty(Title)) { f.Key("title"); f.Value(Title); } - if (!string.IsNullOrEmpty(Description)) { f.Key("description"); f.Value(Description); } - Validator.ToJsonSchema(f); - f.EndMap(); - } - - public bool IsExplicitlyIgnorableValue(T obj) - { - if (obj == null) - { - return ExplicitIgnorableValue == null; - } - - var iter = obj as System.Collections.ICollection; - if (ExplicitIgnorableItemLength != -1 && iter != null) - { - return iter.Count == ExplicitIgnorableItemLength; - } - - return obj.Equals(ExplicitIgnorableValue); - } - } - - public static class JsonSchemaExtensions - { - public static string Serialize(this JsonSchema s, T o, JsonSchemaValidationContext c = null) - { - var f = new JsonFormatter(); - s.Serialize(f, o, c); - return f.ToString(); - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonSchema.cs.meta b/Assets/VRM/UniJSON/Scripts/Json/JsonSchema.cs.meta deleted file mode 100644 index 05431a7f6..000000000 --- a/Assets/VRM/UniJSON/Scripts/Json/JsonSchema.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 4d98ef4e469916e428284c9155f29059 -timeCreated: 1526056149 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Json/JsonSchemaAttribute.cs.meta b/Assets/VRM/UniJSON/Scripts/Json/JsonSchemaAttribute.cs.meta deleted file mode 100644 index fa872cf7e..000000000 --- a/Assets/VRM/UniJSON/Scripts/Json/JsonSchemaAttribute.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: e79a9be81d4b0fc4ebd9ca47d0f20a04 -timeCreated: 1526058096 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator.meta b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator.meta deleted file mode 100644 index 817676fed..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: bebbecaad7b8e70479f6378faadbccbe -folderAsset: yes -timeCreated: 1531812228 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/IJsonSchemaValidator.cs b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/IJsonSchemaValidator.cs deleted file mode 100644 index 39449b6c6..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/IJsonSchemaValidator.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace UniJSON -{ - public class JsonSchemaValidationContext - { - Stack m_stack = new Stack(); - - public bool EnableDiagnosisForNotRequiredFields = false; - - public JsonSchemaValidationContext(object o) - { - Push(o.GetType().Name); - } - - public ActionDisposer Push(object o) - { - m_stack.Push(o.ToString()); - return new ActionDisposer(Pop); - } - - public void Pop() - { - m_stack.Pop(); - } - - public bool IsEmpty() - { - return m_stack.Count == 1; // A first element will be remained. - } - - public override string ToString() - { - return string.Join(".", m_stack.ToArray(), 0, m_stack.Count); - } - } - - - public class JsonSchemaValidationException : Exception - { - public Exception Error - { - get; private set; - } - - public JsonSchemaValidationException(JsonSchemaValidationContext context, string msg) : base(string.Format("[{0}] {1}", context, msg)) - { - } - - public JsonSchemaValidationException(JsonSchemaValidationContext context, Exception ex) : base(string.Format("[{0}] {1}", context, ex)) - { - Error = ex; - } - } - - - public interface IJsonSchemaValidator - { - #region JsonSchema - void Merge(IJsonSchemaValidator rhs); - - /// - /// Parse json schema - /// - /// - /// - /// - /// - bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode value); - - void ToJsonSchema(IFormatter f); - #endregion - - #region Serializer - /// - /// - /// - /// - /// return null if validate value - JsonSchemaValidationException Validate(JsonSchemaValidationContext context, T value); - - void Serialize(IFormatter f, JsonSchemaValidationContext context, T value); - - void Deserialize(ListTreeNode src, ref U dst) where T : IListTreeItem, IValue; - #endregion - } -} diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/IJsonSchemaValidator.cs.meta b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/IJsonSchemaValidator.cs.meta deleted file mode 100644 index 0470e0b49..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/IJsonSchemaValidator.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c35476cdb8e1a4541b2f06b9b11141d0 -timeCreated: 1531812340 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonArrayValidator.cs b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonArrayValidator.cs deleted file mode 100644 index 501fa6f0f..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonArrayValidator.cs +++ /dev/null @@ -1,300 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; - - -namespace UniJSON -{ - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4 - /// - public class JsonArrayValidator : IJsonSchemaValidator - { - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.1 - /// - public JsonSchema Items - { - get; set; - } - - // additionalItems - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.3 - /// - public int? MaxItems - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.4.4 - /// - public int? MinItems - { - get; set; - } - - // uniqueItems - - // contains - - public override int GetHashCode() - { - return 5; - } - - public override bool Equals(object obj) - { - var rhs = obj as JsonArrayValidator; - if (rhs == null) return false; - - if (Items != rhs.Items) return false; - if (MaxItems != rhs.MaxItems) return false; - if (MinItems != rhs.MinItems) return false; - - return true; - } - - public void Merge(IJsonSchemaValidator rhs) - { - throw new NotImplementedException(); - } - - public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode value) - { - switch (key) - { - case "items": - if (value.IsArray()) - { - throw new NotImplementedException(); - } - else - { - var sub = new JsonSchema(); - sub.Parse(fs, value, "items"); - Items = sub; - } - return true; - - case "additionalItems": - return true; - - case "maxItems": - MaxItems = value.GetInt32(); - return true; - - case "minItems": - MinItems = value.GetInt32(); - return true; - - case "uniqueItems": - return true; - - case "contains": - return true; - } - - return false; - } - - static class GenericCounter - { - delegate int Counter(T value); - - static Counter s_counter; - - public static int Count(T value) - { - if (s_counter == null) - { - var t = typeof(T); - if (t.IsArray) - { - var pi = t.GetProperty("Length"); - var compiled = (Func)((T array) => - { - return (int)pi.GetValue(array, null); - }); - s_counter = new Counter(compiled); - } - else if (t.GetIsGenericList()) - { - var pi = t.GetProperty("Count"); - var compiled = (Func)((T list) => - { - return (int)pi.GetValue(list, null); - }); - s_counter = new Counter(compiled); - } - else - { - throw new NotImplementedException(); - } - } - return s_counter(value); - } - } - - public JsonSchemaValidationException Validate(JsonSchemaValidationContext context, T o) - { - if (o == null) - { - return new JsonSchemaValidationException(context, "null"); - } - - var count = GenericCounter.Count(o); - - // Empty array is valid - /*if (count == 0) - { - return new JsonSchemaValidationException(context, "empty"); - }*/ - - if (MaxItems.HasValue && count > MaxItems.Value) - { - return new JsonSchemaValidationException(context, "maxItems"); - } - - if (MinItems.HasValue && count < MinItems.Value) - { - return new JsonSchemaValidationException(context, "minItems"); - } - - if (Items == null) - { - return null; // There are no json schema for items, success - } - - var v = Items.Validator; - var t = o.GetType(); - IEnumerable iter = null; - if (t.IsArray) - { - iter = o as Array; - } - else if (t.GetIsGenericList()) - { - iter = o as IList; - } - else - { - return new JsonSchemaValidationException(context, "non iterable object"); - } - - foreach(var e in iter) - { - var ex = v.Validate(context, e); - if (ex != null) - { - return ex; - } - }; - - return null; - } - - static void ArraySerializer(IJsonSchemaValidator v, IFormatter f, JsonSchemaValidationContext c, U[] array) - { - f.BeginList(array.Length); - { - //int i = 0; - foreach (var x in array) - { - //using (c.Push(i++)) - { - v.Serialize(f, c, x); - } - } - } - f.EndList(); - } - - static void ListSerializer(IJsonSchemaValidator v, IFormatter f, JsonSchemaValidationContext c, List list) - { - f.BeginList(list.Count); - { - //int i = 0; - foreach (var x in list) - { - //using (c.Push(i++)) - { - v.Serialize(f, c, x); - } - } - } - f.EndList(); - } - - static class GenericSerializer - { - delegate void Serializer(IJsonSchemaValidator v, IFormatter f, JsonSchemaValidationContext c, T o); - - static Serializer s_serializer; - - public static void Serialize(IJsonSchemaValidator v, IFormatter f, JsonSchemaValidationContext c, T o) - { - if (s_serializer == null) - { - var t = typeof(T); - MethodInfo g = null; - if (t.IsArray) - { - var mi = typeof(JsonArrayValidator).GetMethod("ArraySerializer", - BindingFlags.Static | BindingFlags.NonPublic); - g = mi.MakeGenericMethod(t.GetElementType()); - } - else if (t.GetIsGenericList()) - { - // ToDo: IList - var mi = typeof(JsonArrayValidator).GetMethod("ListSerializer", - BindingFlags.Static | BindingFlags.NonPublic); - g = mi.MakeGenericMethod(t.GetGenericArguments()); - } - else - { - throw new NotImplementedException(); - } - - var compiled = (Action< - IJsonSchemaValidator, - IFormatter, - JsonSchemaValidationContext, - T>) - GenericInvokeCallFactory.StaticAction< - IJsonSchemaValidator, - IFormatter, - JsonSchemaValidationContext, - T>(g); - s_serializer = new Serializer(compiled); - } - s_serializer(v, f, c, o); - } - } - - public void Serialize(IFormatter f, JsonSchemaValidationContext c, T o) - { - GenericSerializer.Serialize(Items.Validator, f, c, o); - } - - public void ToJsonSchema(IFormatter f) - { - f.Key("type"); f.Value("array"); - - if (Items != null) - { - f.Key("items"); - Items.ToJson(f); - } - } - - public void Deserialize(ListTreeNode src, ref U dst) - where T : IListTreeItem, IValue - { - src.Deserialize(ref dst); - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonArrayValidator.cs.meta b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonArrayValidator.cs.meta deleted file mode 100644 index 0c5ed09b5..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonArrayValidator.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6144a646f2f535641885a006024771a4 -timeCreated: 1531812663 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonBoolValidator.cs b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonBoolValidator.cs deleted file mode 100644 index 93e4f1a20..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonBoolValidator.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; - - -namespace UniJSON -{ - public class JsonBoolValidator : IJsonSchemaValidator - { - public override int GetHashCode() - { - return 1; - } - - public override bool Equals(object obj) - { - var rhs = obj as JsonBoolValidator; - if (rhs == null) return false; - return true; - } - - public void Merge(IJsonSchemaValidator obj) - { - throw new NotImplementedException(); - } - - public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode value) - { - return false; - } - - public void ToJsonSchema(IFormatter f) - { - f.Key("type"); f.Value("boolean"); - } - - public JsonSchemaValidationException Validate(JsonSchemaValidationContext c, T value) - { - return null; - } - - public void Serialize(IFormatter f, JsonSchemaValidationContext c, T value) - { - f.Serialize(value); - } - - public void Deserialize(ListTreeNode src, ref U dst) - where T : IListTreeItem, IValue - { - dst = GenericCast.Cast(src.GetBoolean()); - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonBoolValidator.cs.meta b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonBoolValidator.cs.meta deleted file mode 100644 index 6604e10ce..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonBoolValidator.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 2a6454bbd9b910d499702d2ba8270ea0 -timeCreated: 1531812394 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonDictionaryValidator.cs b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonDictionaryValidator.cs deleted file mode 100644 index c28fab0a8..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonDictionaryValidator.cs +++ /dev/null @@ -1,307 +0,0 @@ -using System; -using System.Linq; -using System.Collections.Generic; - -namespace UniJSON -{ - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5 - /// - public class JsonDictionaryValidator : IJsonSchemaValidator - { - public JsonDictionaryValidator() - { - AdditionalProperties = JsonSchema.FromType(); - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.1 - /// - public int MaxProperties - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.2 - /// - public int MinProperties - { - get; set; - } - - List m_required = new List(); - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.3 - /// - public List Required - { - get { return m_required; } - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.5 - /// - public string PatternProperties - { - get; private set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.6 - /// - public JsonSchema AdditionalProperties - { - get; set; - } - - Dictionary m_dependencies; - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.7 - /// - public Dictionary Dependencies - { - get - { - if (m_dependencies == null) - { - m_dependencies = new Dictionary(); - } - return m_dependencies; - } - } - - public override int GetHashCode() - { - return 6; - } - - public override bool Equals(object obj) - { - var rhs = obj as JsonObjectValidator; - if (rhs == null) - { - return false; - } - - if (Required.Count != rhs.Required.Count) - { - return false; - } - if (!Required.OrderBy(x => x).SequenceEqual(rhs.Required.OrderBy(x => x))) - { - return false; - } - - if (Dependencies.Count != rhs.Dependencies.Count) - { - return false; - } - foreach (var kv in Dependencies) - { - if (!kv.Value.OrderBy(x => x).SequenceEqual(rhs.Dependencies[kv.Key].OrderBy(x => x))) - { - return false; - } - } - - if (AdditionalProperties == null - && rhs.AdditionalProperties == null) - { - // ok - } - else if (AdditionalProperties == null) - { - return false; - } - else if (rhs.AdditionalProperties == null) - { - return false; - } - else - { - if (!AdditionalProperties.Equals(rhs.AdditionalProperties)) - { - return false; - } - } - - return true; - } - - public void Merge(IJsonSchemaValidator obj) - { - var rhs = obj as JsonObjectValidator; - if (rhs == null) - { - throw new ArgumentException(); - } - - foreach (var x in rhs.Required) - { - this.Required.Add(x); - } - - if (rhs.AdditionalProperties != null) - { - if (AdditionalProperties != null) - { - throw new NotImplementedException(); - } - AdditionalProperties = rhs.AdditionalProperties; - } - } - - public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode value) - { - switch (key) - { - case "maxProperties": - MaxProperties = value.GetInt32(); - return true; - - case "minProperties": - MinProperties = value.GetInt32(); - return true; - - case "required": - { - foreach (var req in value.ArrayItems()) - { - m_required.Add(req.GetString()); - } - } - return true; - - case "patternProperties": - PatternProperties = value.GetString(); - return true; - - case "additionalProperties": - { - var sub = new JsonSchema(); - sub.Parse(fs, value, "additionalProperties"); - AdditionalProperties = sub; - } - return true; - - case "dependencies": - { - foreach (var kv in value.ObjectItems()) - { - Dependencies.Add(kv.Key.GetString(), kv.Value.ArrayItems().Select(x => x.GetString()).ToArray()); - } - } - return true; - - case "propertyNames": - return true; - } - - return false; - } - - public void ToJsonSchema(IFormatter f) - { - f.Key("type"); f.Value("object"); - } - - public JsonSchemaValidationException Validate(JsonSchemaValidationContext c, S o) - { - if (o == null) - { - return new JsonSchemaValidationException(c, "null"); - } - - var d = o as IDictionary; - if (d == null) - { - return new JsonSchemaValidationException(c, "not dictionary"); - } - - if (Required != null) - { - foreach (var x in Required) - { - using (c.Push(x)) - { - // ToDo - } - } - } - - if (AdditionalProperties != null) - { - foreach (var kv in d) - { - using (c.Push(kv.Key)) - { - var result = AdditionalProperties.Validator.Validate(c, kv.Value); - if (result != null) - { - return result; - } - } - } - } - - return null; - } - - Dictionary m_validValueMap = new Dictionary(); - - public void Serialize(IFormatter f, JsonSchemaValidationContext c, S o) - { - // validate properties - m_validValueMap.Clear(); - - var dict = o as Dictionary; - f.BeginMap(dict.Count); - { - foreach (var kv in dict) - { - // key - f.Key(kv.Key); - - // value - //using (c.Push(kv.Key)) - { - AdditionalProperties.Validator.Serialize(f, c, kv.Value); - } - } - } - f.EndMap(); - } - - public void Deserialize(ListTreeNode src, ref V dst) - where U : IListTreeItem, IValue - { - src.Deserialize(ref dst); - } - } - - public static class JsonDictionaryValidator - { - public static JsonDictionaryValidator Create() - { - return new JsonDictionaryValidator(); - } - - #region AOT - public static JsonDictionaryValidator CreateSingle() - { - return Create(); - } - - public static JsonDictionaryValidator CreateInt32() - { - return Create(); - } - - public static JsonDictionaryValidator CreateBoolean() - { - return Create(); - } - #endregion - } -} diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonDictionaryValidator.cs.meta b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonDictionaryValidator.cs.meta deleted file mode 100644 index 65d5fbc05..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonDictionaryValidator.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ccee0323c35d40d498d45b207124fe7e -timeCreated: 1531812708 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonEnumValidator.cs b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonEnumValidator.cs deleted file mode 100644 index 26177ef63..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonEnumValidator.cs +++ /dev/null @@ -1,441 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - - -namespace UniJSON -{ - public static class JsonEnumValidator - { - public static IJsonSchemaValidator Create(ListTreeNode value) - { - foreach (var x in value.ArrayItems()) - { - if (x.IsInteger() || x.IsFloat()) - { - return JsonIntEnumValidator.Create(value.ArrayItems() - .Where(y => y.IsInteger() || y.IsFloat()) - .Select(y => y.GetInt32()) - ); - } - else if (x.IsString()) - { - - return JsonStringEnumValidator.Create(value.ArrayItems() - .Where(y => y.IsString()) - .Select(y => y.GetString()) - , EnumSerializationType.AsString - ); - } - else - { - } - } - - throw new NotImplementedException(); - } - - public static IJsonSchemaValidator Create(IEnumerable composition, EnumSerializationType type) - { - foreach (var x in composition) - { - if (x.Validator is JsonStringEnumValidator) - { - return JsonStringEnumValidator.Create(composition - .Select(y => y.Validator as JsonStringEnumValidator) - .Where(y => y != null) - .SelectMany(y => y.Values), - type - ); - } - if (x.Validator is JsonIntEnumValidator) - { - return JsonIntEnumValidator.Create(composition - .Select(y => y.Validator as JsonIntEnumValidator) - .Where(y => y != null) - .SelectMany(y => y.Values) - ); - } - } - - throw new NotImplementedException(); - } - - static IEnumerable GetStringValues(Type t, object[] excludes, Func filter) - { - foreach (var x in Enum.GetValues(t)) - { - if (excludes == null || !excludes.Contains(x)) - { - yield return filter(x.ToString()); - } - } - } - - static IEnumerable GetIntValues(Type t, object[] excludes) - { - foreach (var x in Enum.GetValues(t)) - { - if (excludes == null || !excludes.Contains(x)) - { - yield return (int)x; - } - } - } - - public static IJsonSchemaValidator Create(Type t, EnumSerializationType serializationType, object[] excludes) - { - switch (serializationType) - { - case EnumSerializationType.AsInt: - return JsonIntEnumValidator.Create(GetIntValues(t, excludes)); - - case EnumSerializationType.AsString: - return JsonStringEnumValidator.Create(GetStringValues(t, excludes, x => x), serializationType); - - case EnumSerializationType.AsLowerString: - return JsonStringEnumValidator.Create(GetStringValues(t, excludes, x => x.ToLower()), serializationType); - - case EnumSerializationType.AsUpperString: - return JsonStringEnumValidator.Create(GetStringValues(t, excludes, x => x.ToUpper()), serializationType); - - default: - throw new NotImplementedException(); - } - } - - public static IJsonSchemaValidator Create(object[] values, EnumSerializationType type) - { - foreach (var x in values) - { - if (x is string) - { - return JsonStringEnumValidator.Create(values.Select(y => (string)y), type); - } - if (x is int) - { - return JsonIntEnumValidator.Create(values.Select(y => (int)y)); - } - } - - throw new NotImplementedException(); - } - } - - public class JsonStringEnumValidator : IJsonSchemaValidator - { - EnumSerializationType SerializationType; - - public String[] Values - { - get; set; - } - - JsonStringEnumValidator(IEnumerable values, EnumSerializationType type) - { - SerializationType = type; - switch (SerializationType) - { - case EnumSerializationType.AsString: - Values = values.ToArray(); - break; - - case EnumSerializationType.AsLowerString: - Values = values.Select(x => x.ToLower()).ToArray(); - break; - - case EnumSerializationType.AsUpperString: - Values = values.Select(x => x.ToUpper()).ToArray(); - break; - - case EnumSerializationType.AsInt: - throw new ArgumentException("JsonStringEnumValidator not allow AsInt"); - - default: - throw new NotImplementedException(""); - } - } - - public static JsonStringEnumValidator Create(IEnumerable values, EnumSerializationType type) - { - return new JsonStringEnumValidator(values, type); - } - - public override int GetHashCode() - { - return 7; - } - - public override bool Equals(object obj) - { - var rhs = obj as JsonStringEnumValidator; - if (rhs == null) return false; - - if (Values.Length != rhs.Values.Length) return false; - - var l = Values.OrderBy(x => x).GetEnumerator(); - var r = rhs.Values.OrderBy(x => x).GetEnumerator(); - while (l.MoveNext() && r.MoveNext()) - { - if (l.Current != r.Current) - { - return false; - } - } - return true; - } - - public void Merge(IJsonSchemaValidator obj) - { - throw new NotImplementedException(); - } - - public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode value) - { - throw new NotImplementedException(); - } - - public void ToJsonSchema(IFormatter f) - { - f.Key("type"); f.Value("string"); - f.Key("enum"); - f.BeginList(Values.Length); - foreach (var x in Values) - { - f.Value(x); - } - f.EndList(); - } - - public JsonSchemaValidationException Validate(JsonSchemaValidationContext c, T o) - { - if (o == null) - { - return new JsonSchemaValidationException(c, "null"); - } - - var t = o.GetType(); - string value = null; - if (t.IsEnum) - { - value = Enum.GetName(t, o); - } - else - { - value = GenericCast.Cast(o); - } - - if (SerializationType == EnumSerializationType.AsLowerString) - { - value = value.ToLower(); - } - else if (SerializationType == EnumSerializationType.AsUpperString) - { - value = value.ToUpper(); - } - - if (Values.Contains(value)) - { - return null; - } - else - { - return new JsonSchemaValidationException(c, string.Format("{0} is not valid enum", o)); - } - } - - public static class GenericSerializer - { - delegate void Serializer(JsonStringEnumValidator v, - IFormatter f, JsonSchemaValidationContext c, T o); - - static Serializer s_serializer; - - public static void Serialize(JsonStringEnumValidator validator, - IFormatter f, JsonSchemaValidationContext c, T o) - { - if (s_serializer == null) - { - var t = typeof(T); - if (t.IsEnum) - { - s_serializer = (vv, ff, cc, oo) => - { - var value = Enum.GetName(t, oo); - if (vv.SerializationType == EnumSerializationType.AsLowerString) - { - value = value.ToLower(); - } - else if (vv.SerializationType == EnumSerializationType.AsUpperString) - { - value = value.ToUpper(); - } - ff.Value(value); - }; - } - else if (t == typeof(string)) - { - s_serializer = (vv, ff, cc, oo) => - { - var value = GenericCast.Cast(oo); - if (vv.SerializationType == EnumSerializationType.AsLowerString) - { - value = value.ToLower(); - } - else if (vv.SerializationType == EnumSerializationType.AsUpperString) - { - value = value.ToUpper(); - } - ff.Value(value); - }; - } - else - { - throw new NotImplementedException(); - } - } - s_serializer(validator, f, c, o); - } - } - - public void Serialize(IFormatter f, JsonSchemaValidationContext c, T o) - { - GenericSerializer.Serialize(this, f, c, o); - } - - static class GenericDeserializer - where T : IListTreeItem, IValue - { - delegate U Deserializer(ListTreeNode src); - static Deserializer s_d; - public static void Deserialize(ListTreeNode src, ref U t) - { - if (s_d == null) - { - if (typeof(U).IsEnum) - { - // enum from string - var mi = typeof(Enum).GetMethods(BindingFlags.Static | BindingFlags.Public).First( - x => x.Name == "Parse" && x.GetParameters().Length == 3 - ); - - var enumParse = GenericInvokeCallFactory.StaticFunc(mi); - s_d = x => - { - var enumValue = enumParse(typeof(U), x.GetString(), true); - return GenericCast.Cast(enumValue); - }; - } - else - { - s_d = x => GenericCast.Cast(x.GetString()); - } - } - t = s_d(src); - } - } - - public void Deserialize(ListTreeNode src, ref U dst) - where T : IListTreeItem, IValue - { - GenericDeserializer.Deserialize(src, ref dst); - } - } - - public class JsonIntEnumValidator : IJsonSchemaValidator - { - public int[] Values - { - get; set; - } - - public static JsonIntEnumValidator Create(IEnumerable values) - { - return new JsonIntEnumValidator - { - Values = values.ToArray() - }; - } - - public override int GetHashCode() - { - return 7; - } - - public override bool Equals(object obj) - { - var rhs = obj as JsonIntEnumValidator; - if (rhs == null) return false; - - if (Values.Length != rhs.Values.Length) return false; - - var l = Values.OrderBy(x => x).GetEnumerator(); - var r = rhs.Values.OrderBy(x => x).GetEnumerator(); - while (l.MoveNext() && r.MoveNext()) - { - if (l.Current != r.Current) - { - return false; - } - } - return true; - } - - public void Merge(IJsonSchemaValidator obj) - { - throw new NotImplementedException(); - } - - public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode value) - { - throw new NotImplementedException(); - } - - public void ToJsonSchema(IFormatter f) - { - f.Key("type"); f.Value("integer"); - } - - public JsonSchemaValidationException Validate(JsonSchemaValidationContext c, T o) - { - if (Values.Contains(GenericCast.Cast(o))) - { - return null; - } - else - { - return new JsonSchemaValidationException(c, string.Format("{0} is not valid enum", o)); - } - } - - public void Serialize(IFormatter f, JsonSchemaValidationContext c, T o) - { - f.Serialize(GenericCast.Cast(o)); - } - - static class GenericDeserializer - where T : IListTreeItem, IValue - { - delegate U Deserializer(ListTreeNode src); - - static Deserializer s_d; - - public static void Deserialize(ListTreeNode src, ref U dst) - { - if (s_d == null) - { - // enum from int - s_d = s => GenericCast.Cast(s.GetInt32()); - } - dst = s_d(src); - } - } - - public void Deserialize(ListTreeNode src, ref U dst) - where T : IListTreeItem, IValue - { - GenericDeserializer.Deserialize(src, ref dst); - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonEnumValidator.cs.meta b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonEnumValidator.cs.meta deleted file mode 100644 index 0fd90809b..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonEnumValidator.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f503fff7ab8dcf74abc9dd8073aa9062 -timeCreated: 1531812758 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonNumberValidator.cs b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonNumberValidator.cs deleted file mode 100644 index 223ff4bdf..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonNumberValidator.cs +++ /dev/null @@ -1,430 +0,0 @@ -using System; - - -namespace UniJSON -{ - /// - /// http://json-schema.org/latest/json-schema-validation.html#numeric - /// - public class JsonIntValidator : IJsonSchemaValidator - { - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.1 - /// - public int? MultipleOf - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.2 - /// - public int? Maximum - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.3 - /// - public bool ExclusiveMaximum - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.4 - /// - public int? Minimum - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.5 - /// - public bool ExclusiveMinimum - { - get; set; - } - - public override int GetHashCode() - { - return 2; - } - - public override bool Equals(object obj) - { - var rhs = obj as JsonIntValidator; - if (rhs == null) return false; - - if (MultipleOf != rhs.MultipleOf) - { - Console.WriteLine("MultipleOf"); - return false; - } - if (Maximum != rhs.Maximum) - { - Console.WriteLine("Maximum"); - return false; - } - - if (ExclusiveMaximum != rhs.ExclusiveMaximum) - { - Console.WriteLine("ExclusiveMaximum"); - return false; - } - - if (Minimum != rhs.Minimum) - { - Console.WriteLine("Minimum"); - return false; - } - - if (ExclusiveMinimum != rhs.ExclusiveMinimum) - { - Console.WriteLine("ExclusiveMinimum"); - return false; - } - - return true; - } - - public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode value) - { - switch (key) - { - case "multipleOf": - MultipleOf = value.GetInt32(); - return true; - - case "maximum": - Maximum = value.GetInt32(); - return true; - - case "exclusiveMaximum": - ExclusiveMaximum = value.GetBoolean(); - return true; - - case "minimum": - Minimum = value.GetInt32(); - return true; - - case "exclusiveMinimum": - ExclusiveMinimum = value.GetBoolean(); - return true; - } - - return false; - } - - public void ToJsonSchema(IFormatter f) - { - f.Key("type"); f.Value("integer"); - if (Minimum.HasValue) - { - f.Key("minimum"); f.Value(Minimum.Value); - } - if (Maximum.HasValue) - { - f.Key("maximum"); f.Value(Maximum.Value); - } - } - - public void Merge(IJsonSchemaValidator obj) - { - var rhs = obj as JsonIntValidator; - if (rhs == null) - { - throw new ArgumentException(); - } - - MultipleOf = rhs.MultipleOf; - Maximum = rhs.Maximum; - ExclusiveMaximum = rhs.ExclusiveMaximum; - Minimum = rhs.Minimum; - ExclusiveMinimum = rhs.ExclusiveMinimum; - } - - public JsonSchemaValidationException Validate(JsonSchemaValidationContext c, T o) - { - try - { - var value = GenericCast.Cast(o); - - if (Minimum.HasValue) - { - if (ExclusiveMinimum) - { - if (value > Minimum.Value) - { - // ok - } - else - { - return new JsonSchemaValidationException(c, string.Format("minimum: ! {0}>{1}", value, Minimum.Value)); - } - } - else - { - if (value >= Minimum.Value) - { - // ok - } - else - { - return new JsonSchemaValidationException(c, string.Format("minimum: ! {0}>={1}", value, Minimum.Value)); - } - } - } - - if (Maximum.HasValue) - { - if (ExclusiveMaximum) - { - if (value < Maximum.Value) - { - // ok - } - else - { - return new JsonSchemaValidationException(c, string.Format("maximum: ! {0}<{1}", value, Maximum.Value)); - } - } - else - { - if (value <= Maximum.Value) - { - // ok - } - else - { - return new JsonSchemaValidationException(c, string.Format("maximum: ! {0}<={1}", value, Maximum.Value)); - } - } - } - - if (MultipleOf.HasValue && value % MultipleOf.Value != 0) - { - return new JsonSchemaValidationException(c, string.Format("multipleOf: {0}%{1}", value, MultipleOf.Value)); - } - - return null; - } - catch (Exception ex) - { - return new JsonSchemaValidationException(c, ex); - } - } - - public void Serialize(IFormatter f, JsonSchemaValidationContext c, T o) - { - f.Serialize(GenericCast.Cast(o)); - } - - public void Deserialize(ListTreeNode src, ref U dst) - where T : IListTreeItem, IValue - { - dst = GenericCast.Cast(src.GetInt32()); - } - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#numeric - /// - public class JsonNumberValidator : IJsonSchemaValidator - { - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.1 - /// - public double? MultipleOf - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.2 - /// - public double? Maximum - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.3 - /// - public bool ExclusiveMaximum - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.4 - /// - public double? Minimum - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.2.5 - /// - public bool ExclusiveMinimum - { - get; set; - } - - public override int GetHashCode() - { - return 3; - } - - public override bool Equals(object obj) - { - var rhs = obj as JsonNumberValidator; - if (rhs == null) return false; - - if (MultipleOf != rhs.MultipleOf) return false; - if (Maximum != rhs.Maximum) return false; - if (ExclusiveMaximum != rhs.ExclusiveMaximum) return false; - if (Minimum != rhs.Minimum) return false; - if (ExclusiveMinimum != rhs.ExclusiveMinimum) return false; - - return true; - } - - public void Merge(IJsonSchemaValidator rhs) - { - throw new NotImplementedException(); - } - - public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode value) - { - switch (key) - { - case "multipleOf": - MultipleOf = value.GetDouble(); - return true; - - case "maximum": - Maximum = value.GetDouble(); - return true; - - case "exclusiveMaximum": - ExclusiveMaximum = value.GetBoolean(); - return true; - - case "minimum": - Minimum = value.GetDouble(); - return true; - - case "exclusiveMinimum": - ExclusiveMinimum = value.GetBoolean(); - return true; - } - - return false; - } - - public void ToJsonSchema(IFormatter f) - { - f.Key("type"); f.Value("number"); - if (Minimum.HasValue) - { - f.Key("minimum"); f.Value(Minimum.Value); - } - if (Maximum.HasValue) - { - f.Key("maximum"); f.Value(Maximum.Value); - } - } - - public JsonSchemaValidationException Validate(JsonSchemaValidationContext c, T o) - { - try - { - var value = Convert.ToDouble(o); - - if (Minimum.HasValue) - { - if (ExclusiveMinimum) - { - if (value > Minimum.Value) - { - // ok - } - else - { - return new JsonSchemaValidationException(c, string.Format("minimum: ! {0}>{1}", value, Minimum.Value)); - } - } - else - { - if (value >= Minimum.Value) - { - // ok - } - else - { - return new JsonSchemaValidationException(c, string.Format("minimum: ! {0}>={1}", value, Minimum.Value)); - } - } - } - - if (Maximum.HasValue) - { - if (ExclusiveMaximum) - { - if (value < Maximum.Value) - { - // ok - } - else - { - return new JsonSchemaValidationException(c, string.Format("maximum: ! {0}<{1}", value, Maximum.Value)); - } - } - else - { - if (value <= Maximum.Value) - { - // ok - } - else - { - return new JsonSchemaValidationException(c, string.Format("maximum: ! {0}<={1}", value, Maximum.Value)); - } - } - } - - /* - if (MultipleOf.HasValue && value % MultipleOf.Value != 0) - { - return new JsonSchemaValidationException(c, string.Format("multipleOf: {0}%{1}", value, MultipleOf.Value)); - } - */ - if (MultipleOf.HasValue) - { - throw new NotImplementedException(); - } - - return null; - } - catch (Exception ex) - { - return new JsonSchemaValidationException(c, ex); - } - } - - public void Serialize(IFormatter f, JsonSchemaValidationContext c, T o) - { - f.Serialize(o); - } - - public void Deserialize(ListTreeNode src, ref U dst) - where T : IListTreeItem, IValue - { - dst = GenericCast.Cast(src.GetDouble()); - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonNumberValidator.cs.meta b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonNumberValidator.cs.meta deleted file mode 100644 index 6651eeb4b..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonNumberValidator.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: fb1d83ccd68b93c47821000b53471eae -timeCreated: 1531812526 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonObjectValidator.cs b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonObjectValidator.cs deleted file mode 100644 index e49ee8fc3..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonObjectValidator.cs +++ /dev/null @@ -1,686 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - - -namespace UniJSON -{ - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5 - /// - public class JsonObjectValidator : IJsonSchemaValidator - { - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.1 - /// - public int MaxProperties - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.2 - /// - public int MinProperties - { - get; set; - } - - HashSet m_required = new HashSet(); - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.3 - /// - public HashSet Required - { - get { return m_required; } - } - - Dictionary m_props; - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.4 - /// - public Dictionary Properties - { - get - { - if (m_props == null) - { - m_props = new Dictionary(); - } - return m_props; - } - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.5 - /// - public string PatternProperties - { - get; private set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.6 - /// - public JsonSchema AdditionalProperties - { - get; set; - } - - Dictionary m_dependencies; - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.5.7 - /// - public Dictionary Dependencies - { - get - { - if (m_dependencies == null) - { - m_dependencies = new Dictionary(); - } - return m_dependencies; - } - } - - public void AddProperty(IFileSystemAccessor fs, string key, ListTreeNode value) - { - var sub = new JsonSchema(); - sub.Parse(fs, value, key); - - if (Properties.ContainsKey(key)) - { - if (sub.Validator != null) - { - Properties[key].Validator.Merge(sub.Validator); - } - } - else - { - Properties.Add(key, sub); - } - } - - public override int GetHashCode() - { - return 6; - } - - public override bool Equals(object obj) - { - var rhs = obj as JsonObjectValidator; - if (rhs == null) - { - return false; - } - - if (Properties.Count != rhs.Properties.Count) - { - return false; - } - foreach (var pair in Properties) - { - JsonSchema value; - if (rhs.Properties.TryGetValue(pair.Key, out value)) - { -#if true - if (!value.Equals(pair.Value)) - { - Console.WriteLine(string.Format("{0} is not equals", pair.Key)); - var l = pair.Value.Validator; - var r = value.Validator; - return false; - } -#else - // key name match - return true; -#endif - } - else - { - return false; - } - } - - if (Required.Count != rhs.Required.Count) - { - return false; - } - if (!Required.OrderBy(x => x).SequenceEqual(rhs.Required.OrderBy(x => x))) - { - return false; - } - - if (Dependencies.Count != rhs.Dependencies.Count) - { - return false; - } - foreach (var kv in Dependencies) - { - if (!kv.Value.OrderBy(x => x).SequenceEqual(rhs.Dependencies[kv.Key].OrderBy(x => x))) - { - return false; - } - } - - if (AdditionalProperties == null - && rhs.AdditionalProperties == null) - { - // ok - } - else if (AdditionalProperties == null) - { - return false; - } - else if (rhs.AdditionalProperties == null) - { - return false; - } - else - { - if (!AdditionalProperties.Equals(rhs.AdditionalProperties)) - { - return false; - } - } - - return true; - } - - public void Merge(IJsonSchemaValidator obj) - { - var rhs = obj as JsonObjectValidator; - if (rhs == null) - { - throw new ArgumentException(); - } - - foreach (var x in rhs.Properties) - { - if (this.Properties.ContainsKey(x.Key)) - { - this.Properties[x.Key] = x.Value; - } - else - { - this.Properties.Add(x.Key, x.Value); - } - } - - foreach (var x in rhs.Required) - { - this.Required.Add(x); - } - - if (rhs.AdditionalProperties != null) - { - if (AdditionalProperties != null) - { - throw new NotImplementedException(); - } - AdditionalProperties = rhs.AdditionalProperties; - } - } - - public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode value) - { - switch (key) - { - case "maxProperties": - MaxProperties = value.GetInt32(); - return true; - - case "minProperties": - MinProperties = value.GetInt32(); - return true; - - case "required": - { - foreach (var req in value.ArrayItems()) - { - m_required.Add(req.GetString()); - } - } - return true; - - case "properties": - { - foreach (var prop in value.ObjectItems()) - { - AddProperty(fs, prop.Key.GetString(), prop.Value); - } - } - return true; - - case "patternProperties": - PatternProperties = value.GetString(); - return true; - - case "additionalProperties": - { - var sub = new JsonSchema(); - sub.Parse(fs, value, "additionalProperties"); - AdditionalProperties = sub; - } - return true; - - case "dependencies": - { - foreach (var kv in value.ObjectItems()) - { - Dependencies.Add(kv.Key.GetString(), kv.Value.ArrayItems().Select(x => x.GetString()).ToArray()); - } - } - return true; - - case "propertyNames": - return true; - } - - return false; - } - - public void ToJsonSchema(IFormatter f) - { - f.Key("type"); f.Value("object"); - if (Properties.Count > 0) - { - f.Key("properties"); - f.BeginMap(Properties.Count); - foreach (var kv in Properties) - { - f.Key(kv.Key); - kv.Value.ToJson(f); - } - f.EndMap(); - } - } - - static class GenericFieldView - { - public static FieldInfo[] GetFields() - { - var t = typeof(T); - return t.GetFields(BindingFlags.Instance | BindingFlags.Public); - } - - public static void CreateFieldProcessors( - Func creator, - Dictionary processors - ) - { - foreach (var fi in GetFields()) - { - processors.Add(fi.Name, creator(fi)); - } - } - } - - internal class ValidationResult - { - public bool IsIgnorable; - public JsonSchemaValidationException Ex; - } - - public static class GenericValidator - { - class ObjectValidator - { - delegate JsonSchemaValidationException FieldValidator( - JsonSchema s, JsonSchemaValidationContext c, T o, out bool isIgnorable); - - Dictionary m_validators; - - static FieldValidator CreateFieldValidator(FieldInfo fi) - { - var mi = typeof(ObjectValidator).GetMethod("_CreateFieldValidator", - BindingFlags.Static | BindingFlags.NonPublic) - ; - var g = mi.MakeGenericMethod(fi.FieldType); - return GenericInvokeCallFactory.StaticFunc(g)(fi); - } - - static FieldValidator _CreateFieldValidator(FieldInfo fi) - { - var getter = (Func)((t) => (U)fi.GetValue(t)); - - return (JsonSchema s, JsonSchemaValidationContext c, T o, out bool isIgnorable) => - { - var v = s.Validator; - using (c.Push(fi.Name)) - { - var field = getter(o); - var ex = v.Validate(c, field); - - isIgnorable = ex != null && s.IsExplicitlyIgnorableValue(field); - - return ex; - } - }; - } - - public ObjectValidator() - { - var validators = new Dictionary(); - GenericFieldView.CreateFieldProcessors( - CreateFieldValidator, validators); - - m_validators = validators; - } - - public JsonSchemaValidationException ValidateProperty( - HashSet required, - KeyValuePair property, - JsonSchemaValidationContext c, - T o, - out bool isIgnorable - ) - { - var fieldName = property.Key; - var schema = property.Value; - - isIgnorable = false; - - FieldValidator fv; - if (m_validators.TryGetValue(fieldName, out fv)) - { - var isRequired = required != null && required.Contains(fieldName); - - bool isMemberIgnorable; - var ex = fv(schema, c, o, out isMemberIgnorable); - if (ex != null) - { - isIgnorable = !isRequired && isMemberIgnorable; - - if (isRequired // required fields must be checked - || c.EnableDiagnosisForNotRequiredFields) - { - return ex; - } - } - } - - return null; - } - - public JsonSchemaValidationException Validate( - HashSet required, - Dictionary properties, - JsonSchemaValidationContext c, T o) - { - foreach (var kv in properties) - { - bool isIgnorable; - var ex = ValidateProperty(required, kv, c, o, out isIgnorable); - if (ex != null && !isIgnorable) - { - return ex; - } - } - - return null; - } - - public void ValidationResults - (HashSet required, - Dictionary properties, - JsonSchemaValidationContext c, T o, - Dictionary results) - { - foreach (var kv in properties) - { - bool isIgnorable; - var ex = ValidateProperty(required, kv, c, o, out isIgnorable); - - results.Add(kv.Key, new ValidationResult { - IsIgnorable = isIgnorable, - Ex = ex, - }); - } - } - } - - static ObjectValidator s_validator; - - static void prepareValidator() - { - if (s_validator == null) - { - s_validator = new ObjectValidator(); - } - } - - public static JsonSchemaValidationException Validate(HashSet required, - Dictionary properties, - JsonSchemaValidationContext c, T o) - { - prepareValidator(); - return s_validator.Validate(required, properties, c, o); - } - - internal static void ValidationResults(HashSet required, - Dictionary properties, - JsonSchemaValidationContext c, T o, - Dictionary results) - { - prepareValidator(); - s_validator.ValidationResults(required, properties, c, o, results); - } - } - - public JsonSchemaValidationException Validate(JsonSchemaValidationContext c, T o) - { - if (o == null) - { - return new JsonSchemaValidationException(c, "null"); - } - - if (Properties.Count < MinProperties) - { - return new JsonSchemaValidationException(c, "no properties"); - } - - return GenericValidator.Validate(Required, Properties, c, o); - } - - static class GenericSerializer - { - class Serializer - { - delegate void FieldSerializer(JsonSchema s, JsonSchemaValidationContext c, IFormatter f, T o, - Dictionary vRes, string[] deps); - - Dictionary m_serializers; - - static FieldSerializer CreateFieldSerializer(FieldInfo fi) - { - var mi = typeof(Serializer).GetMethod("_CreateFieldSerializer", - BindingFlags.Static | BindingFlags.NonPublic); - var g = mi.MakeGenericMethod(fi.FieldType); - return GenericInvokeCallFactory.StaticFunc(g)(fi); - } - - static FieldSerializer _CreateFieldSerializer(FieldInfo fi) - { - Func getter = t => - { - return (U)fi.GetValue(t); - }; - - return (s, c, f, o, vRes, deps) => - { - var v = s.Validator; - var field = getter(o); - - if (vRes[fi.Name].Ex != null) - { - return; - } - - if (deps != null) - { - foreach(var dep in deps) - { - if (vRes[dep].Ex != null) - { - return; - } - } - } - - f.Key(fi.Name); - v.Serialize(f, c, field); - }; - } - - public Serializer() - { - var serializers = new Dictionary(); - GenericFieldView.CreateFieldProcessors( - CreateFieldSerializer, serializers); - - m_serializers = serializers; - } - - public void Serialize(JsonObjectValidator objectValidator, - IFormatter f, JsonSchemaValidationContext c, T o) - { - // Validates fields - var validationResults = new Dictionary(); - GenericValidator.ValidationResults( - objectValidator.Required, objectValidator.Properties, - c, o, validationResults); - - // Serialize fields - f.BeginMap(objectValidator.Properties.Count()); - foreach (var property in objectValidator.Properties) - { - var fieldName = property.Key; - var schema = property.Value; - - string[] deps = null; - objectValidator.Dependencies.TryGetValue(fieldName, out deps); - - FieldSerializer fs; - if (m_serializers.TryGetValue(fieldName, out fs)) - { - fs(schema, c, f, o, validationResults, deps); - } - } - f.EndMap(); - } - } - - static FieldInfo[] s_fields; - static Serializer s_serializer; - - public static void Serialize(JsonObjectValidator objectValidator, - IFormatter f, JsonSchemaValidationContext c, T value) - { - if (s_serializer == null) - { - s_serializer = new Serializer(); - } - - s_serializer.Serialize(objectValidator, f, c, value); - } - } - - public void Serialize(IFormatter f, JsonSchemaValidationContext c, T value) - { - GenericSerializer.Serialize(this, f, c, value); - } - - public static class GenericDeserializer - where S : IListTreeItem, IValue - { - delegate T Deserializer(ListTreeNode src); - - static Deserializer s_d; - - delegate void FieldSetter(ListTreeNode s, object o); - static FieldSetter GetFieldDeserializer(FieldInfo fi) - { - return (s, o) => - { - var u = default(U); - s.Deserialize(ref u); - fi.SetValue(o, u); - }; - } - - public static U DeserializeField(JsonSchema prop, ListTreeNode s) - { - var u = default(U); - prop.Validator.Deserialize(s, ref u); - return u; - } - - public static void Deserialize(ListTreeNode src, ref T dst, Dictionary props) - { - if (s_d == null) - { - var target = typeof(T); - - var fields = target.GetFields(BindingFlags.Instance | BindingFlags.Public); - var fieldDeserializers = fields.ToDictionary(x => Utf8String.From(x.Name), x => - { - /* - var mi = typeof(GenericDeserializer).GetMethod("GetFieldDeserializer", - BindingFlags.Static | BindingFlags.NonPublic); - var g = mi.MakeGenericMethod(x.FieldType); - return (FieldSetter)g.Invoke(null, new object[] { x }); - */ - JsonSchema prop; - if (!props.TryGetValue(x.Name, out prop)) - { - return null; - } - - var mi = typeof(GenericDeserializer).GetMethod("DeserializeField", - BindingFlags.Static | BindingFlags.Public); - var g = mi.MakeGenericMethod(x.FieldType); - - return (FieldSetter)((s, o) => - { - var f = g.Invoke(null, new object[] { prop, s }); - x.SetValue(o, f); - }); - }); - - s_d = (ListTreeNode s) => - { - if (!s.IsMap()) - { - throw new ArgumentException(s.Value.ValueType.ToString()); - } - - // boxing - var t = (object)Activator.CreateInstance(); - foreach (var kv in s.ObjectItems()) - { - FieldSetter setter; - if (fieldDeserializers.TryGetValue(kv.Key.GetUtf8String(), out setter)) - { - if (setter != null) - { - setter(kv.Value, t); - } - } - } - return (T)t; - }; - - } - dst = s_d(src); - } - } - - public void Deserialize(ListTreeNode src, ref U dst) - where T : IListTreeItem, IValue - { - GenericDeserializer.Deserialize(src, ref dst, Properties); - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonObjectValidator.cs.meta b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonObjectValidator.cs.meta deleted file mode 100644 index 669075111..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonObjectValidator.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1bdf39f36f58f584daee6d67f7ab446f -timeCreated: 1531812708 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidator.cs b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidator.cs deleted file mode 100644 index f085ff09f..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidator.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Linq; -using System.Collections.Generic; - - -namespace UniJSON -{ - [Flags] - public enum PropertyExportFlags - { - None, - PublicFields = 1, - PublicProperties = 2, - - Default = PublicFields | PublicProperties, - } - - public enum CompositionType - { - Unknown, - - AllOf, - AnyOf, - OneOf, - } - - - - - - - -} diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidator.cs.meta b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidator.cs.meta deleted file mode 100644 index 38043343d..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidator.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9ff35fccc1467f341b052622fedcb3ca -timeCreated: 1531557083 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidatorFactory.cs b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidatorFactory.cs deleted file mode 100644 index 82a70a3d4..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidatorFactory.cs +++ /dev/null @@ -1,320 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -#if UNIJSON_PROFILING -#else -using UnityEngine; -#endif - - -namespace UniJSON -{ - public static class JsonSchemaValidatorFactory - { - struct JsonSchemaItem - { - public string Key; - public JsonSchema Schema; - public bool Required; - public string[] Dependencies; - } - - static IEnumerable GetProperties(Type t, PropertyExportFlags exportFlags) - { - // fields - foreach (var fi in t.GetFields()) - { - var a = fi.GetCustomAttributes(typeof(JsonSchemaAttribute), true).FirstOrDefault() as JsonSchemaAttribute; - if (a == null) - { - a = fi.FieldType.GetCustomAttributes(typeof(JsonSchemaAttribute), true).FirstOrDefault() as JsonSchemaAttribute; - if (a == null) - { - // default - if (!fi.IsStatic && fi.IsPublic) - { - // only public instance field - a = new JsonSchemaAttribute(); - } - } - } - - // for array item - var ia = fi.GetCustomAttributes(typeof(ItemJsonSchemaAttribute), true).FirstOrDefault() as ItemJsonSchemaAttribute; - - if (a == null) - { - //int x = 0; - } - else - { - yield return new JsonSchemaItem - { - Key = fi.Name, - Schema = JsonSchema.FromType(fi.FieldType, a, ia), - Required = a.Required, - Dependencies = a.Dependencies, - }; - } - } - - // properties - foreach (var pi in t.GetProperties()) - { - var a = pi.GetCustomAttributes(typeof(JsonSchemaAttribute), true).FirstOrDefault() as JsonSchemaAttribute; - - // for array item - var ia = pi.GetCustomAttributes(typeof(ItemJsonSchemaAttribute), true).FirstOrDefault() as ItemJsonSchemaAttribute; - - if (a != null) - { - yield return new JsonSchemaItem - { - Key = pi.Name, - Schema = JsonSchema.FromType(pi.PropertyType, a, ia), - Required = a.Required, - Dependencies = a.Dependencies, - }; - } - } - } - - public static IJsonSchemaValidator Create(ValueNodeType valueType, - Type t = null, - BaseJsonSchemaAttribute a = null, - ItemJsonSchemaAttribute ia = null) - { - switch (valueType) - { - case ValueNodeType.Integer: - { - var v = new JsonIntValidator(); - if (a != null) - { - if (!double.IsNaN(a.Minimum)) - { - v.Minimum = (int)a.Minimum; - } - if (a.ExclusiveMinimum) - { - v.ExclusiveMinimum = a.ExclusiveMinimum; - } - if (!double.IsNaN(a.Maximum)) - { - v.Maximum = (int)a.Maximum; - } - if (a.ExclusiveMaximum) - { - v.ExclusiveMaximum = a.ExclusiveMaximum; - } - if (a.MultipleOf != 0) - { - v.MultipleOf = (int)a.MultipleOf; - } - } - return v; - } - - case ValueNodeType.Number: - { - var v = new JsonNumberValidator(); - if (a != null) - { - if (!double.IsNaN(a.Minimum)) - { - v.Minimum = (int)a.Minimum; - } - if (a.ExclusiveMinimum) - { - v.ExclusiveMinimum = a.ExclusiveMinimum; - } - if (!double.IsNaN(a.Maximum)) - { - v.Maximum = (int)a.Maximum; - } - if (a.ExclusiveMaximum) - { - v.ExclusiveMaximum = a.ExclusiveMaximum; - } - if (a.MultipleOf != 0) - { - v.MultipleOf = (int)a.MultipleOf; - } - } - return v; - } - - case ValueNodeType.String: - { - var v = new JsonStringValidator(); - if (a != null) - { - if (a.Pattern != null) - { - v.Pattern = new System.Text.RegularExpressions.Regex(a.Pattern); - } - } - return v; - } - - case ValueNodeType.Boolean: - return new JsonBoolValidator(); - - case ValueNodeType.Array: - { - var v = new JsonArrayValidator(); - if (a != null) - { - if (a.MinItems != 0) - { - v.MinItems = a.MinItems; - } - if (a.MaxItems != 0) - { - v.MaxItems = a.MaxItems; - } - - if (t != null) - { - if (ia == null) - { - ia = new ItemJsonSchemaAttribute(); - } - - Type elementType = null; - if (t.IsArray) - { - elementType = t.GetElementType(); - } - else if (t.GetIsGenericList()) - { - elementType = t.GetGenericArguments().First(); - } - - if (elementType != null) - { - /* - var sub = new JsonSchema - { - SkipComparison = ia.SkipSchemaComparison, - Validator = Create(elementType, ia, null) - }; - */ - var sub = JsonSchema.FromType(elementType, ia, null); - v.Items = sub; - } - } - } - return v; - } - - case ValueNodeType.Object: - { - if (t.GetIsGenericDictionary()) - { - var genericFactory = typeof(JsonDictionaryValidator).GetMethod("Create", BindingFlags.Static | BindingFlags.Public); - var factory = genericFactory.MakeGenericMethod(t.GetGenericArguments()[1]); - var v = factory.Invoke(null, null) as IJsonSchemaValidator; - return v; - } - else - { - var v = new JsonObjectValidator(); - if (a != null) - { - if (a.MinProperties > 0) - { - v.MinProperties = a.MinProperties; - } - - // props - foreach (var prop in GetProperties(t, a.ExportFlags)) - { - v.Properties.Add(prop.Key, prop.Schema); - if (prop.Required) - { - v.Required.Add(prop.Key); - } - if (prop.Dependencies != null) - { - v.Dependencies.Add(prop.Key, prop.Dependencies); - } - } - - } - - if (ia != null) - { - var sub = new JsonSchema - { - SkipComparison = ia.SkipSchemaComparison, - Validator = Create(typeof(object), ia, null) - }; - v.AdditionalProperties = sub; - } - - return v; - } - } - - default: - throw new NotImplementedException(); - } - } - - public static IJsonSchemaValidator Create(string t) - { - return Create((ValueNodeType)Enum.Parse(typeof(ValueNodeType), t, true)); - } - - static Dictionary s_typeMap = new Dictionary - { - {typeof(byte), ValueNodeType.Integer }, - {typeof(short), ValueNodeType.Integer }, - {typeof(int), ValueNodeType.Integer }, - {typeof(long), ValueNodeType.Integer }, - {typeof(sbyte), ValueNodeType.Integer }, - {typeof(ushort), ValueNodeType.Integer }, - {typeof(uint), ValueNodeType.Integer }, - {typeof(ulong), ValueNodeType.Integer }, - {typeof(float), ValueNodeType.Number }, - {typeof(double), ValueNodeType.Number }, - {typeof(string), ValueNodeType.String }, - {typeof(bool), ValueNodeType.Boolean }, - - // Unity types - {typeof(Vector3), ValueNodeType.Object }, - }; - - static ValueNodeType ToJsonType(Type t) - { - ValueNodeType jsonValueType; - if (s_typeMap.TryGetValue(t, out jsonValueType)) - { - return jsonValueType; - } - - if (t.IsArray) - { - return ValueNodeType.Array; - } - if (t.GetIsGenericList()) - { - return ValueNodeType.Array; - } - - //if (t.IsClass) - { - return ValueNodeType.Object; - } - - //throw new NotImplementedException(string.Format("No JsonType for {0}", t)); - } - - public static IJsonSchemaValidator Create(Type t, BaseJsonSchemaAttribute a, ItemJsonSchemaAttribute ia) - { - return Create(ToJsonType(t), t, a, ia); - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidatorFactory.cs.meta b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidatorFactory.cs.meta deleted file mode 100644 index e89965388..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonSchemaValidatorFactory.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9fef66d39a7b22b499bea68e0b22d000 -timeCreated: 1531574156 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonStringValidator.cs b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonStringValidator.cs deleted file mode 100644 index 189229756..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonStringValidator.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System; -using System.Linq; -using System.Text.RegularExpressions; - -namespace UniJSON -{ - /// - /// http://json-schema.org/latest/json-schema-validation.html#string - /// - public class JsonStringValidator : IJsonSchemaValidator - { - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.3.1 - /// - public int? MaxLength - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.3.2 - /// - public int? MinLength - { - get; set; - } - - /// - /// http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.3.3 - /// - public Regex Pattern - { - get; set; - } - - public override int GetHashCode() - { - return 4; - } - - public override bool Equals(object obj) - { - var rhs = obj as JsonStringValidator; - if (rhs == null) return false; - - if (MaxLength != rhs.MaxLength) return false; - if (MinLength != rhs.MinLength) return false; - - if (Pattern == null && rhs.Pattern == null) - { - } - else if (Pattern == null) - { - return false; - } - else if (rhs.Pattern == null) - { - return false; - } - else if (Pattern.ToString() != rhs.Pattern.ToString()) - { - return false; - } - - return true; - } - - public void Merge(IJsonSchemaValidator obj) - { - var rhs = obj as JsonStringValidator; - if (rhs == null) - { - throw new ArgumentException(); - } - - MaxLength = rhs.MaxLength; - MinLength = rhs.MinLength; - Pattern = rhs.Pattern; - } - - public bool FromJsonSchema(IFileSystemAccessor fs, string key, ListTreeNode value) - { - switch (key) - { - case "maxLength": - MaxLength = value.GetInt32(); - return true; - - case "minLength": - MinLength = value.GetInt32(); - return true; - - case "pattern": - Pattern = new Regex(value.GetString().Replace("\\\\", "\\")); - return true; - } - - return false; - } - - public void ToJsonSchema(IFormatter f) - { - f.Key("type"); f.Value("string"); - } - - public JsonSchemaValidationException Validate(JsonSchemaValidationContext c, T o) - { - if (o == null) - { - return new JsonSchemaValidationException(c, "null"); - } - - var value = o as string; - - if (MinLength.HasValue && value.Length < MinLength) - { - return new JsonSchemaValidationException(c, string.Format("minlength: {0}<{1}", value.Length, MinLength.Value)); - } - if (MaxLength.HasValue && value.Length > MaxLength) - { - return new JsonSchemaValidationException(c, string.Format("maxlength: {0}>{1}", value.Length, MaxLength.Value)); - } - - if (Pattern != null && !Pattern.IsMatch(value)) - { - return new JsonSchemaValidationException(c, string.Format("pattern: {0} not match {1}", Pattern, value)); - } - - return null; - } - - public void Serialize(IFormatter f, JsonSchemaValidationContext c, T o) - { - f.Value(GenericCast.Cast(o)); - } - - public void Deserialize(ListTreeNode src, ref U dst) - where T: IListTreeItem, IValue - { - dst = GenericCast.Cast(src.GetString()); - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonStringValidator.cs.meta b/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonStringValidator.cs.meta deleted file mode 100644 index 07f08dad4..000000000 --- a/Assets/VRM/UniJSON/Scripts/JsonSchemaValidator/JsonStringValidator.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 0256cc9f46a4e6744826cf5ca0aa1b46 -timeCreated: 1531812574 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode.meta b/Assets/VRM/UniJSON/Scripts/ListTreeNode.meta deleted file mode 100644 index 5127bf90c..000000000 --- a/Assets/VRM/UniJSON/Scripts/ListTreeNode.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: fa0987f7b38d9eb4b93a22c465570153 -folderAsset: yes -timeCreated: 1545735556 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeDeserializerExtensions.cs b/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeDeserializerExtensions.cs deleted file mode 100644 index e07560648..000000000 --- a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeDeserializerExtensions.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - - -namespace UniJSON -{ - public static class ListTreeNodeDeserializerExtensions - { - public static void Deserialize(this ListTreeNode self, ref U value) - where T : IListTreeItem, IValue - { - GenericDeserializer.Deserialize(self, ref value); - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeDeserializerExtensions.cs.meta b/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeDeserializerExtensions.cs.meta deleted file mode 100644 index e7edfeb77..000000000 --- a/Assets/VRM/UniJSON/Scripts/ListTreeNode/ListTreeNodeDeserializerExtensions.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 961c1bf9650027347a1279c4f04a1feb -timeCreated: 1545735557 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/MsgPack.meta b/Assets/VRM/UniJSON/Scripts/MsgPack.meta deleted file mode 100644 index d1df7e374..000000000 --- a/Assets/VRM/UniJSON/Scripts/MsgPack.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: c2497653b22017547b01e854b0fa540d -folderAsset: yes -timeCreated: 1540812361 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Rpc.meta b/Assets/VRM/UniJSON/Scripts/Rpc.meta deleted file mode 100644 index b31ccf87a..000000000 --- a/Assets/VRM/UniJSON/Scripts/Rpc.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: e9f4765570f7add459493027e7057429 -folderAsset: yes -timeCreated: 1543734557 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Rpc/IRpc.cs b/Assets/VRM/UniJSON/Scripts/Rpc/IRpc.cs deleted file mode 100644 index ee35dab1f..000000000 --- a/Assets/VRM/UniJSON/Scripts/Rpc/IRpc.cs +++ /dev/null @@ -1,84 +0,0 @@ -namespace UniJSON -{ - public interface IRpc - { - void Request(Utf8String method); - void Request(Utf8String method, A0 a0); - void Request(Utf8String method, A0 a0, A1 a1); - void Request(Utf8String method, A0 a0, A1 a1, A2 a2); - void Request(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3); - void Request(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4); - void Request(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5); - void ResponseSuccess(int id); - void ResponseSuccess(int id, T result); - void ResponseError(int id, System.Exception error); - void Notify(Utf8String method); - void Notify(Utf8String method, A0 a0); - void Notify(Utf8String method, A0 a0, A1 a1); - void Notify(Utf8String method, A0 a0, A1 a1, A2 a2); - void Notify(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3); - void Notify(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4); - void Notify(Utf8String method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5); - } - - public static class RpcExtensions - { - public static void Request(this IRpc rpc, string method) - { - rpc.Request(Utf8String.From(method)); - } - public static void Request(this IRpc rpc, string method, A0 a0) - { - rpc.Request(Utf8String.From(method), a0); - } - public static void Request(this IRpc rpc, string method, A0 a0, A1 a1) - { - rpc.Request(Utf8String.From(method), a0, a1); - } - public static void Request(this IRpc rpc, string method, A0 a0, A1 a1, A2 a2) - { - rpc.Request(Utf8String.From(method), a0, a1, a2); - } - public static void Request(this IRpc rpc, string method, A0 a0, A1 a1, A2 a2, A3 a3) - { - rpc.Request(Utf8String.From(method), a0, a1, a2, a3); - } - public static void Request(this IRpc rpc, string method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) - { - rpc.Request(Utf8String.From(method), a0, a1, a2, a3, a4); - } - public static void Request(this IRpc rpc, string method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) - { - rpc.Request(Utf8String.From(method), a0, a1, a2, a3, a4, a5); - } - - public static void Notify(this IRpc rpc, string method) - { - rpc.Notify(Utf8String.From(method)); - } - public static void Notify(this IRpc rpc, string method, A0 a0) - { - rpc.Notify(Utf8String.From(method), a0); - } - public static void Notify(this IRpc rpc, string method, A0 a0, A1 a1) - { - rpc.Notify(Utf8String.From(method), a0, a1); - } - public static void Notify(this IRpc rpc, string method, A0 a0, A1 a1, A2 a2) - { - rpc.Notify(Utf8String.From(method), a0, a1, a2); - } - public static void Notify(this IRpc rpc, string method, A0 a0, A1 a1, A2 a2, A3 a3) - { - rpc.Notify(Utf8String.From(method), a0, a1, a2, a3); - } - public static void Notify(this IRpc rpc, string method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) - { - rpc.Notify(Utf8String.From(method), a0, a1, a2, a3, a4); - } - public static void Notify(this IRpc rpc, string method, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) - { - rpc.Notify(Utf8String.From(method), a0, a1, a2, a3, a4, a5); - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/Rpc/IRpc.cs.meta b/Assets/VRM/UniJSON/Scripts/Rpc/IRpc.cs.meta deleted file mode 100644 index dd1d74b33..000000000 --- a/Assets/VRM/UniJSON/Scripts/Rpc/IRpc.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 565cc7f9a76689a45b352370db24f90f -timeCreated: 1543734576 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Rpc/RpcDispatcher.cs b/Assets/VRM/UniJSON/Scripts/Rpc/RpcDispatcher.cs deleted file mode 100644 index bdf9a3927..000000000 --- a/Assets/VRM/UniJSON/Scripts/Rpc/RpcDispatcher.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections.Generic; - - -namespace UniJSON -{ - public class RpcDispatcher - where T : IListTreeItem, IValue - { - delegate void Callback(int id, ListTreeNode args, IRpc f); - Dictionary m_map = new Dictionary(); - - #region Action - public void Register(string method, Action action) - { - m_map.Add(method, (id, args, f) => - { - var it = args.ArrayItems().GetEnumerator(); - - var a0 = default(A0); - it.MoveNext(); - it.Current.Deserialize(ref a0); - - try - { - action(a0); - f.ResponseSuccess(id); - } - catch(Exception ex) - { - f.ResponseError(id, ex); - } - }); - } - - public void Register(string method, Action action) - { - throw new NotImplementedException(); - } - #endregion - - #region Func - public void Register(string method, Func action) - { - m_map.Add(method, (id, args, f) => - { - var it = args.ArrayItems().GetEnumerator(); - - var a0 = default(A0); - it.MoveNext(); - it.Current.Deserialize(ref a0); - - var a1 = default(A1); - it.MoveNext(); - it.Current.Deserialize(ref a1); - - try - { - var r = action(a0, a1); - f.ResponseSuccess(id, r); - } - catch(Exception ex) - { - f.ResponseError(id, ex); - } - }); - } - #endregion - - public void Call(IRpc f, int id, string method, ListTreeNode args) - { - Callback callback; - if (!m_map.TryGetValue(method, out callback)) - { - throw new KeyNotFoundException(); - } - callback(id, args, f); - } - } -} diff --git a/Assets/VRM/UniJSON/Scripts/Rpc/RpcDispatcher.cs.meta b/Assets/VRM/UniJSON/Scripts/Rpc/RpcDispatcher.cs.meta deleted file mode 100644 index 912d71720..000000000 --- a/Assets/VRM/UniJSON/Scripts/Rpc/RpcDispatcher.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 648f9a3ef9c1a6f41b11198b1f499d5c -timeCreated: 1543549119 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/Scripts/Toml.meta b/Assets/VRM/UniJSON/Scripts/Toml.meta deleted file mode 100644 index a58d5b658..000000000 --- a/Assets/VRM/UniJSON/Scripts/Toml.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: ebc8d8c2347b31d4a8023a91b95f618e -folderAsset: yes -timeCreated: 1545735556 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniJSON/UniJSON.asmdef b/Assets/VRM/UniJSON/UniJSON.asmdef deleted file mode 100644 index 54ea498ab..000000000 --- a/Assets/VRM/UniJSON/UniJSON.asmdef +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "UniJSON" -} diff --git a/Assets/VRM/UniJSON/UniJSON.asmdef.meta b/Assets/VRM/UniJSON/UniJSON.asmdef.meta deleted file mode 100644 index 9e8f01352..000000000 --- a/Assets/VRM/UniJSON/UniJSON.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 5dad3aa3e33a0ea48b088de553c50bf7 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniVRM.meta b/Assets/VRM/UniVRM.meta deleted file mode 100644 index 6c8ff4b44..000000000 --- a/Assets/VRM/UniVRM.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: cd93bd4f117e1e54db244c5cadbef691 -folderAsset: yes -timeCreated: 1546003999 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniVRM/DevOnly.meta b/Assets/VRM/UniVRM/DevOnly.meta deleted file mode 100644 index 75edaab55..000000000 --- a/Assets/VRM/UniVRM/DevOnly.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: b9f74db0c0238f74db36a528e42f53f6 -folderAsset: yes -timeCreated: 1546832162 -licenseType: Pro -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniVRM/DevOnly/Editor/UniVRM.DevOnly.Editor.asmdef b/Assets/VRM/UniVRM/DevOnly/Editor/UniVRM.DevOnly.Editor.asmdef deleted file mode 100644 index bf0c128c8..000000000 --- a/Assets/VRM/UniVRM/DevOnly/Editor/UniVRM.DevOnly.Editor.asmdef +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "UniVRM.DevOnly.Editor", - "references": [ - "VRM" - ], - "optionalUnityReferences": [], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false -} \ No newline at end of file diff --git a/Assets/VRM/UniVRM/DevOnly/Editor/UniVRM.DevOnly.Editor.asmdef.meta b/Assets/VRM/UniVRM/DevOnly/Editor/UniVRM.DevOnly.Editor.asmdef.meta deleted file mode 100644 index 198f6c8c4..000000000 --- a/Assets/VRM/UniVRM/DevOnly/Editor/UniVRM.DevOnly.Editor.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9fb72ff565df8da48b61531daac6a726 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Editor.meta b/Assets/VRM/UniVRM/Editor.meta deleted file mode 100644 index 3b4c9994b..000000000 --- a/Assets/VRM/UniVRM/Editor.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 41cb69128d62a4e4a9ffde396b606553 -folderAsset: yes -timeCreated: 1521102890 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Editor/Format/VRMVersionMenu.cs b/Assets/VRM/UniVRM/Editor/Format/VRMVersionMenu.cs deleted file mode 100644 index a2d05726e..000000000 --- a/Assets/VRM/UniVRM/Editor/Format/VRMVersionMenu.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System.IO; -using System.Text; -using UnityEditor; -using UnityEngine; - -namespace VRM -{ - public class VRMVersionMenu : EditorWindow - { - const string VersionPath = "Assets/VRM/UniVRM/Scripts/Format/VRMVersion.cs"; - const string VersionTemplate = @" -namespace VRM -{{ - public static partial class VRMVersion - {{ - public const int MAJOR = {0}; - public const int MINOR = {1}; - public const int PATCH = {2}; - public const string VERSION = ""{0}.{1}.{2}""; - }} -}} -"; - - const string VRMShadersPackagePath = "Assets/VRMShaders/package.json"; - const string VRMShadersPackageTemplate = @"{{ - ""name"": ""com.vrmc.vrmshaders"", - ""version"": ""{0}.{1}.{2}"", - ""displayName"": ""VRM Shaders"", - ""description"": ""VRM Shaders"", - ""unity"": ""2018.4"", - ""keywords"": [ - ""vrm"", - ""shader"" - ], - ""author"": {{ - ""name"": ""VRM Consortium"" - }} -}} -"; - - const string MeshUtilityPath = "Assets/MeshUtility/package.json"; - const string MeshUtilityTemplate = @"{{ - ""name"": ""com.vrmc.meshutility"", - ""version"": ""{0}.{1}.{2}"", - ""displayName"": ""MeshUtility"", - ""unity"": ""2018.4"", - ""description"": ""MeshUtility is a package for mesh separation, etc. \n\nCheck out the latest information here: "", - ""keywords"": [ - ""mesh"" - ], - ""author"": {{ - ""name"": ""VRM Consortium"" - }} -}} -"; - - const string VRMPackagePath = "Assets/VRM/package.json"; - const string VRMPackageTemplate = @"{{ - ""name"": ""com.vrmc.univrm"", - ""version"": ""{0}.{1}.{2}"", - ""displayName"": ""VRM"", - ""description"": ""VRM importer"", - ""unity"": ""2018.4"", - ""keywords"": [ - ""vrm"", - ""importer"", - ""avatar"", - ""vr"" - ], - ""author"": {{ - ""name"": ""VRM Consortium"" - }}, - ""dependencies"": {{ - ""com.vrmc.vrmshaders"": ""{0}.{1}.{2}"", - ""com.vrmc.meshutility"": ""{0}.{1}.{2}"" - }} -}} -"; - - [SerializeField] - string m_version; - - void OnGUI() - { - GUILayout.Label($"Current version: {VRMVersion.VERSION}"); - - m_version = EditorGUILayout.TextField("Major.Minor.Patch", m_version); - - if (GUILayout.Button("Apply")) - { - if (string.IsNullOrEmpty(m_version)) - { - return; - } - var splitted = m_version.Split('.'); - if (splitted.Length != 3) - { - Debug.LogWarning($"InvalidFormat: {m_version}"); - return; - } - var values = new int[3]; - for (int i = 0; i < 3; ++i) - { - values[i] = int.Parse(splitted[i]); - } - - // generate - var utf8 = new UTF8Encoding(false); - File.WriteAllText(VersionPath, string.Format(VersionTemplate, - values[0], - values[1], - values[2]), utf8); - File.WriteAllText(VRMShadersPackagePath, string.Format(VRMShadersPackageTemplate, - values[0], - values[1], - values[2]), utf8); - File.WriteAllText(MeshUtilityPath, string.Format(MeshUtilityTemplate, - values[0], - values[1], - values[2]), utf8); - File.WriteAllText(VRMPackagePath, string.Format(VRMPackageTemplate, - values[0], - values[1], - values[2]), utf8); - AssetDatabase.Refresh(); - } - - if (GUILayout.Button("Close")) - { - Close(); - } - } - -#if VRM_DEVELOP - [MenuItem(VRMVersion.MENU + "/VersionDialog")] -#endif - static void ShowVersionDialog() - { - var window = ScriptableObject.CreateInstance(); - window.m_version = VRMVersion.VERSION; - window.ShowUtility(); - } - } -} diff --git a/Assets/VRM/UniVRM/Editor/Tests.meta b/Assets/VRM/UniVRM/Editor/Tests.meta deleted file mode 100644 index 9acbf73c3..000000000 --- a/Assets/VRM/UniVRM/Editor/Tests.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 0903c33afe5ef6346ad9526e78055293 -folderAsset: yes -timeCreated: 1521799604 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Editor/Tests/UniVRM.Editor.Tests.asmdef.meta b/Assets/VRM/UniVRM/Editor/Tests/UniVRM.Editor.Tests.asmdef.meta deleted file mode 100644 index 704a813ba..000000000 --- a/Assets/VRM/UniVRM/Editor/Tests/UniVRM.Editor.Tests.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: ea02711c84d022f46bcbae5d1cd38c16 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs b/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs deleted file mode 100644 index 8b1caac2e..000000000 --- a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs +++ /dev/null @@ -1,687 +0,0 @@ -using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using UniJSON; -using UnityEngine; - -namespace VRM -{ - public class UniVRMSerializeTests - { - [Test] - public void MaterialValueBindTest() - { - var model = new glTF_VRM_MaterialValueBind(); - - var json = model.ToJson(); - Assert.AreEqual(@"{}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(json, json2); - } - - [Test] - public void BlendShapeBindTest() - { - var model = new glTF_VRM_BlendShapeBind() - { - mesh = 1, - weight = 2, - index = 3, - }; - - var json = model.ToJson(); - Assert.AreEqual(@"{""mesh"":1,""index"":3,""weight"":2}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(json, json2); - } - - [Test] - public void BlendShapeBindTestError() - { - var model = new glTF_VRM_BlendShapeBind(); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[mesh.String] minimum: ! -1>=0", ex.Message); - } - - [Test] - public void BlendShapeGroupTest() - { - var model = new glTF_VRM_BlendShapeGroup() - { - presetName = "neutral", - }; - - var json = model.ToJson(); - Assert.AreEqual(@"{""presetName"":""neutral"",""isBinary"":false,""binds"":[],""materialValues"":[]}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(@"{""presetName"":""neutral"",""binds"":[],""materialValues"":[],""isBinary"":false}", json2); - } - - [Test] - public void BlendShapeGroupTestError() - { - var model = new glTF_VRM_BlendShapeGroup() - { - presetName = "aaaaaaaaaaaa_not_exists_", - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[presetName.String] aaaaaaaaaaaa_not_exists_ is not valid enum", ex.Message); - } - - [Test] - public void DegreeMapTest() - { - var model = new glTF_VRM_DegreeMap(); - - var json = model.ToJson(); - Assert.AreEqual(@"{""xRange"":90,""yRange"":10}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(json, json2); - } - - [Test] - public void MeshAnnotationTest() - { - var model = new glTF_VRM_MeshAnnotation(); - - var json = model.ToJson(); - Assert.AreEqual(@"{""mesh"":0}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual(json, json2); - } - - [Test] - public void FirstPersonTest() - { - var model = new glTF_VRM_Firstperson(); - - var json = model.ToJson(); - Assert.AreEqual( - @"{""firstPersonBone"":-1,""firstPersonBoneOffset"":{""x"":0,""y"":0,""z"":0},""meshAnnotations"":[],""lookAtTypeName"":""Bone"",""lookAtHorizontalInner"":{""xRange"":90,""yRange"":10},""lookAtHorizontalOuter"":{""xRange"":90,""yRange"":10},""lookAtVerticalDown"":{""xRange"":90,""yRange"":10},""lookAtVerticalUp"":{""xRange"":90,""yRange"":10}}", - json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - Assert.AreEqual( - @"{""firstPersonBoneOffset"":{""x"":0,""y"":0,""z"":0},""meshAnnotations"":[],""lookAtTypeName"":""Bone"",""lookAtHorizontalInner"":{""xRange"":90,""yRange"":10},""lookAtHorizontalOuter"":{""xRange"":90,""yRange"":10},""lookAtVerticalDown"":{""xRange"":90,""yRange"":10},""lookAtVerticalUp"":{""xRange"":90,""yRange"":10}}", - json2); - } - - [Test] - public void HumanoidBoneTest() - { - var model = new glTF_VRM_HumanoidBone() - { - bone = "hips", // NOTE: This field must not be null? - node = 0, - }; - - var json = model.ToJson(); - Assert.AreEqual(@"{""bone"":""hips"",""node"":0,""useDefaultValues"":true}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual( - @"{""bone"":""hips"",""node"":0,""useDefaultValues"":true,""min"":{""x"":0,""y"":0,""z"":0},""max"":{""x"":0,""y"":0,""z"":0},""center"":{""x"":0,""y"":0,""z"":0},""axisLength"":0}", - json2); - } - - [Test] - public void HumanoidBoneTestError() - { - var model = new glTF_VRM_HumanoidBone() - { - bone = "hips", // NOTE: This field must not be null? - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[node.String] minimum: ! -1>=0", ex.Message); - } - - [Test] - public void HumanoidTest() - { - var model = new glTF_VRM_Humanoid(); - - var json = model.ToJson(); - Assert.AreEqual(@"{""humanBones"":[],""armStretch"":0.05,""legStretch"":0.05,""upperArmTwist"":0.5,""lowerArmTwist"":0.5,""upperLegTwist"":0.5,""lowerLegTwist"":0.5,""feetSpacing"":0,""hasTranslationDoF"":false}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(json, json2); - } - - [Test] - public void MaterialTest() - { - var model = new glTF_VRM_Material - { - floatProperties = new Dictionary - { - {"float", 1.0f} - }, - vectorProperties = new Dictionary - { - {"vector", new float[]{0, 1, 2, 3 }} - }, - textureProperties = new Dictionary - { - {"texture", 0} - }, - keywordMap = new Dictionary - { - {"keyword", true} - }, - tagMap = new Dictionary - { - {"tag", "map"} - }, - }; - - var json = model.ToJson(); - Assert.AreEqual(@"{""renderQueue"":-1,""floatProperties"":{""float"":1},""vectorProperties"":{""vector"":[0,1,2,3]},""textureProperties"":{""texture"":0},""keywordMap"":{""keyword"":true},""tagMap"":{""tag"":""map""}}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(json, json2); - - // deserialize - var deserialized = default(glTF_VRM_Material); - json.ParseAsJson().Deserialize(ref deserialized); - Assert.AreEqual(1, deserialized.floatProperties.Count); - } - - [Test] - public void MetaTest() - { - var model = new glTF_VRM_Meta() - { - allowedUserName = "OnlyAuthor", - violentUssageName = "Disallow", - sexualUssageName = "Disallow", - commercialUssageName = "Disallow", - licenseName = "CC0", - }; - - var json = model.ToJson(); - Assert.AreEqual(@"{""texture"":-1,""allowedUserName"":""OnlyAuthor"",""violentUssageName"":""Disallow"",""sexualUssageName"":""Disallow"",""commercialUssageName"":""Disallow"",""licenseName"":""CC0""}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(@"{""allowedUserName"":""OnlyAuthor"",""violentUssageName"":""Disallow"",""sexualUssageName"":""Disallow"",""commercialUssageName"":""Disallow"",""licenseName"":""CC0""}", json2); - } - - [Test] - public void MetaTestError() - { - { - var model = new glTF_VRM_Meta() - { - allowedUserName = null, - violentUssageName = null, - sexualUssageName = null, - commercialUssageName = null, - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[allowedUserName.String] null", ex.Message); - } - - { - var model = new glTF_VRM_Meta() - { - allowedUserName = "OnlyAuthor", - violentUssageName = "Disallow", - sexualUssageName = "Disallow", - commercialUssageName = "Disallow", - //licenseName = "CC0", - licenseName = null, - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[licenseName.String] null", ex.Message); - } - - { - var model = new glTF_VRM_Meta() - { - allowedUserName = "OnlyAuthor", - violentUssageName = "Disallow", - sexualUssageName = "Disallow", - commercialUssageName = "Disallow", - licenseName = "_INVALID_SOME_THING_", - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[licenseName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message); - } - - { - var model = new glTF_VRM_Meta() - { - // allowedUserName = "OnlyAuthor", - allowedUserName = null, - violentUssageName = "Disallow", - sexualUssageName = "Disallow", - commercialUssageName = "Disallow", - licenseName = "CC0", - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[allowedUserName.String] null", ex.Message); - } - - { - var model = new glTF_VRM_Meta() - { - allowedUserName = "_INVALID_SOME_THING_", - violentUssageName = "Disallow", - sexualUssageName = "Disallow", - commercialUssageName = "Disallow", - licenseName = "CC0", - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[allowedUserName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message); - } - - { - var model = new glTF_VRM_Meta() - { - allowedUserName = "OnlyAuthor", - //violentUssageName = "Disallow", - violentUssageName = null, - sexualUssageName = "Disallow", - commercialUssageName = "Disallow", - licenseName = "CC0", - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[violentUssageName.String] null", ex.Message); - } - - { - var model = new glTF_VRM_Meta() - { - allowedUserName = "OnlyAuthor", - violentUssageName = "_INVALID_SOME_THING_", - sexualUssageName = "Disallow", - commercialUssageName = "Disallow", - licenseName = "CC0", - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[violentUssageName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message); - } - - { - var model = new glTF_VRM_Meta() - { - allowedUserName = "OnlyAuthor", - violentUssageName = "Disallow", - //sexualUssageName = "Disallow", - sexualUssageName = null, - commercialUssageName = "Disallow", - licenseName = "CC0", - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[sexualUssageName.String] null", ex.Message); - } - - { - var model = new glTF_VRM_Meta() - { - allowedUserName = "OnlyAuthor", - violentUssageName = "Disallow", - sexualUssageName = "_INVALID_SOME_THING_", - commercialUssageName = "Disallow", - licenseName = "CC0", - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[sexualUssageName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message); - } - - { - var model = new glTF_VRM_Meta() - { - allowedUserName = "OnlyAuthor", - violentUssageName = "Disallow", - sexualUssageName = "Disallow", - //commercialUssageName = "Disallow", - commercialUssageName = null, - licenseName = "CC0", - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[commercialUssageName.String] null", ex.Message); - } - - { - var model = new glTF_VRM_Meta() - { - allowedUserName = "OnlyAuthor", - violentUssageName = "Disallow", - sexualUssageName = "Disallow", - commercialUssageName = "_INVALID_SOME_THING_", - licenseName = "CC0", - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[commercialUssageName.String] _INVALID_SOME_THING_ is not valid enum", ex.Message); - } - } - - // TODO: Move to another suitable location - [Test] - public void MetaDeserializeTest() - { - var json = @"{}"; - - var model = deserialize(json); - - Assert.AreEqual(-1, model.texture); - } - - [Test] - public void SecondaryAnimationColliderTest() - { - var model = new glTF_VRM_SecondaryAnimationCollider() - { - offset = new Vector3(1, 2, 3), - radius = 42, - }; - - var json = model.ToJson(); - Assert.AreEqual(@"{""offset"":{""x"":1,""y"":2,""z"":3},""radius"":42}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(json, json2); - } - - [Test] - public void SecondaryAnimationColliderGroupTest() - { - var model = new glTF_VRM_SecondaryAnimationColliderGroup(); - - var json = model.ToJson(); - Assert.AreEqual(@"{""node"":0,""colliders"":[]}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(json, json2); - } - - [Test] - public void SecondaryAnimationColliderGroupTestError() - { - var model = new glTF_VRM_SecondaryAnimationColliderGroup() - { - node = -1, - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[node.String] minimum: ! -1>=0", ex.Message); - } - - [Test] - public void SecondaryAnimationGroupTest() - { - var model = new glTF_VRM_SecondaryAnimationGroup(); - - var json = model.ToJson(); - Assert.AreEqual(@"{""stiffiness"":0,""gravityPower"":0,""gravityDir"":{""x"":0,""y"":0,""z"":0},""dragForce"":0,""center"":0,""hitRadius"":0,""bones"":[],""colliderGroups"":[]}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(json, json2); - } - - [Test] - public void SecondaryAnimationGroupTestErrorBones() - { - var model = new glTF_VRM_SecondaryAnimationGroup() - { - bones = new int[] { -1 } - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[bones.String] minimum: ! -1>=0", ex.Message); - } - - [Test] - public void SecondaryAnimationGroupTestErrorColliderGroups() - { - var model = new glTF_VRM_SecondaryAnimationGroup() - { - colliderGroups = new int[] { -1 } - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var ex = Assert.Throws( - () => JsonSchema.FromType().Serialize(model, c) - ); - Assert.AreEqual("[colliderGroups.String] minimum: ! -1>=0", ex.Message); - } - - [Test] - public void SecondaryAnimationTest() - { - var model = new glTF_VRM_SecondaryAnimation(); - - var json = model.ToJson(); - Assert.AreEqual(@"{""boneGroups"":[],""colliderGroups"":[]}", json); - Debug.Log(json); - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - // NOTE: New serializer outputs values which will not be used... - Assert.AreEqual(json, json2); - } - - [Test] - public void ExtensionsTest() - { - var model = new glTF_VRM_extensions() - { - meta = null, - humanoid = null, - firstPerson = null, - blendShapeMaster = null, - secondaryAnimation = null, - materialProperties = null, - }; - - var c = new JsonSchemaValidationContext("") - { - EnableDiagnosisForNotRequiredFields = true, - }; - var json2 = JsonSchema.FromType().Serialize(model, c); - var expected = - String.Format(@"{{""exporterVersion"":""{0}"",""specVersion"":""0.0""}}", VRMVersion.VRM_VERSION); - Assert.AreEqual(expected, json2); - } - - // TODO: Move to another suitable location - T deserialize(string json) - { - return JsonUtility.FromJson(json); - } - } -} diff --git a/Assets/VRM/UniVRM/Scripts.meta b/Assets/VRM/UniVRM/Scripts.meta deleted file mode 100644 index 96afb8fa6..000000000 --- a/Assets/VRM/UniVRM/Scripts.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 2f85d3d3cb76658408fd936e3b798481 -folderAsset: yes -timeCreated: 1517228412 -licenseType: Free -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Scripts/AOTCall.g.cs b/Assets/VRM/UniVRM/Scripts/AOTCall.g.cs deleted file mode 100644 index c111002f2..000000000 --- a/Assets/VRM/UniVRM/Scripts/AOTCall.g.cs +++ /dev/null @@ -1,1953 +0,0 @@ - -using System; -using UniJSON; -using UniGLTF; -using System.Collections.Generic; - - -namespace VRM { - public static partial class VRMAOTCall { - static void glTF() - { - { - var f = new JsonFormatter(); - - -// String -f.Serialize(default(System.String)); -{ -var value = default(System.String); -default(ListTreeNode).Deserialize(ref value); -} - -// Boolean -f.Serialize(default(System.Boolean)); -{ -var value = default(System.Boolean); -default(ListTreeNode).Deserialize(ref value); -} - -// Byte -f.Serialize(default(System.Byte)); -{ -var value = default(System.Byte); -default(ListTreeNode).Deserialize(ref value); -} - -// UInt16 -f.Serialize(default(System.UInt16)); -{ -var value = default(System.UInt16); -default(ListTreeNode).Deserialize(ref value); -} - -// UInt32 -f.Serialize(default(System.UInt32)); -{ -var value = default(System.UInt32); -default(ListTreeNode).Deserialize(ref value); -} - -// UInt64 -f.Serialize(default(System.UInt64)); -{ -var value = default(System.UInt64); -default(ListTreeNode).Deserialize(ref value); -} - -// SByte -f.Serialize(default(System.SByte)); -{ -var value = default(System.SByte); -default(ListTreeNode).Deserialize(ref value); -} - -// Int16 -f.Serialize(default(System.Int16)); -{ -var value = default(System.Int16); -default(ListTreeNode).Deserialize(ref value); -} - -// Int32 -f.Serialize(default(System.Int32)); -{ -var value = default(System.Int32); -default(ListTreeNode).Deserialize(ref value); -} - -// Int64 -f.Serialize(default(System.Int64)); -{ -var value = default(System.Int64); -default(ListTreeNode).Deserialize(ref value); -} - -// Single -f.Serialize(default(System.Single)); -{ -var value = default(System.Single); -default(ListTreeNode).Deserialize(ref value); -} - -// Double -f.Serialize(default(System.Double)); -{ -var value = default(System.Double); -default(ListTreeNode).Deserialize(ref value); -} - -// Vector2 -f.Serialize(default(UnityEngine.Vector2)); -{ -var value = default(UnityEngine.Vector2); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// Vector3 -f.Serialize(default(UnityEngine.Vector3)); -{ -var value = default(UnityEngine.Vector3); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// Vector4 -f.Serialize(default(UnityEngine.Vector4)); -{ -var value = default(UnityEngine.Vector4); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// Quaternion -f.Serialize(default(UnityEngine.Quaternion)); -{ -var value = default(UnityEngine.Quaternion); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTF -f.Serialize(default(UniGLTF.glTF)); -{ -var value = default(UniGLTF.glTF); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFAssets -f.Serialize(default(UniGLTF.glTFAssets)); -{ -var value = default(UniGLTF.glTFAssets); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFBuffer -f.Serialize(default(UniGLTF.glTFBuffer)); -{ -var value = default(UniGLTF.glTFBuffer); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFBufferView -f.Serialize(default(UniGLTF.glTFBufferView)); -{ -var value = default(UniGLTF.glTFBufferView); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glBufferTarget -f.Serialize(default(UniGLTF.glBufferTarget)); -{ -var value = default(UniGLTF.glBufferTarget); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFAccessor -f.Serialize(default(UniGLTF.glTFAccessor)); -{ -var value = default(UniGLTF.glTFAccessor); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glComponentType -f.Serialize(default(UniGLTF.glComponentType)); -{ -var value = default(UniGLTF.glComponentType); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// Single[] -f.Serialize(default(Single[])); -{ -var value = default(Single[]); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer.GenericArrayDeserializer(default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFSparse -f.Serialize(default(UniGLTF.glTFSparse)); -{ -var value = default(UniGLTF.glTFSparse); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFSparseIndices -f.Serialize(default(UniGLTF.glTFSparseIndices)); -{ -var value = default(UniGLTF.glTFSparseIndices); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFSparseValues -f.Serialize(default(UniGLTF.glTFSparseValues)); -{ -var value = default(UniGLTF.glTFSparseValues); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFTexture -f.Serialize(default(UniGLTF.glTFTexture)); -{ -var value = default(UniGLTF.glTFTexture); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFTextureSampler -f.Serialize(default(UniGLTF.glTFTextureSampler)); -{ -var value = default(UniGLTF.glTFTextureSampler); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glFilter -f.Serialize(default(UniGLTF.glFilter)); -{ -var value = default(UniGLTF.glFilter); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glWrap -f.Serialize(default(UniGLTF.glWrap)); -{ -var value = default(UniGLTF.glWrap); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFImage -f.Serialize(default(UniGLTF.glTFImage)); -{ -var value = default(UniGLTF.glTFImage); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFMaterial -f.Serialize(default(UniGLTF.glTFMaterial)); -{ -var value = default(UniGLTF.glTFMaterial); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFPbrMetallicRoughness -f.Serialize(default(UniGLTF.glTFPbrMetallicRoughness)); -{ -var value = default(UniGLTF.glTFPbrMetallicRoughness); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFMaterialBaseColorTextureInfo -f.Serialize(default(UniGLTF.glTFMaterialBaseColorTextureInfo)); -{ -var value = default(UniGLTF.glTFMaterialBaseColorTextureInfo); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFMaterialMetallicRoughnessTextureInfo -f.Serialize(default(UniGLTF.glTFMaterialMetallicRoughnessTextureInfo)); -{ -var value = default(UniGLTF.glTFMaterialMetallicRoughnessTextureInfo); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFMaterialNormalTextureInfo -f.Serialize(default(UniGLTF.glTFMaterialNormalTextureInfo)); -{ -var value = default(UniGLTF.glTFMaterialNormalTextureInfo); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFMaterialOcclusionTextureInfo -f.Serialize(default(UniGLTF.glTFMaterialOcclusionTextureInfo)); -{ -var value = default(UniGLTF.glTFMaterialOcclusionTextureInfo); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFMaterialEmissiveTextureInfo -f.Serialize(default(UniGLTF.glTFMaterialEmissiveTextureInfo)); -{ -var value = default(UniGLTF.glTFMaterialEmissiveTextureInfo); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFMaterial_extensions -f.Serialize(default(UniGLTF.glTFMaterial_extensions)); -{ -var value = default(UniGLTF.glTFMaterial_extensions); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTF_KHR_materials_unlit -f.Serialize(default(UniGLTF.glTF_KHR_materials_unlit)); -{ -var value = default(UniGLTF.glTF_KHR_materials_unlit); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFMesh -f.Serialize(default(UniGLTF.glTFMesh)); -{ -var value = default(UniGLTF.glTFMesh); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFPrimitives -f.Serialize(default(UniGLTF.glTFPrimitives)); -{ -var value = default(UniGLTF.glTFPrimitives); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFAttributes -f.Serialize(default(UniGLTF.glTFAttributes)); -{ -var value = default(UniGLTF.glTFAttributes); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// gltfMorphTarget -f.Serialize(default(UniGLTF.gltfMorphTarget)); -{ -var value = default(UniGLTF.gltfMorphTarget); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFPrimitives_extras -f.Serialize(default(UniGLTF.glTFPrimitives_extras)); -{ -var value = default(UniGLTF.glTFPrimitives_extras); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFPrimitives_extensions -f.Serialize(default(UniGLTF.glTFPrimitives_extensions)); -{ -var value = default(UniGLTF.glTFPrimitives_extensions); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFNode -f.Serialize(default(UniGLTF.glTFNode)); -{ -var value = default(UniGLTF.glTFNode); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// Int32[] -f.Serialize(default(Int32[])); -{ -var value = default(Int32[]); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer.GenericArrayDeserializer(default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFNode_extensions -f.Serialize(default(UniGLTF.glTFNode_extensions)); -{ -var value = default(UniGLTF.glTFNode_extensions); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFNode_extra -f.Serialize(default(UniGLTF.glTFNode_extra)); -{ -var value = default(UniGLTF.glTFNode_extra); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFSkin -f.Serialize(default(UniGLTF.glTFSkin)); -{ -var value = default(UniGLTF.glTFSkin); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// gltfScene -f.Serialize(default(UniGLTF.gltfScene)); -{ -var value = default(UniGLTF.gltfScene); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFAnimation -f.Serialize(default(UniGLTF.glTFAnimation)); -{ -var value = default(UniGLTF.glTFAnimation); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFAnimationChannel -f.Serialize(default(UniGLTF.glTFAnimationChannel)); -{ -var value = default(UniGLTF.glTFAnimationChannel); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFAnimationTarget -f.Serialize(default(UniGLTF.glTFAnimationTarget)); -{ -var value = default(UniGLTF.glTFAnimationTarget); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFAnimationSampler -f.Serialize(default(UniGLTF.glTFAnimationSampler)); -{ -var value = default(UniGLTF.glTFAnimationSampler); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTFCamera -f.Serialize(default(UniGLTF.glTFCamera)); -{ -var value = default(UniGLTF.glTFCamera); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFOrthographic -f.Serialize(default(UniGLTF.glTFOrthographic)); -{ -var value = default(UniGLTF.glTFOrthographic); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFOrthographic_extensions -f.Serialize(default(UniGLTF.glTFOrthographic_extensions)); -{ -var value = default(UniGLTF.glTFOrthographic_extensions); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFOrthographic_extras -f.Serialize(default(UniGLTF.glTFOrthographic_extras)); -{ -var value = default(UniGLTF.glTFOrthographic_extras); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFPerspective -f.Serialize(default(UniGLTF.glTFPerspective)); -{ -var value = default(UniGLTF.glTFPerspective); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFPerspective_extensions -f.Serialize(default(UniGLTF.glTFPerspective_extensions)); -{ -var value = default(UniGLTF.glTFPerspective_extensions); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFPerspective_extras -f.Serialize(default(UniGLTF.glTFPerspective_extras)); -{ -var value = default(UniGLTF.glTFPerspective_extras); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// ProjectionType -f.Serialize(default(UniGLTF.ProjectionType)); -{ -var value = default(UniGLTF.ProjectionType); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFCamera_extensions -f.Serialize(default(UniGLTF.glTFCamera_extensions)); -{ -var value = default(UniGLTF.glTFCamera_extensions); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTFCamera_extras -f.Serialize(default(UniGLTF.glTFCamera_extras)); -{ -var value = default(UniGLTF.glTFCamera_extras); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTF_extensions -f.Serialize(default(UniGLTF.glTF_extensions)); -{ -var value = default(UniGLTF.glTF_extensions); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTF_VRM_extensions -f.Serialize(default(VRM.glTF_VRM_extensions)); -{ -var value = default(VRM.glTF_VRM_extensions); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTF_VRM_Meta -f.Serialize(default(VRM.glTF_VRM_Meta)); -{ -var value = default(VRM.glTF_VRM_Meta); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTF_VRM_Humanoid -f.Serialize(default(VRM.glTF_VRM_Humanoid)); -{ -var value = default(VRM.glTF_VRM_Humanoid); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTF_VRM_HumanoidBone -f.Serialize(default(VRM.glTF_VRM_HumanoidBone)); -{ -var value = default(VRM.glTF_VRM_HumanoidBone); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTF_VRM_Firstperson -f.Serialize(default(VRM.glTF_VRM_Firstperson)); -{ -var value = default(VRM.glTF_VRM_Firstperson); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTF_VRM_MeshAnnotation -f.Serialize(default(VRM.glTF_VRM_MeshAnnotation)); -{ -var value = default(VRM.glTF_VRM_MeshAnnotation); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTF_VRM_DegreeMap -f.Serialize(default(VRM.glTF_VRM_DegreeMap)); -{ -var value = default(VRM.glTF_VRM_DegreeMap); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTF_VRM_BlendShapeMaster -f.Serialize(default(VRM.glTF_VRM_BlendShapeMaster)); -{ -var value = default(VRM.glTF_VRM_BlendShapeMaster); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTF_VRM_BlendShapeGroup -f.Serialize(default(VRM.glTF_VRM_BlendShapeGroup)); -{ -var value = default(VRM.glTF_VRM_BlendShapeGroup); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTF_VRM_BlendShapeBind -f.Serialize(default(VRM.glTF_VRM_BlendShapeBind)); -{ -var value = default(VRM.glTF_VRM_BlendShapeBind); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTF_VRM_MaterialValueBind -f.Serialize(default(VRM.glTF_VRM_MaterialValueBind)); -{ -var value = default(VRM.glTF_VRM_MaterialValueBind); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// glTF_VRM_SecondaryAnimation -f.Serialize(default(VRM.glTF_VRM_SecondaryAnimation)); -{ -var value = default(VRM.glTF_VRM_SecondaryAnimation); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTF_VRM_SecondaryAnimationGroup -f.Serialize(default(VRM.glTF_VRM_SecondaryAnimationGroup)); -{ -var value = default(VRM.glTF_VRM_SecondaryAnimationGroup); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTF_VRM_SecondaryAnimationColliderGroup -f.Serialize(default(VRM.glTF_VRM_SecondaryAnimationColliderGroup)); -{ -var value = default(VRM.glTF_VRM_SecondaryAnimationColliderGroup); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTF_VRM_SecondaryAnimationCollider -f.Serialize(default(VRM.glTF_VRM_SecondaryAnimationCollider)); -{ -var value = default(VRM.glTF_VRM_SecondaryAnimationCollider); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// List`1 -f.Serialize(default(List)); -{ -var value = default(List); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.GenericListDeserializer(default(ListTreeNode)); -} - -// glTF_VRM_Material -f.Serialize(default(VRM.glTF_VRM_Material)); -{ -var value = default(VRM.glTF_VRM_Material); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// Dictionary`2 -f.Serialize(default(Dictionary)); -{ -var value = default(Dictionary); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.DictionaryDeserializer(default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// Dictionary`2 -f.Serialize(default(Dictionary)); -{ -var value = default(Dictionary); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.DictionaryDeserializer(default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// Dictionary`2 -f.Serialize(default(Dictionary)); -{ -var value = default(Dictionary); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.DictionaryDeserializer(default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// Dictionary`2 -f.Serialize(default(Dictionary)); -{ -var value = default(Dictionary); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.DictionaryDeserializer(default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField>(default(JsonSchema), default(ListTreeNode)); -} - -// Dictionary`2 -f.Serialize(default(Dictionary)); -{ -var value = default(Dictionary); -default(ListTreeNode).Deserialize(ref value); -GenericDeserializer>.DictionaryDeserializer(default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// gltf_extras -f.Serialize(default(UniGLTF.gltf_extras)); -{ -var value = default(UniGLTF.gltf_extras); -default(ListTreeNode).Deserialize(ref value); -} -} - -{ - var f = new MsgPackFormatter(); - - -// String -f.Serialize(default(System.String)); -{ -var value = default(System.String); -default(ListTreeNode).Deserialize(ref value); -} - -// Boolean -f.Serialize(default(System.Boolean)); -{ -var value = default(System.Boolean); -default(ListTreeNode).Deserialize(ref value); -} - -// Byte -f.Serialize(default(System.Byte)); -{ -var value = default(System.Byte); -default(ListTreeNode).Deserialize(ref value); -} - -// UInt16 -f.Serialize(default(System.UInt16)); -{ -var value = default(System.UInt16); -default(ListTreeNode).Deserialize(ref value); -} - -// UInt32 -f.Serialize(default(System.UInt32)); -{ -var value = default(System.UInt32); -default(ListTreeNode).Deserialize(ref value); -} - -// UInt64 -f.Serialize(default(System.UInt64)); -{ -var value = default(System.UInt64); -default(ListTreeNode).Deserialize(ref value); -} - -// SByte -f.Serialize(default(System.SByte)); -{ -var value = default(System.SByte); -default(ListTreeNode).Deserialize(ref value); -} - -// Int16 -f.Serialize(default(System.Int16)); -{ -var value = default(System.Int16); -default(ListTreeNode).Deserialize(ref value); -} - -// Int32 -f.Serialize(default(System.Int32)); -{ -var value = default(System.Int32); -default(ListTreeNode).Deserialize(ref value); -} - -// Int64 -f.Serialize(default(System.Int64)); -{ -var value = default(System.Int64); -default(ListTreeNode).Deserialize(ref value); -} - -// Single -f.Serialize(default(System.Single)); -{ -var value = default(System.Single); -default(ListTreeNode).Deserialize(ref value); -} - -// Double -f.Serialize(default(System.Double)); -{ -var value = default(System.Double); -default(ListTreeNode).Deserialize(ref value); -} - -// Vector2 -f.Serialize(default(UnityEngine.Vector2)); -{ -var value = default(UnityEngine.Vector2); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// Vector3 -f.Serialize(default(UnityEngine.Vector3)); -{ -var value = default(UnityEngine.Vector3); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// Vector4 -f.Serialize(default(UnityEngine.Vector4)); -{ -var value = default(UnityEngine.Vector4); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - -// Quaternion -f.Serialize(default(UnityEngine.Quaternion)); -{ -var value = default(UnityEngine.Quaternion); -default(ListTreeNode).Deserialize(ref value); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} -{ -JsonObjectValidator.GenericDeserializer.DeserializeField(default(JsonSchema), default(ListTreeNode)); -} - - } - } - } -} - diff --git a/Assets/VRM/UniVRM/Scripts/AOTCall.g.cs.meta b/Assets/VRM/UniVRM/Scripts/AOTCall.g.cs.meta deleted file mode 100644 index 9fda613bf..000000000 --- a/Assets/VRM/UniVRM/Scripts/AOTCall.g.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7e3d4b1fe26c7984f93ae501382f2dd6 -timeCreated: 1550041070 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs b/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs deleted file mode 100644 index 6e50945e4..000000000 --- a/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using UniGLTF; -using UniJSON; - -namespace UniGLTF -{ - public partial class glTF_extensions : ExtensionsBase - { - public VRM.glTF_VRM_extensions VRM; - - [JsonSerializeMembers] - void VRMSerializeMembers(GLTFJsonFormatter f) - { - if (VRM != null) - { - f.Key("VRM"); f.GLTFValue(VRM); - } - } - } -} - - -namespace VRM -{ - [Serializable] - [JsonSchema(Title = "vrm", Description = @" -VRM extension is for 3d humanoid avatars (and models) in VR applications. -")] - public class glTF_VRM_extensions : JsonSerializableBase - { - public static string ExtensionName - { - get - { - return "VRM"; - } - } - - [JsonSchema(Description = @"Version of exporter that vrm created. " + VRMVersion.VRM_VERSION)] - public string exporterVersion = "UniVRM-" + VRMVersion.VERSION; - - [JsonSchema(Description = @"Version of VRM specification. " + VRMSpecVersion.VERSION)] - public string specVersion = VRMSpecVersion.Version; - - public glTF_VRM_Meta meta = new glTF_VRM_Meta(); - public glTF_VRM_Humanoid humanoid = new glTF_VRM_Humanoid(); - public glTF_VRM_Firstperson firstPerson = new glTF_VRM_Firstperson(); - public glTF_VRM_BlendShapeMaster blendShapeMaster = new glTF_VRM_BlendShapeMaster(); - public glTF_VRM_SecondaryAnimation secondaryAnimation = new glTF_VRM_SecondaryAnimation(); - public List materialProperties = new List(); - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => exporterVersion); - f.KeyValue(() => specVersion); - f.Key("meta"); f.GLTFValue(meta); - f.Key("humanoid"); f.GLTFValue(humanoid); - f.Key("firstPerson"); f.GLTFValue(firstPerson); - f.Key("blendShapeMaster"); f.GLTFValue(blendShapeMaster); - f.Key("secondaryAnimation"); f.GLTFValue(secondaryAnimation); - f.Key("materialProperties"); f.GLTFValue(materialProperties); - } - } -} diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs.meta b/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs.meta deleted file mode 100644 index ae2eaf1f5..000000000 --- a/Assets/VRM/UniVRM/Scripts/Format/VRMFormat.cs.meta +++ /dev/null @@ -1,13 +0,0 @@ -fileFormatVersion: 2 -guid: 20eca00211c61d047b586f852b818b8f -timeCreated: 1517308526 -licenseType: Free -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Material.cs b/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Material.cs deleted file mode 100644 index 726cd58df..000000000 --- a/Assets/VRM/UniVRM/Scripts/Format/glTF_VRM_Material.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using UniGLTF; -using UniJSON; - - -namespace VRM -{ - [Serializable] - [JsonSchema(Title = "vrm.material")] - public class glTF_VRM_Material : JsonSerializableBase - { - public string name; - public string shader; - public int renderQueue = -1; - - public Dictionary floatProperties = new Dictionary(); - public Dictionary vectorProperties = new Dictionary(); - public Dictionary textureProperties = new Dictionary(); - public Dictionary keywordMap = new Dictionary(); - public Dictionary tagMap = new Dictionary(); - - public static readonly string VRM_USE_GLTFSHADER = "VRM_USE_GLTFSHADER"; - - protected override void SerializeMembers(GLTFJsonFormatter f) - { - f.KeyValue(() => name); - f.KeyValue(() => renderQueue); - f.KeyValue(() => shader); - { - f.Key("floatProperties"); f.BeginMap(); - foreach (var kv in floatProperties) - { - f.Key(kv.Key); f.Value(kv.Value); - } - f.EndMap(); - } - { - f.Key("vectorProperties"); f.BeginMap(); - foreach (var kv in vectorProperties) - { - f.Key(kv.Key); f.Serialize(kv.Value.ToArray()); - } - f.EndMap(); - } - { - f.Key("textureProperties"); f.BeginMap(); - foreach (var kv in textureProperties) - { - f.Key(kv.Key); f.Value(kv.Value); - } - f.EndMap(); - } - { - f.Key("keywordMap"); f.BeginMap(); - foreach (var kv in keywordMap) - { - f.Key(kv.Key); f.Value(kv.Value); - } - f.EndMap(); - } - { - f.Key("tagMap"); f.BeginMap(); - foreach (var kv in tagMap) - { - f.Key(kv.Key); f.Value(kv.Value); - } - f.EndMap(); - } - } - - public static List Parse(string src) - { - var json = JsonParser.Parse(src)["extensions"]["VRM"]["materialProperties"]; - return Parse(json); - } - - static Utf8String s_floatProperties = Utf8String.From("floatProperties"); - static Utf8String s_vectorProperties = Utf8String.From("vectorProperties"); - static Utf8String s_keywordMap = Utf8String.From("keywordMap"); - static Utf8String s_tagMap = Utf8String.From("tagMap"); - static Utf8String s_textureProperties = Utf8String.From("textureProperties"); - - public static List Parse(ListTreeNode json) - { - var materials = json.DeserializeList(); - var jsonItems = json.ArrayItems().ToArray(); - for (int i = 0; i < materials.Count; ++i) - { - materials[i].floatProperties = - jsonItems[i][s_floatProperties].ObjectItems().ToDictionary(x => x.Key.GetString(), x => x.Value.GetSingle()); - materials[i].vectorProperties = - jsonItems[i][s_vectorProperties].ObjectItems().ToDictionary(x => x.Key.GetString(), x => - { - return x.Value.ArrayItems().Select(y => y.GetSingle()).ToArray(); - }); - materials[i].keywordMap = - jsonItems[i][s_keywordMap].ObjectItems().ToDictionary(x => x.Key.GetString(), x => x.Value.GetBoolean()); - materials[i].tagMap = - jsonItems[i][s_tagMap].ObjectItems().ToDictionary(x => x.Key.GetString(), x => x.Value.GetString()); - materials[i].textureProperties = - jsonItems[i][s_textureProperties].ObjectItems().ToDictionary(x => x.Key.GetString(), x => x.Value.GetInt32()); - } - return materials; - } - } -} diff --git a/Assets/VRM/package.json b/Assets/VRM/package.json index ce3b07311..695dcff7f 100644 --- a/Assets/VRM/package.json +++ b/Assets/VRM/package.json @@ -15,6 +15,7 @@ }, "dependencies": { "com.vrmc.vrmshaders": "0.62.0", - "com.vrmc.meshutility": "0.62.0" + "com.vrmc.meshutility": "0.62.0", + "com.vrmc.unigltf": "2.0.0" } } diff --git a/Packages/manifest.json b/Packages/manifest.json new file mode 100644 index 000000000..ddf67b40c --- /dev/null +++ b/Packages/manifest.json @@ -0,0 +1,40 @@ +{ + "dependencies": { + "com.unity.ads": "2.0.8", + "com.unity.analytics": "3.2.3", + "com.unity.collab-proxy": "1.2.15", + "com.unity.package-manager-ui": "2.0.13", + "com.unity.purchasing": "2.0.3", + "com.unity.textmeshpro": "1.4.1", + "com.unity.modules.ai": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.cloth": "1.0.0", + "com.unity.modules.director": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.physics2d": "1.0.0", + "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.terrain": "1.0.0", + "com.unity.modules.terrainphysics": "1.0.0", + "com.unity.modules.tilemap": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.uielements": "1.0.0", + "com.unity.modules.umbra": "1.0.0", + "com.unity.modules.unityanalytics": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.unitywebrequesttexture": "1.0.0", + "com.unity.modules.unitywebrequestwww": "1.0.0", + "com.unity.modules.vehicles": "1.0.0", + "com.unity.modules.video": "1.0.0", + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.wind": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } +} diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 393cb6385..a07f3960c 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -68,7 +68,7 @@ PlayerSettings: androidBlitType: 0 defaultIsNativeResolution: 1 macRetinaSupport: 1 - runInBackground: 0 + runInBackground: 1 captureSingleScreen: 0 muteOtherAudioSources: 0 Prepare IOS For Recording: 0 @@ -112,6 +112,8 @@ PlayerSettings: switchNVNShaderPoolsGranularity: 33554432 switchNVNDefaultPoolsGranularity: 16777216 switchNVNOtherPoolsGranularity: 16777216 + switchNVNMaxPublicTextureIDCount: 0 + switchNVNMaxPublicSamplerIDCount: 0 vulkanEnableSetSRGBWrite: 0 m_SupportedAspectRatios: 4:3: 1 @@ -446,6 +448,7 @@ PlayerSettings: ps4ShareFilePath: ps4ShareOverlayImagePath: ps4PrivacyGuardImagePath: + ps4ExtraSceSysFile: ps4NPtitleDatPath: ps4RemotePlayKeyAssignment: -1 ps4RemotePlayKeyMappingDir: @@ -486,6 +489,8 @@ PlayerSettings: ps4disableAutoHideSplash: 0 ps4videoRecordingFeaturesUsed: 0 ps4contentSearchFeaturesUsed: 0 + ps4CompatibilityPS5: 0 + ps4GPU800MHz: 1 ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] monoEnv: