Skip to content

Commit 3449934

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into UNI-29074-mayalt-plugin
# Conflicts: # Assets/FbxExporters/Editor/FbxExportSettings.cs # Assets/FbxExporters/Editor/InstallIntegration.cs
2 parents d904d75 + 51ea6a0 commit 3449934

File tree

6 files changed

+97
-37
lines changed

6 files changed

+97
-37
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace FbxExporters.EditorTools {
1010
[CustomEditor(typeof(ExportSettings))]
1111
public class ExportSettingsEditor : UnityEditor.Editor {
1212
Vector2 scrollPos = Vector2.zero;
13-
const float LabelWidth = 225;
14-
const float SelectableLabelMinWidth = 100;
15-
const float BrowseButtonWidth = 55;
13+
const float LabelWidth = 130;
14+
const float SelectableLabelMinWidth = 90;
15+
const float BrowseButtonWidth = 25;
1616

1717
public override void OnInspectorGUI() {
1818
ExportSettings exportSettings = (ExportSettings)target;
@@ -27,9 +27,9 @@ public override void OnInspectorGUI() {
2727
GUILayout.Label ("Version: " + version, EditorStyles.centeredGreyMiniLabel);
2828
EditorGUILayout.Space ();
2929
}
30-
30+
GUILayout.BeginVertical();
3131
exportSettings.mayaCompatibleNames = EditorGUILayout.Toggle (
32-
new GUIContent ("Convert to Maya Compatible Naming:",
32+
new GUIContent ("Compatible Naming:",
3333
"In Maya some symbols such as spaces and accents get replaced when importing an FBX " +
3434
"(e.g. \"foo bar\" becomes \"fooFBXASC032bar\"). " +
3535
"On export, convert the names of GameObjects so they are Maya compatible." +
@@ -48,7 +48,7 @@ public override void OnInspectorGUI() {
4848
GUILayout.BeginHorizontal ();
4949
GUILayout.Label (new GUIContent (
5050
"Export Path:",
51-
"Relative path for saving Model Prefabs."));
51+
"Relative path for saving Model Prefabs."), GUILayout.Width(LabelWidth - 3));
5252

5353
var pathLabel = ExportSettings.GetRelativeSavePath();
5454
if (pathLabel == ".") { pathLabel = "(Assets root)"; }
@@ -57,7 +57,7 @@ public override void OnInspectorGUI() {
5757
GUILayout.MinWidth(SelectableLabelMinWidth),
5858
GUILayout.Height(EditorGUIUtility.singleLineHeight));
5959

60-
if (GUILayout.Button ("Browse", EditorStyles.miniButton, GUILayout.Width (BrowseButtonWidth))) {
60+
if (GUILayout.Button (new GUIContent("...", "Browse to a new location for saving model prefabs"), EditorStyles.miniButton, GUILayout.Width (BrowseButtonWidth))) {
6161
string initialPath = ExportSettings.GetAbsoluteSavePath();
6262

6363
// if the directory doesn't exist, set it to the default save path
@@ -92,18 +92,13 @@ public override void OnInspectorGUI() {
9292
GUILayout.BeginHorizontal ();
9393
GUILayout.Label (new GUIContent (
9494
"3D Application:",
95-
"Select the 3D Application for which you would like to install the Unity integration."));
96-
95+
"Select the 3D Application for which you would like to install the Unity integration."), GUILayout.Width(LabelWidth - 3));
96+
9797
// dropdown to select Maya version to use
9898
var options = ExportSettings.GetDCCOptions();
99-
// make sure we never initially have browse selected
100-
if (exportSettings.selectedDCCApp == options.Length - 1) {
101-
exportSettings.selectedDCCApp = exportSettings.GetPreferredDCCApp();
102-
}
10399

104-
int oldValue = exportSettings.selectedDCCApp;
105100
exportSettings.selectedDCCApp = EditorGUILayout.Popup(exportSettings.selectedDCCApp, options);
106-
if (exportSettings.selectedDCCApp == options.Length - 1) {
101+
if (GUILayout.Button(new GUIContent("...", "Browse to a 3D application in a non-default location"), EditorStyles.miniButton, GUILayout.Width(BrowseButtonWidth))) {
107102
var ext = "";
108103
switch (Application.platform) {
109104
case RuntimePlatform.WindowsEditor:
@@ -128,14 +123,11 @@ public override void OnInspectorGUI() {
128123
}
129124
if (foundDCCPath == null) {
130125
Debug.LogError (string.Format ("Could not find supported 3D application at: \"{0}\"", Path.GetDirectoryName (dccPath)));
131-
exportSettings.selectedDCCApp = oldValue;
132126
} else {
133127
dccPath = foundDCCPath;
134128
ExportSettings.AddDCCOption (dccPath, foundDCC);
135129
}
136130
Repaint ();
137-
} else {
138-
exportSettings.selectedDCCApp = oldValue;
139131
}
140132
}
141133
GUILayout.EndHorizontal ();
@@ -147,8 +139,15 @@ public override void OnInspectorGUI() {
147139
FbxExporters.Editor.IntegrationsUI.InstallDCCIntegration ();
148140
}
149141

142+
exportSettings.launchAfterInstallation = EditorGUILayout.Toggle(
143+
new GUIContent("Launch 3D Application:",
144+
"Launch the selected application after unity integration is completed."),
145+
exportSettings.launchAfterInstallation
146+
);
147+
150148
GUILayout.FlexibleSpace ();
151149
GUILayout.EndScrollView ();
150+
GUILayout.EndVertical();
152151

153152
if (GUI.changed) {
154153
EditorUtility.SetDirty (exportSettings);
@@ -232,6 +231,7 @@ public static string kDefaultAdskRoot {
232231
// Note: default values are set in LoadDefaults().
233232
public bool mayaCompatibleNames;
234233
public bool centerObjects;
234+
public bool launchAfterInstallation;
235235

236236
public int selectedDCCApp = 0;
237237

@@ -259,6 +259,7 @@ protected override void LoadDefaults()
259259
{
260260
mayaCompatibleNames = true;
261261
centerObjects = true;
262+
launchAfterInstallation = true;
262263
convertToModelSavePath = kDefaultSavePath;
263264
dccOptionPaths = null;
264265
dccOptionNames = null;
@@ -530,19 +531,17 @@ public static GUIContent[] GetDCCOptions(){
530531

531532
if (instance.dccOptionPaths.Count <= 0) {
532533
return new GUIContent[]{
533-
new GUIContent("<No 3D Application found>"),
534-
new GUIContent("Browse...")
534+
new GUIContent("<No 3D Application found>")
535535
};
536536
}
537537

538-
GUIContent[] optionArray = new GUIContent[instance.dccOptionPaths.Count+1];
538+
GUIContent[] optionArray = new GUIContent[instance.dccOptionPaths.Count];
539539
for(int i = 0; i < instance.dccOptionPaths.Count; i++){
540540
optionArray [i] = new GUIContent(
541541
instance.dccOptionNames[i],
542542
instance.dccOptionPaths[i]
543543
);
544544
}
545-
optionArray [optionArray.Length - 1] = new GUIContent("Browse...");
546545

547546
return optionArray;
548547
}

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ public static string GetProjectPath()
6363
/// <returns><c>true</c> if folder is already unzipped at the specified path; otherwise, <c>false</c>.</returns>
6464
/// <param name="path">Path.</param>
6565
public abstract bool FolderAlreadyUnzippedAtPath (string path);
66+
67+
/// <summary>
68+
/// Launches application at given path
69+
/// </summary>
70+
/// <param name="AppPath"></param>
71+
public static void LaunchDCCApplication(string AppPath)
72+
{
73+
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
74+
myProcess.StartInfo.FileName = AppPath;
75+
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
76+
myProcess.StartInfo.CreateNoWindow = false;
77+
myProcess.StartInfo.UseShellExecute = false;
78+
79+
myProcess.EnableRaisingEvents = false;
80+
myProcess.Start();
81+
}
6682
}
6783

6884

@@ -122,10 +138,14 @@ protected static string ESCAPED_QUOTE {
122138
}
123139
}
124140

125-
protected virtual string MAYA_COMMANDS { get {
126-
return string.Format("configureUnityFbxForMaya {0}{1}{0} {0}{2}{0} {0}{3}{0} {0}{4}{0} {0}{5}{0} {6}; scriptJob -idleEvent quit;",
141+
protected virtual string MAYA_CONFIG_COMMAND { get {
142+
return string.Format("configureUnityFbxForMaya {0}{1}{0} {0}{2}{0} {0}{3}{0} {0}{4}{0} {0}{5}{0} {6};",
127143
ESCAPED_QUOTE, GetProjectPath(), GetAppPath(), GetTempSavePath(),
128-
GetExportSettingsPath(), GetMayaInstructionPath(), (IsHeadlessInstall()?1:0));
144+
GetExportSettingsPath(), GetMayaInstructionPath(), (IsHeadlessInstall() ? 1 : 0));
145+
}}
146+
147+
private static string MAYA_CLOSE_COMMAND { get {
148+
return string.Format("scriptJob -idleEvent quit;");
129149
}}
130150
private static Char[] FIELD_SEPARATORS = new Char[] {':'};
131151

@@ -332,24 +352,45 @@ public int ConfigureMaya(string mayaPath)
332352
myProcess.StartInfo.CreateNoWindow = true;
333353
myProcess.StartInfo.UseShellExecute = false;
334354

355+
string commandString;
356+
335357
switch (Application.platform) {
336358
case RuntimePlatform.WindowsEditor:
337-
myProcess.StartInfo.Arguments = string.Format("-command \"{0}\"", MAYA_COMMANDS);
359+
commandString = "-command \"{0}\"";
338360
break;
339361
case RuntimePlatform.OSXEditor:
340-
myProcess.StartInfo.Arguments = string.Format(@"-command '{0}'", MAYA_COMMANDS);
362+
commandString = @"-command '{0}'";
341363
break;
342364
default:
343365
throw new NotImplementedException ();
344366
}
345367

368+
if (EditorTools.ExportSettings.instance.launchAfterInstallation)
369+
{
370+
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
371+
myProcess.StartInfo.CreateNoWindow = false;
372+
myProcess.StartInfo.Arguments = string.Format(commandString, MAYA_CONFIG_COMMAND);
373+
}
374+
else
375+
{
376+
myProcess.StartInfo.Arguments = string.Format(commandString, MAYA_CONFIG_COMMAND + MAYA_CLOSE_COMMAND);
377+
}
378+
346379
myProcess.EnableRaisingEvents = true;
347380
myProcess.Start();
348-
myProcess.WaitForExit();
349-
ExitCode = myProcess.ExitCode;
350-
Debug.Log(string.Format("Ran maya: [{0}]\nWith args [{1}]\nResult {2}",
351-
mayaPath, myProcess.StartInfo.Arguments, ExitCode));
352-
}
381+
382+
if (!EditorTools.ExportSettings.instance.launchAfterInstallation)
383+
{
384+
myProcess.WaitForExit();
385+
ExitCode = myProcess.ExitCode;
386+
Debug.Log(string.Format("Ran maya: [{0}]\nWith args [{1}]\nResult {2}",
387+
mayaPath, myProcess.StartInfo.Arguments, ExitCode));
388+
}
389+
else
390+
{
391+
ExitCode = 0;
392+
}
393+
}
353394
catch (Exception e)
354395
{
355396
UnityEngine.Debug.LogError(string.Format ("Exception failed to start Maya ({0})", e.Message));
@@ -652,8 +693,13 @@ public static int InstallMaxPlugin(string maxExe){
652693
myProcess.WaitForExit();
653694
ExitCode = myProcess.ExitCode;
654695

696+
if (EditorTools.ExportSettings.instance.launchAfterInstallation)
697+
{
698+
LaunchDCCApplication(maxExe);
699+
}
700+
655701
// TODO (UNI-29910): figure out what exactly causes this exit code + how to resolve
656-
if(ExitCode == -1073740791){
702+
if (ExitCode == -1073740791){
657703
Debug.Log(string.Format("Detected 3ds max exitcode {0} -- safe to ignore", ExitCode));
658704
ExitCode = 0;
659705
}
@@ -665,7 +711,7 @@ public static int InstallMaxPlugin(string maxExe){
665711
{
666712
UnityEngine.Debug.LogError(string.Format ("Exception failed to start Max ({0})", e.Message));
667713
ExitCode = -1;
668-
}
714+
}
669715
return ExitCode;
670716
}
671717

Binary file not shown.

Assets/Integrations/Autodesk/max/scripts/UnityFbxForMaxPlugin.ms

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- MacroScripts that will perform actions
2-
macroScript UnityImport category:"Unity"
2+
macroScript UnityImport category:"Unity" tooltip:"Import FBX file from Unity project and auto-configure for exporting."
33
(
44
origObjects = #()
55

@@ -82,7 +82,7 @@ macroScript UnityImport category:"Unity"
8282
callbacks.removeScripts #postImport id:#unityPlugin
8383
)
8484
)
85-
macroScript UnityExport category:"Unity"
85+
macroScript UnityExport category:"Unity" tooltip:"Export a model to Unity"
8686
(
8787
fn unitToScaleFactor unit = (
8888
case unit of (

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 "sprint32")
26+
set(PACKAGE_VERSION "1.1.0b1")
2727
endif()
2828
message(STATUS "Using Package Version: ${PACKAGE_VERSION}")
2929

RELEASE_NOTES.md

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

3+
**Version**: 1.1.0b1
4+
5+
NEW FEATURES
6+
7+
* Export Settings: Set application with latest version as default selection in 3D application dropdown
8+
9+
In case of a tie, use the following preference order: Maya > Maya LT > 3ds Max > Blender.
10+
11+
* Updated user documentation
12+
13+
FIXES
14+
15+
* Exporter: Fix FBX exported from Unity causing crash when imported in 3ds Max.
16+
* Export Settings: Fix hang when adding multiple installations of the same version of a 3D application to the dropdown
17+
318
**Version**: sprint32
419

520
NEW FEATURES

0 commit comments

Comments
 (0)