Ejemplo n.º 1
0
        public void VRMLookAtTest()
        {
            var parser = new GltfParser();

            parser.ParsePath(AliciaPath);
            byte[] bytes = default;
            using (var loader = new VRMImporterContext(parser))
            {
                loader.Load();
                loader.ShowMeshes();

                var go = loader.Root;
                var fp = go.GetComponent <VRMFirstPerson>();
                GameObject.DestroyImmediate(go.GetComponent <VRMLookAtBoneApplyer>());
                go.AddComponent <VRMLookAtBlendShapeApplyer>();
                bytes = VRMEditorExporter.Export(go, null, new VRMExportSettings
                {
                    PoseFreeze = true,
                });
            }

            var parser2 = new GltfParser();

            parser2.Parse(AliciaPath, bytes);
            var loader2 = new VRMImporterContext(parser2);

            Assert.AreEqual(LookAtType.BlendShape, loader2.VRM.firstPerson.lookAtType);
        }
        static void OnExportClicked(GameObject root, VRMMetaObject meta, VRMExportSettings settings, VRMExportMeshes meshes)
        {
            string directory;

            if (string.IsNullOrEmpty(m_lastExportDir))
            {
                directory = Directory.GetParent(Application.dataPath).ToString();
            }
            else
            {
                directory = m_lastExportDir;
            }

            // save dialog
            var path = EditorUtility.SaveFilePanel(
                "Save vrm",
                directory,
                root.name + EXTENSION,
                EXTENSION.Substring(1));

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            m_lastExportDir = Path.GetDirectoryName(path).Replace("\\", "/");

            // export
            VRMEditorExporter.Export(path, root, meta, settings, meshes.Meshes);
        }
Ejemplo n.º 3
0
        public void VRMLookAtCurveMapTest()
        {
            var data = new GlbFileParser(AliciaPath).Parse();

            byte[]      bytes           = default;
            CurveMapper horizontalInner = default;

            using (data)
                using (var loader = new VRMImporterContext(new VRMData(data)))
                    using (var loaded = loader.Load())
                    {
                        loaded.ShowMeshes();

                        var go     = loaded.gameObject;
                        var fp     = go.GetComponent <VRMFirstPerson>();
                        var lookAt = go.GetComponent <VRMLookAtBoneApplyer>();
                        horizontalInner = lookAt.HorizontalInner;
                        bytes           = VRMEditorExporter.Export(go, null, new VRMExportSettings
                        {
                            PoseFreeze = false,
                        });
                    }

            using (var data2 = new GlbLowLevelParser(AliciaPath, bytes).Parse())
                using (var loader = new VRMImporterContext(new VRMData(data2)))
                    using (var loaded = loader.Load())
                    {
                        loaded.ShowMeshes();

                        var lookAt = loaded.GetComponent <VRMLookAtBoneApplyer>();
                        Assert.AreEqual(horizontalInner.CurveXRangeDegree, lookAt.HorizontalInner.CurveXRangeDegree);
                        Assert.AreEqual(horizontalInner.CurveYRangeDegree, lookAt.HorizontalInner.CurveYRangeDegree);
                    }
        }
Ejemplo n.º 4
0
        public void VRMLookAtTest()
        {
            var data = new GlbFileParser(AliciaPath).Parse();

            byte[] bytes = default;
            using (data)
                using (var loader = new VRMImporterContext(new VRMData(data)))
                    using (var loaded = loader.Load())
                    {
                        loaded.ShowMeshes();

                        var go = loaded.gameObject;
                        var fp = go.GetComponent <VRMFirstPerson>();
                        GameObject.DestroyImmediate(go.GetComponent <VRMLookAtBoneApplyer>());
                        var lookAt = go.AddComponent <VRMLookAtBlendShapeApplyer>();
                        bytes = VRMEditorExporter.Export(go, null, new VRMExportSettings
                        {
                            PoseFreeze = true,
                        });
                    }

            using (var data2 = new GlbLowLevelParser(AliciaPath, bytes).Parse())
                using (var loader2 = new VRMImporterContext(new VRMData(data2)))
                {
                    Assert.AreEqual(LookAtType.BlendShape, loader2.VRM.firstPerson.lookAtType);
                }
        }
Ejemplo n.º 5
0
        void OnWizardCreate()
        {
            string directory;

            if (string.IsNullOrEmpty(m_lastExportDir))
            {
                directory = Directory.GetParent(Application.dataPath).ToString();
            }
            else
            {
                directory = m_lastExportDir;
            }

            // save dialog
            var path = EditorUtility.SaveFilePanel(
                "Save vrm",
                directory,
                ExportRoot.name + EXTENSION,
                EXTENSION.Substring(1));

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            m_lastExportDir = Path.GetDirectoryName(path).Replace("\\", "/");

            // export
            VRMEditorExporter.Export(path, ExportRoot, Meta != null ? Meta : m_tmpMeta, m_settings);
        }
Ejemplo n.º 6
0
        protected override void ExportPath(string path)
        {
            var bytes = VRMEditorExporter.Export(State.ExportRoot, Meta != null ? Meta : m_tmpMeta, m_settings);

            File.WriteAllBytes(path, bytes);

            if (path.StartsWithUnityAssetPath())
            {
                // 出力ファイルのインポートを発動
                AssetDatabase.ImportAsset(path.ToUnityRelativePath());
            }
        }
Ejemplo n.º 7
0
        void OnWizardCreate()
        {
            string directory;

            if (string.IsNullOrEmpty(m_lastExportDir))
            {
                directory = Directory.GetParent(Application.dataPath).ToString();
            }
            else
            {
                directory = m_lastExportDir;
            }

            // save dialog
            var path = EditorUtility.SaveFilePanel(
                "Save vrm",
                directory,
                ExportRoot.name + EXTENSION,
                EXTENSION.Substring(1));

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            m_lastExportDir = Path.GetDirectoryName(path).Replace("\\", "/");

            // export
            if (Meta == null)
            {
                var metaB = ExportRoot.GetComponent <VRMMeta>();
                if (metaB == null)
                {
                    metaB = ExportRoot.AddComponent <VRMMeta>();
                }
                metaB.Meta = m_tmpMeta;
            }
            VRMEditorExporter.Export(path, ExportRoot, m_settings);
            if (Meta == null)
            {
                UnityEngine.GameObject.DestroyImmediate(ExportRoot.GetComponent <VRMMeta>());
            }
        }
Ejemplo n.º 8
0
        public void VRMLookAtCurveMapTest()
        {
            var parser = new GltfParser();

            parser.ParsePath(AliciaPath);
            byte[]      bytes           = default;
            CurveMapper horizontalInner = default;

            using (var loader = new VRMImporterContext(parser))
            {
                loader.Load();
                loader.ShowMeshes();

                var go     = loader.Root;
                var fp     = go.GetComponent <VRMFirstPerson>();
                var lookAt = go.GetComponent <VRMLookAtBoneApplyer>();
                horizontalInner = lookAt.HorizontalInner;
                bytes           = VRMEditorExporter.Export(go, null, new VRMExportSettings
                {
                    PoseFreeze = false,
                });
            }

            var parser2 = new GltfParser();

            parser2.Parse(AliciaPath, bytes);
            using (var loader = new VRMImporterContext(parser2))
            {
                loader.Load();
                loader.ShowMeshes();

                var lookAt = loader.Root.GetComponent <VRMLookAtBoneApplyer>();
                Assert.AreEqual(horizontalInner.CurveXRangeDegree, lookAt.HorizontalInner.CurveXRangeDegree);
                Assert.AreEqual(horizontalInner.CurveYRangeDegree, lookAt.HorizontalInner.CurveYRangeDegree);
            }
        }