public int BlendshapeAnimOnlyTest(float[] keyTimesInSeconds, float[] keyValues, System.Type componentType, string componentName) { var prefabPath = FindPathInUnitTests("Models/blendshape.fbx"); Assert.That(prefabPath, Is.Not.Null); // add prefab to scene GameObject originalGO = AddAssetToScene(prefabPath); KeyData keyData = new PropertyKeyData { targetObject = originalGO, propertyName = componentName, componentType = componentType, keyTimes = keyTimesInSeconds, keyFloatValues = keyValues }; var tester = new AnimTester { keyData = keyData, testName = componentName, path = GetRandomFbxFilePath() }; var exportOptions = new ExportModelSettingsSerialize(); exportOptions.SetAnimatedSkinnedMesh(true); // only export animation, not model and animation exportOptions.SetModelAnimIncludeOption(ExportSettings.Include.Anim); tester.exportOptions = exportOptions; return(tester.DoIt()); }
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); }
/// <summary> /// Exports a single hierarchy to a random fbx file. /// </summary> /// <returns>The exported fbx file path.</returns> /// <param name="hierarchy">Hierarchy.</param> /// <param name="animOnly">If set to <c>true</c> export animation only.</param> internal GameObject ExportToFbx( GameObject hierarchy, bool animOnly = false, ExportSettings.LODExportType lodExportType = ExportSettings.LODExportType.All ) { string filename = GetRandomFbxFilePath(); var exportOptions = new ExportModelSettingsSerialize(); exportOptions.SetLODExportType(lodExportType); if (animOnly) { exportOptions.SetModelAnimIncludeOption(ExportSettings.Include.Anim); } var exportedFilePath = ModelExporter.ExportObject( filename, hierarchy, exportOptions ); Assert.That(exportedFilePath, Is.EqualTo(filename)); var exported = AssetDatabase.LoadMainAssetAtPath(filename) as GameObject; return(exported); }