Skip to content

Commit 77a2158

Browse files
committed
Merge branch 'master' into UNI-41138-connect-UI-to-exporter
2 parents b47dde6 + 5d270d4 commit 77a2158

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public class ModelExporter : System.IDisposable
8282
// from being passed to command, thus resulting in OnContextItem()
8383
// being called only once regardless of what is selected.
8484
const string MenuItemName = "GameObject/Export Model...";
85+
const string ModelOnlyMenuItemName = "GameObject/Export Model Only...";
8586

8687
const string ClipMenuItemName = "GameObject/Export All Recorded Animation Clips...";
8788
const string TimelineClipMenuItemName = "GameObject/Export Selected Timeline Clip...";
@@ -2512,7 +2513,7 @@ protected Dictionary<GameObject, AnimationOnlyExportData> GetAnimationExportData
25122513
/// Transform components have already been exported.
25132514
/// This function exports the other components and animation.
25142515
/// </summary>
2515-
protected bool ExportComponents(FbxScene fbxScene)
2516+
protected bool ExportComponents(FbxScene fbxScene, AnimationExportType animationExportType = AnimationExportType.all)
25162517
{
25172518
var animationNodes = new HashSet<GameObject> ();
25182519

@@ -2551,7 +2552,7 @@ protected bool ExportComponents(FbxScene fbxScene)
25512552

25522553
// check if this object contains animation, keep track of it
25532554
// if it does
2554-
if (GameObjectHasAnimation (unityGo)) {
2555+
if (animationExportType != AnimationExportType.none && GameObjectHasAnimation (unityGo) ) {
25552556
animationNodes.Add (unityGo);
25562557
}
25572558
}
@@ -2718,7 +2719,8 @@ public enum TransformExportType { Local, Global, Reset };
27182719
/// </summary>
27192720
public int ExportAll (
27202721
IEnumerable<UnityEngine.Object> unityExportSet,
2721-
Dictionary<GameObject, AnimationOnlyExportData> animationExportData)
2722+
Dictionary<GameObject, AnimationOnlyExportData> animationExportData
2723+
AnimationExportType animationExportType = AnimationExportType.all)
27222724
{
27232725
exportCancelled = false;
27242726

@@ -2846,7 +2848,7 @@ public int ExportAll (
28462848
foreach (var unityGo in revisedExportSet) {
28472849
AnimationOnlyExportData data;
28482850
if(animOnly && animationExportData.TryGetValue(unityGo, out data)){
2849-
exportProgress = this.ExportAnimationOnly(unityGo, fbxScene, exportProgress, count, center, data, exportType);
2851+
exportProgress = this.ExportAnimationOnly(unityGo, fbxScene, exportProgress, count, center, data, transformExportType);
28502852
}
28512853
else {
28522854
exportProgress = this.ExportTransformHierarchy (unityGo, fbxScene, fbxRootNode,
@@ -2859,7 +2861,7 @@ public int ExportAll (
28592861
}
28602862

28612863
if(!animOnly){
2862-
if(!ExportComponents(fbxScene)){
2864+
if(!ExportComponents(fbxScene,animationExportType)){
28632865
Debug.LogWarning ("Export Cancelled");
28642866
return 0;
28652867
}
@@ -3127,6 +3129,30 @@ public static bool OnValidateMenuItem ()
31273129
return true;
31283130
}
31293131

3132+
/// <summary>
3133+
/// Add a menu item "Export Model Only..." to a GameObject's context menu.
3134+
/// </summary>
3135+
/// <param name="command">Command.</param>
3136+
[MenuItem (ModelOnlyMenuItemName, false, 30)]
3137+
static void ModelOnlyOnContextItem (MenuCommand command)
3138+
{
3139+
if (Selection.objects.Length <= 0) {
3140+
DisplayNoSelectionDialog ();
3141+
return;
3142+
}
3143+
OnExport (AnimationExportType.none);
3144+
}
3145+
3146+
/// <summary>
3147+
/// Validate the menu item defined by the function above.
3148+
/// </summary>
3149+
[MenuItem (ModelOnlyMenuItemName, true, 30)]
3150+
public static bool ModelOnlyOnValidateMenuItem ()
3151+
{
3152+
return true;
3153+
}
3154+
3155+
31303156
/// <summary>
31313157
/// Add a menu item "Export Animation Only" to a GameObject's context menu.
31323158
/// </summary>
@@ -3601,7 +3627,8 @@ public enum AnimationExportType{
36013627
timelineAnimationClip,
36023628
timelineAnimationTrack,
36033629
componentAnimation,
3604-
all
3630+
all,
3631+
none
36053632
}
36063633

36073634

@@ -3651,7 +3678,7 @@ public static string ExportObjects (
36513678
}
36523679

36533680
Dictionary<GameObject, AnimationOnlyExportData> animationExportData = null;
3654-
switch (exportType)
3681+
switch (animationExportType)
36553682
{
36563683
case AnimationExportType.timelineAnimationClip:
36573684
// We expect the first argument in the list to be the GameObject, the second one is the Animation Clip/Track we are exporting from the timeline
@@ -3678,7 +3705,7 @@ public static string ExportObjects (
36783705
break;
36793706
}
36803707

3681-
if (fbxExporter.ExportAll (objects, animationExportData) > 0) {
3708+
if (fbxExporter.ExportAll (objects, animationExportData, animationExportType) > 0) {
36823709
string message = string.Format ("Successfully exported: {0}", filePath);
36833710
UnityEngine.Debug.Log (message);
36843711

0 commit comments

Comments
 (0)