Skip to content

Commit 8badf0e

Browse files
author
AJubrey
committed
Merge branch 'master' into Uni-26011_Align_UI_better
# Conflicts: # Assets/FbxExporters/Editor/FbxExportSettings.cs
2 parents 14ca765 + 3988f76 commit 8badf0e

File tree

6 files changed

+91
-32
lines changed

6 files changed

+91
-32
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public override void OnInspectorGUI() {
2727
GUILayout.Label ("Version: " + version, EditorStyles.centeredGreyMiniLabel);
2828
EditorGUILayout.Space ();
2929
}
30-
30+
GUILayout.BeginVertical();
3131
exportSettings.mayaCompatibleNames = EditorGUILayout.Toggle (
3232
new GUIContent ("Convert to Maya Compatible Naming:",
3333
"In Maya some symbols such as spaces and accents get replaced when importing an FBX " +
@@ -93,17 +93,12 @@ public override void OnInspectorGUI() {
9393
GUILayout.Label (new GUIContent (
9494
"3D Application:",
9595
"Select the 3D Application for which you would like to install the Unity integration."), GUILayout.Width(LabelWidth - 3));
96-
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("Browse", EditorStyles.miniButton, GUILayout.Width(BrowseButtonWidth))) {
107102
var ext = "";
108103
switch (Application.platform) {
109104
case RuntimePlatform.WindowsEditor:
@@ -129,7 +124,6 @@ public override void OnInspectorGUI() {
129124
// Therefore check both executable folder (for Mac) and its parent (for Windows)
130125
if (md.Name.ToLower().StartsWith("mayalt") || md.Parent.Name.ToLower ().StartsWith ("mayalt")) {
131126
Debug.LogError (string.Format("Unity Integration does not support Maya LT: \"{0}\"", md.FullName));
132-
exportSettings.selectedDCCApp = oldValue;
133127
return;
134128
}
135129

@@ -143,14 +137,11 @@ public override void OnInspectorGUI() {
143137
}
144138
if (foundDCCPath == null) {
145139
Debug.LogError (string.Format ("Could not find supported 3D application at: \"{0}\"", Path.GetDirectoryName (dccPath)));
146-
exportSettings.selectedDCCApp = oldValue;
147140
} else {
148141
dccPath = foundDCCPath;
149142
ExportSettings.AddDCCOption (dccPath, foundDCC);
150143
}
151144
Repaint ();
152-
} else {
153-
exportSettings.selectedDCCApp = oldValue;
154145
}
155146
}
156147
GUILayout.EndHorizontal ();
@@ -162,8 +153,15 @@ public override void OnInspectorGUI() {
162153
FbxExporters.Editor.IntegrationsUI.InstallDCCIntegration ();
163154
}
164155

156+
exportSettings.launchAfterInstallation = EditorGUILayout.Toggle(
157+
new GUIContent("Launch 3D Application:",
158+
"Launch the selected application after unity integration is completed."),
159+
exportSettings.launchAfterInstallation
160+
);
161+
165162
GUILayout.FlexibleSpace ();
166163
GUILayout.EndScrollView ();
164+
GUILayout.EndVertical();
167165

168166
if (GUI.changed) {
169167
EditorUtility.SetDirty (exportSettings);
@@ -247,6 +245,7 @@ public static string kDefaultAdskRoot {
247245
// Note: default values are set in LoadDefaults().
248246
public bool mayaCompatibleNames;
249247
public bool centerObjects;
248+
public bool launchAfterInstallation;
250249

251250
public int selectedDCCApp = 0;
252251

@@ -274,6 +273,7 @@ protected override void LoadDefaults()
274273
{
275274
mayaCompatibleNames = true;
276275
centerObjects = true;
276+
launchAfterInstallation = true;
277277
convertToModelSavePath = kDefaultSavePath;
278278
dccOptionPaths = null;
279279
dccOptionNames = null;
@@ -550,19 +550,17 @@ public static GUIContent[] GetDCCOptions(){
550550

551551
if (instance.dccOptionPaths.Count <= 0) {
552552
return new GUIContent[]{
553-
new GUIContent("<No 3D Application found>"),
554-
new GUIContent("Browse...")
553+
new GUIContent("<No 3D Application found>")
555554
};
556555
}
557556

558-
GUIContent[] optionArray = new GUIContent[instance.dccOptionPaths.Count+1];
557+
GUIContent[] optionArray = new GUIContent[instance.dccOptionPaths.Count];
559558
for(int i = 0; i < instance.dccOptionPaths.Count; i++){
560559
optionArray [i] = new GUIContent(
561560
instance.dccOptionNames[i],
562561
instance.dccOptionPaths[i]
563562
);
564563
}
565-
optionArray [optionArray.Length - 1] = new GUIContent("Browse...");
566564

567565
return optionArray;
568566
}

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

@@ -117,10 +133,14 @@ private static string ESCAPED_QUOTE {
117133
}
118134
}
119135

120-
private static string MAYA_COMMANDS { get {
121-
return string.Format("configureUnityFbxForMaya {0}{1}{0} {0}{2}{0} {0}{3}{0} {0}{4}{0} {0}{5}{0} {6}; scriptJob -idleEvent quit;",
136+
private static string MAYA_CONFIG_COMMAND { get {
137+
return string.Format("configureUnityFbxForMaya {0}{1}{0} {0}{2}{0} {0}{3}{0} {0}{4}{0} {0}{5}{0} {6};",
122138
ESCAPED_QUOTE, GetProjectPath(), GetAppPath(), GetTempSavePath(),
123-
GetExportSettingsPath(), GetMayaInstructionPath(), (IsHeadlessInstall()?1:0));
139+
GetExportSettingsPath(), GetMayaInstructionPath(), (IsHeadlessInstall() ? 1 : 0));
140+
}}
141+
142+
private static string MAYA_CLOSE_COMMAND { get {
143+
return string.Format("scriptJob -idleEvent quit;");
124144
}}
125145
private static Char[] FIELD_SEPARATORS = new Char[] {':'};
126146

@@ -307,24 +327,45 @@ public static int ConfigureMaya(string mayaPath)
307327
myProcess.StartInfo.CreateNoWindow = true;
308328
myProcess.StartInfo.UseShellExecute = false;
309329

330+
string commandString;
331+
310332
switch (Application.platform) {
311333
case RuntimePlatform.WindowsEditor:
312-
myProcess.StartInfo.Arguments = string.Format("-command \"{0}\"", MAYA_COMMANDS);
334+
commandString = "-command \"{0}\"";
313335
break;
314336
case RuntimePlatform.OSXEditor:
315-
myProcess.StartInfo.Arguments = string.Format(@"-command '{0}'", MAYA_COMMANDS);
337+
commandString = @"-command '{0}'";
316338
break;
317339
default:
318340
throw new NotImplementedException ();
319341
}
320342

343+
if (EditorTools.ExportSettings.instance.launchAfterInstallation)
344+
{
345+
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
346+
myProcess.StartInfo.CreateNoWindow = false;
347+
myProcess.StartInfo.Arguments = string.Format(commandString, MAYA_CONFIG_COMMAND);
348+
}
349+
else
350+
{
351+
myProcess.StartInfo.Arguments = string.Format(commandString, MAYA_CONFIG_COMMAND + MAYA_CLOSE_COMMAND);
352+
}
353+
321354
myProcess.EnableRaisingEvents = true;
322355
myProcess.Start();
323-
myProcess.WaitForExit();
324-
ExitCode = myProcess.ExitCode;
325-
Debug.Log(string.Format("Ran maya: [{0}]\nWith args [{1}]\nResult {2}",
326-
mayaPath, myProcess.StartInfo.Arguments, ExitCode));
327-
}
356+
357+
if (!EditorTools.ExportSettings.instance.launchAfterInstallation)
358+
{
359+
myProcess.WaitForExit();
360+
ExitCode = myProcess.ExitCode;
361+
Debug.Log(string.Format("Ran maya: [{0}]\nWith args [{1}]\nResult {2}",
362+
mayaPath, myProcess.StartInfo.Arguments, ExitCode));
363+
}
364+
else
365+
{
366+
ExitCode = 0;
367+
}
368+
}
328369
catch (Exception e)
329370
{
330371
UnityEngine.Debug.LogError(string.Format ("Exception failed to start Maya ({0})", e.Message));
@@ -532,8 +573,13 @@ public static int InstallMaxPlugin(string maxExe){
532573
myProcess.WaitForExit();
533574
ExitCode = myProcess.ExitCode;
534575

576+
if (EditorTools.ExportSettings.instance.launchAfterInstallation)
577+
{
578+
LaunchDCCApplication(maxExe);
579+
}
580+
535581
// TODO (UNI-29910): figure out what exactly causes this exit code + how to resolve
536-
if(ExitCode == -1073740791){
582+
if (ExitCode == -1073740791){
537583
Debug.Log(string.Format("Detected 3ds max exitcode {0} -- safe to ignore", ExitCode));
538584
ExitCode = 0;
539585
}
@@ -545,7 +591,7 @@ public static int InstallMaxPlugin(string maxExe){
545591
{
546592
UnityEngine.Debug.LogError(string.Format ("Exception failed to start Max ({0})", e.Message));
547593
ExitCode = -1;
548-
}
594+
}
549595
return ExitCode;
550596
}
551597

Binary file not shown.

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

Lines changed: 3 additions & 3 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 (
@@ -203,7 +203,7 @@ if (maxVersion())[1] >= 20000 then(
203203
(
204204
global unityImportAction = createUnityImportAction unityImportTitle importMenu
205205
global unityExportAction = createUnityExportAction unityExportTitle exportMenu
206-
206+
207207
menuMan.updateMenuBar() --update the menu bar
208208
)
209209
)

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)