コード例 #1
0
        public void ExportSingleTimelineClipTest()
        {
            string cubeSpecialPath = FindPathInUnitTests("Scene/CubeSpecial.prefab");

            GameObject myCube     = AddAssetToScene(cubeSpecialPath);
            string     folderPath = GetRandomFileNamePath(extName: "");
            string     filePath   = null;
            var        exportData = new Dictionary <GameObject, IExportData>();

            PlayableDirector pd = myCube.GetComponent <PlayableDirector> ();

            if (pd != null)
            {
                foreach (PlayableBinding output in pd.playableAsset.outputs)
                {
                    AnimationTrack at = output.sourceObject as AnimationTrack;

                    var atComponent = pd.GetGenericBinding(at) as Component;
                    Assert.That(atComponent, Is.Not.Null);

                    var atObject = atComponent.gameObject;

                    // One file by animation clip
                    foreach (TimelineClip timeLineClip in at.GetClips())
                    {
                        Assert.That(timeLineClip.animationClip, Is.Not.Null);

                        filePath             = string.Format("{0}/{1}@{2}", folderPath, atObject.name, "Recorded.fbx");
                        exportData[atObject] = ModelExporter.GetExportData(atObject, timeLineClip.animationClip);
                        break;
                    }
                }
            }
            Assert.That(filePath, Is.Not.Null);
            Assert.That(exportData, Is.Not.Null);

            // This version of ExportObjects is private. Use reflection
            // ModelExporter.ExportObjects(filePath, new Object[1]{myCube}, null, exportData);
            var internalMethod = typeof(ModelExporter).GetMethod("ExportObjects",
                                                                 BindingFlags.Static | BindingFlags.NonPublic,
                                                                 null,
                                                                 new Type[] { typeof(string), typeof(UnityEngine.Object[]), typeof(IExportOptions), typeof(Dictionary <GameObject, IExportData>) },
                                                                 null);

            internalMethod.Invoke(null, new object[] { filePath, new UnityEngine.Object[1] {
                                                           myCube
                                                       }, null, exportData });
            FileAssert.Exists(filePath);
        }
コード例 #2
0
        public void ExportSingleTimelineClipFromExportDataTest()
        {
            string cubeSpecialPath = FindPathInUnitTests("Scene/CubeSpecial.prefab");

            GameObject myCube     = AddAssetToScene(cubeSpecialPath);
            string     folderPath = GetRandomFileNamePath(extName: "");
            string     filePath   = null;
            var        exportData = new Dictionary <GameObject, IExportData>();

            PlayableDirector pd = myCube.GetComponent <PlayableDirector>();

            if (pd != null)
            {
                foreach (PlayableBinding output in pd.playableAsset.outputs)
                {
                    AnimationTrack at = output.sourceObject as AnimationTrack;

                    var atComponent = pd.GetGenericBinding(at) as Component;
                    Assert.That(atComponent, Is.Not.Null);

                    var atObject = atComponent.gameObject;

                    // One file by animation clip
                    foreach (TimelineClip timeLineClip in at.GetClips())
                    {
                        Assert.That(timeLineClip.animationClip, Is.Not.Null);

                        filePath             = $"{folderPath}/{atObject.name}@Recorded.fbx";
                        exportData[atObject] = ModelExporter.GetExportData(atObject, timeLineClip.animationClip);
                        break;
                    }
                }
            }
            Assert.That(filePath, Is.Not.Null);
            Assert.That(exportData, Is.Not.Null);
            ModelExporter.ExportObjects(filePath, new UnityEngine.Object[1] {
                myCube
            }, null, exportData);
            FileAssert.Exists(filePath);
        }