protected override bool Export()
        {
            if (string.IsNullOrEmpty(ExportFileName))
            {
                Debug.LogError("FbxExporter: Please specify an fbx filename");
                return(false);
            }
            var folderPath = ExportSettings.GetAbsoluteSavePath(FbxSavePaths[SelectedFbxPath]);
            var filePath   = System.IO.Path.Combine(folderPath, ExportFileName + ".fbx");

            if (!OverwriteExistingFile(filePath))
            {
                return(false);
            }

            string exportResult;

            if (IsTimelineAnim)
            {
                exportResult = ModelExporter.ExportTimelineClip(filePath, TimelineClipToExport, PlayableDirector, SettingsObject);
            }
            else
            {
                exportResult = ModelExporter.ExportObjects(filePath, ToExport, SettingsObject);
            }

            if (!string.IsNullOrEmpty(exportResult))
            {
                // refresh the asset database so that the file appears in the
                // asset folder view.
                AssetDatabase.Refresh();
            }
            return(true);
        }
Пример #2
0
        public void ExportSingleTimelineClipTest()
        {
            string cubeSpecialPath = FindPathInUnitTests("Scene/CubeSpecial.prefab");

            GameObject   myCube               = AddAssetToScene(cubeSpecialPath);
            string       folderPath           = GetRandomFileNamePath(extName: "");
            string       filePath             = null;
            TimelineClip timelineClipToExport = null;

            UnityEditor.Selection.activeObject = myCube;

            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";
                        timelineClipToExport = timeLineClip;
                        break;
                    }
                }
            }
            Assert.That(filePath, Is.Not.Null);

            var exportOptions = new ExportModelSettingsSerialize();

            exportOptions.SetModelAnimIncludeOption(ExportSettings.Include.Anim);

            ModelExporter.ExportTimelineClip(filePath, timelineClipToExport, pd, exportOptions);
            FileAssert.Exists(filePath);
        }