Skip to content

Commit 9c92be0

Browse files
committed
Merge branch 'master' into UNI-39449-timeline-clip-export-filename-select
2 parents 51a7e9d + 21e7287 commit 9c92be0

File tree

6 files changed

+131
-55
lines changed

6 files changed

+131
-55
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public override void OnInspectorGUI() {
5656
exportSettings.autoUpdaterEnabled
5757
);
5858

59+
exportSettings.exportMeshNoRenderer = EditorGUILayout.Toggle(
60+
new GUIContent("Export Meshes with no Renderers:",
61+
"If unchecked, meshes that don't have renderers won't be exported."),
62+
exportSettings.exportMeshNoRenderer
63+
);
64+
5965
GUILayout.BeginHorizontal();
6066
EditorGUILayout.LabelField(new GUIContent("Export Format:", "Export the FBX file in the standard binary format." +
6167
" Select ASCII to export the FBX file in ASCII format."), GUILayout.Width(LabelWidth - FieldOffset));
@@ -442,6 +448,7 @@ public static string[] DCCVendorLocations
442448
public bool HideSendToUnityMenu = true;
443449
public int ExportFormatSelection;
444450
public bool BakeAnimation = true;
451+
public bool exportMeshNoRenderer = false;
445452

446453
public string IntegrationSavePath;
447454

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 68 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class ModelExporter : System.IDisposable
8686
const string ClipMenuItemName = "GameObject/Export All Timeline Clips...";
8787
const string TimelineClipMenuItemName = "GameObject/Export Selected Timeline Clip...";
8888

89-
const string AnimOnlyMenuItemName = "GameObject/Export Animation Only";
89+
const string AnimOnlyMenuItemName = "GameObject/Export Animation Only...";
9090

9191
const string FileBaseName = "Untitled";
9292

@@ -189,6 +189,11 @@ public enum FbxNodeRelationType
189189
/// </summary>
190190
const string UniqueNameFormat = "{0}_{1}";
191191

192+
/// <summary>
193+
/// The animation fbx file format.
194+
/// </summary>
195+
const string AnimFbxFileFormat = "{0}/{1}@{2}.fbx";
196+
192197
/// <summary>
193198
/// Gets the export settings.
194199
/// </summary>
@@ -1238,7 +1243,8 @@ protected bool ExportInstance (GameObject unityGo, FbxNode fbxNode, FbxScene fbx
12381243
{
12391244
PrefabType unityPrefabType = PrefabUtility.GetPrefabType(unityGo);
12401245

1241-
if (unityPrefabType != PrefabType.PrefabInstance) return false;
1246+
if (unityPrefabType != PrefabType.PrefabInstance &&
1247+
unityPrefabType != PrefabType.ModelPrefabInstance) return false;
12421248

12431249
Object unityPrefabParent = PrefabUtility.GetPrefabParent (unityGo);
12441250

@@ -1530,8 +1536,8 @@ protected void ExportAnimationCurve (UnityEngine.Object uniObj,
15301536
Debug.Log ("Exporting animation for " + uniObj.ToString() + " (" + uniPropertyName + ")");
15311537
}
15321538

1533-
FbxPropertyChannelPair fbxPropertyChannelPair;
1534-
if (!FbxPropertyChannelPair.TryGetValue (uniPropertyName, out fbxPropertyChannelPair)) {
1539+
FbxPropertyChannelPair[] fbxPropertyChannelPairs;
1540+
if (!FbxPropertyChannelPair.TryGetValue (uniPropertyName, out fbxPropertyChannelPairs)) {
15351541
Debug.LogWarning (string.Format ("no mapping from Unity '{0}' to fbx property", uniPropertyName));
15361542
return;
15371543
}
@@ -1549,39 +1555,35 @@ protected void ExportAnimationCurve (UnityEngine.Object uniObj,
15491555
return;
15501556
}
15511557

1552-
// map unity property name to fbx property
1553-
var fbxProperty = fbxNode.FindProperty(fbxPropertyChannelPair.Property, false);
1554-
if (!fbxProperty.IsValid())
1555-
{
1556-
var fbxNodeAttribute = fbxNode.GetNodeAttribute();
1557-
if (fbxNodeAttribute != null)
1558-
{
1559-
fbxProperty = fbxNodeAttribute.FindProperty(fbxPropertyChannelPair.Property, false);
1558+
foreach (var fbxPropertyChannelPair in fbxPropertyChannelPairs) {
1559+
// map unity property name to fbx property
1560+
var fbxProperty = fbxNode.FindProperty (fbxPropertyChannelPair.Property, false);
1561+
if (!fbxProperty.IsValid ()) {
1562+
var fbxNodeAttribute = fbxNode.GetNodeAttribute ();
1563+
if (fbxNodeAttribute != null) {
1564+
fbxProperty = fbxNodeAttribute.FindProperty (fbxPropertyChannelPair.Property, false);
1565+
}
1566+
}
1567+
if (!fbxProperty.IsValid ()) {
1568+
Debug.LogError (string.Format ("no fbx property {0} found on {1} node or nodeAttribute ", fbxPropertyChannelPair.Property, fbxNode.GetName ()));
1569+
return;
15601570
}
1561-
}
1562-
if (!fbxProperty.IsValid())
1563-
{
1564-
Debug.LogError(string.Format("no fbx property {0} found on {1} node or nodeAttribute ", fbxPropertyChannelPair.Property, fbxNode.GetName()));
1565-
return;
1566-
}
15671571

1568-
// Create the AnimCurve on the channel
1569-
FbxAnimCurve fbxAnimCurve = fbxProperty.GetCurve (fbxAnimLayer, fbxPropertyChannelPair.Channel, true);
1572+
// Create the AnimCurve on the channel
1573+
FbxAnimCurve fbxAnimCurve = fbxProperty.GetCurve (fbxAnimLayer, fbxPropertyChannelPair.Channel, true);
15701574

1571-
// create a convert scene helper so that we can convert from Unity to Maya
1572-
// AxisSystem (LeftHanded to RightHanded) and FBX's default units
1573-
// (Meters to Centimetres)
1574-
var convertSceneHelper = new UnityToMayaConvertSceneHelper (uniPropertyName);
1575+
// create a convert scene helper so that we can convert from Unity to Maya
1576+
// AxisSystem (LeftHanded to RightHanded) and FBX's default units
1577+
// (Meters to Centimetres)
1578+
var convertSceneHelper = new UnityToMayaConvertSceneHelper (uniPropertyName);
15751579

1576-
// TODO: we'll resample the curve so we don't have to
1577-
// configure tangents
1578-
if (ModelExporter.ExportSettings.BakeAnimation)
1579-
{
1580-
ExportAnimationSamples(uniAnimCurve, fbxAnimCurve, frameRate, convertSceneHelper);
1581-
}
1582-
else
1583-
{
1584-
ExportAnimationKeys(uniAnimCurve, fbxAnimCurve, convertSceneHelper);
1580+
// TODO: we'll resample the curve so we don't have to
1581+
// configure tangents
1582+
if (ModelExporter.ExportSettings.BakeAnimation) {
1583+
ExportAnimationSamples (uniAnimCurve, fbxAnimCurve, frameRate, convertSceneHelper);
1584+
} else {
1585+
ExportAnimationKeys (uniAnimCurve, fbxAnimCurve, convertSceneHelper);
1586+
}
15851587
}
15861588
}
15871589

@@ -1636,75 +1638,78 @@ public FbxPropertyChannelPair(string p, string c):this() {
16361638
/// Map a Unity property name to the corresponding FBX property and
16371639
/// channel names.
16381640
/// </summary>
1639-
public static bool TryGetValue(string uniPropertyName, out FbxPropertyChannelPair prop)
1641+
public static bool TryGetValue(string uniPropertyName, out FbxPropertyChannelPair[] prop)
16401642
{
16411643
System.StringComparison ct = System.StringComparison.CurrentCulture;
16421644

16431645
// Transform Scaling
16441646
if (uniPropertyName.StartsWith ("m_LocalScale.x", ct) || uniPropertyName.EndsWith ("S.x", ct)) {
1645-
prop = new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_X);
1647+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_X) };
16461648
return true;
16471649
}
16481650
if (uniPropertyName.StartsWith ("m_LocalScale.y", ct) || uniPropertyName.EndsWith ("S.y", ct)) {
1649-
prop = new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_Y);
1651+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_Y) };
16501652
return true;
16511653
}
16521654
if (uniPropertyName.StartsWith ("m_LocalScale.z", ct) || uniPropertyName.EndsWith ("S.z", ct)) {
1653-
prop = new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_Z);
1655+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Scaling", Globals.FBXSDK_CURVENODE_COMPONENT_Z) };
16541656
return true;
16551657
}
16561658

16571659
// Transform Translation
16581660
if (uniPropertyName.StartsWith ("m_LocalPosition.x", ct) || uniPropertyName.EndsWith ("T.x", ct)) {
1659-
prop = new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_X);
1661+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_X) };
16601662
return true;
16611663
}
16621664
if (uniPropertyName.StartsWith ("m_LocalPosition.y", ct) || uniPropertyName.EndsWith ("T.y", ct)) {
1663-
prop = new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_Y);
1665+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_Y) };
16641666
return true;
16651667
}
16661668
if (uniPropertyName.StartsWith ("m_LocalPosition.z", ct) || uniPropertyName.EndsWith ("T.z", ct)) {
1667-
prop = new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_Z);
1669+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Lcl Translation", Globals.FBXSDK_CURVENODE_COMPONENT_Z) };
16681670
return true;
16691671
}
16701672

16711673
if (uniPropertyName.StartsWith("m_Intensity", ct))
16721674
{
1673-
prop = new FbxPropertyChannelPair ("Intensity", null);
1675+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Intensity", null) };
16741676
return true;
16751677
}
16761678

16771679
if (uniPropertyName.StartsWith("m_SpotAngle", ct))
16781680
{
1679-
prop = new FbxPropertyChannelPair ("OuterAngle", null);
1681+
prop = new FbxPropertyChannelPair[]{
1682+
new FbxPropertyChannelPair ("OuterAngle", null),
1683+
new FbxPropertyChannelPair ("InnerAngle", null)
1684+
};
16801685
return true;
16811686
}
16821687

16831688
if (uniPropertyName.StartsWith("m_Color.r", ct))
16841689
{
1685-
prop = new FbxPropertyChannelPair ("Color", Globals.FBXSDK_CURVENODE_COLOR_RED);
1690+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair ("Color", Globals.FBXSDK_CURVENODE_COLOR_RED) };
16861691
return true;
16871692
}
16881693

16891694
if (uniPropertyName.StartsWith("m_Color.g", ct))
16901695
{
1691-
prop = new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR_GREEN);
1696+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR_GREEN) };
16921697
return true;
16931698
}
16941699

16951700
if (uniPropertyName.StartsWith("m_Color.b", ct))
16961701
{
1697-
prop = new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR_BLUE);
1702+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair("Color", Globals.FBXSDK_CURVENODE_COLOR_BLUE) };
16981703
return true;
16991704
}
17001705

17011706
if (uniPropertyName.StartsWith("field of view", ct))
17021707
{
1703-
prop = new FbxPropertyChannelPair("FieldOfView", null);
1708+
prop = new FbxPropertyChannelPair[]{ new FbxPropertyChannelPair("FieldOfView", null) };
17041709
return true;
17051710
}
17061711

1707-
prop = new FbxPropertyChannelPair ();
1712+
prop = new FbxPropertyChannelPair[]{};
17081713
return false;
17091714
}
17101715
}
@@ -2813,7 +2818,7 @@ public int ExportAll (
28132818

28142819
Vector3 center = Vector3.zero;
28152820
if(exportType == TransformExportType.Global){
2816-
center = ExportSettings.centerObjects? FindCenter(revisedExportSet) : Vector3.zero;
2821+
center = (ExportSettings.centerObjects && revisedExportSet.Count > 1)? FindCenter(revisedExportSet) : Vector3.zero;
28172822
}
28182823

28192824
foreach (var unityGo in revisedExportSet) {
@@ -2950,12 +2955,10 @@ static void OnClipContextClick(MenuCommand command)
29502955
{
29512956
if (obj.GetType().Name.Contains("EditorClip"))
29522957
{
2953-
var selClip = obj.GetType ().GetProperty ("clip").GetValue (obj, null);
2954-
UnityEngine.Timeline.TimelineClip timeLineClip = selClip as UnityEngine.Timeline.TimelineClip;
2958+
var timeLineClip = GetPropertyFromObject<TimelineClip> (obj, "clip");
29552959

2956-
var selClipItem = obj.GetType ().GetProperty ("item").GetValue (obj, null);
2957-
var selClipItemParentTrack = selClipItem.GetType ().GetProperty ("parentTrack").GetValue (selClipItem, null);
2958-
AnimationTrack editorClipAnimationTrack = selClipItemParentTrack as AnimationTrack;
2960+
var selClipItem = GetPropertyFromObject<object>(obj, "item");
2961+
var editorClipAnimationTrack = GetPropertyFromObject<AnimationTrack> (selClipItem, "parentTrack");
29592962

29602963
GameObject animationTrackGObject = UnityEditor.Timeline.TimelineEditor.playableDirector.GetGenericBinding (editorClipAnimationTrack) as GameObject;
29612964

@@ -2972,6 +2975,10 @@ static void OnClipContextClick(MenuCommand command)
29722975
}
29732976
}
29742977

2978+
private static T GetPropertyFromObject<T>(object obj, string propertyName) where T : class {
2979+
return obj.GetType ().GetProperty (propertyName).GetValue (obj, null) as T;
2980+
}
2981+
29752982
/// <summary>
29762983
/// Add an option "Export all Timeline clips" in the contextual GameObject menu.
29772984
/// </summary>
@@ -3020,7 +3027,7 @@ static void OnGameObjectWithTimelineContextClick(MenuCommand command)
30203027
GameObject atObject = pd.GetGenericBinding(output.sourceObject) as GameObject;
30213028
// One file by animation clip
30223029
foreach (TimelineClip timeLineClip in at.GetClips()) {
3023-
string filePath = folderPath + "/" + atObject.name + "@" + timeLineClip.animationClip.name + ".fbx";
3030+
string filePath = string.Format(AnimFbxFileFormat, folderPath, atObject.name, timeLineClip.animationClip.name);
30243031
UnityEngine.Object[] myArray = new UnityEngine.Object[] { atObject, timeLineClip.animationClip };
30253032
ExportObjects (filePath, myArray, AnimationExportType.timelineAnimationClip);
30263033

@@ -3484,6 +3491,13 @@ bool ExportMesh (GameObject gameObject, FbxNode fbxNode)
34843491

34853492
// If we're here, custom handling didn't work.
34863493
// Revert to default handling.
3494+
3495+
// if user doesn't want to export mesh colliders, and this gameobject doesn't have a renderer
3496+
// then don't export it.
3497+
if (!ExportSettings.instance.exportMeshNoRenderer && !gameObject.GetComponent<Renderer>()) {
3498+
return false;
3499+
}
3500+
34873501
var meshFilter = defaultComponent as MeshFilter;
34883502
if (meshFilter) {
34893503
var renderer = gameObject.GetComponent<Renderer>();

Assets/Integrations/Autodesk/maya/scripts/unityCommands.mel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,25 @@ proc string checkNamespaceNeedsUpdate(string $unitySet, string $unityFbxNamespac
129129
return $unityFbxNamespace;
130130
}
131131

132+
global proc string formValidObjectName(string $input)
133+
{
134+
string $output = "";
135+
for ($n = 1 ; $n < size($input)+1 ; $n++)
136+
{
137+
string $char = `substring $input $n $n`;
138+
// if starting with a number, add underscore before number
139+
if ($n == 1 && `match "[0-9]" $char` != "")
140+
$output += ("_"+$char);
141+
// if character is alphanumeric, or underscore, add character
142+
else if (`match "[a-zA-Z0-9\_]" $char` != "")
143+
$output += $char;
144+
// otherwise replace with underscore
145+
else
146+
$output += "_";
147+
}
148+
return $output;
149+
}
150+
132151
proc importFile(string $filePathStr){
133152
// get the global variables
134153
global string $UnityExportSets[];
@@ -154,6 +173,8 @@ proc importFile(string $filePathStr){
154173

155174
$fileNameWithoutExt = match("[^@]+", $fileNameWithoutExt);
156175
}
176+
$fileNameWithoutExt = formValidObjectName($fileNameWithoutExt);
177+
157178
$unityExportSet = `format -stringArg $fileNameWithoutExt $UnityExportSetNameFormat`;
158179

159180
string $origNamespace = `namespaceInfo -cur -an`;

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ endif()
2323
message(STATUS "Building for ${CMAKE_BUILD_TYPE}")
2424

2525
if (NOT DEFINED PACKAGE_VERSION OR "${PACKAGE_VERSION}" STREQUAL "")
26-
set(PACKAGE_VERSION "sprint46")
26+
set(PACKAGE_VERSION "sprint47")
2727
endif()
2828
message(STATUS "Using Package Version: ${PACKAGE_VERSION}")
2929

RELEASE_NOTES.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
RELEASE NOTES
22

3+
**Version**: sprint47
4+
5+
NEW FEATURES
6+
7+
* Unity Maya Integration: Add all imported objects to same namespace
8+
9+
Namespace is created according to the filename and is stored as an attribute on the export set.
10+
11+
* Fbx Exporter: "Export Model" option exports with global transform
12+
13+
Center Objects option is disabled by default but still available in the export settings.
14+
15+
* Fbx Export Settings: Add LOD export option
16+
17+
Added 3 options for LOD export: Highest, Lowest, All.
18+
If "Highest" is selected, then only highest LOD is exported in the hierarchy for GameObjects with LOD groups, and
19+
vice versa for "Lowest". If All is selected, behaviour will be the same as before, exporting all LODs.
20+
NOTE: will ignore any LOD meshes not directly parented under the object containing the LOD group.
21+
22+
FIXES
23+
24+
* ConvertToPrefab: Don't re-export fbx model instances
25+
26+
If the object being exported in the scene is an fbx model instance, then create the prefab with the FbxPrefab component,
27+
and attach it to the existing fbx without re-exporting the fbx.
28+
329
**Version**: sprint46
430

531
NEW FEATURES

meta/FbxExporters/RELEASE_NOTES.txt.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)