Skip to content

Commit a40b4f3

Browse files
authored
Merge pull request #47 from Unity-Technologies/Uni-21773-headless-install
Uni 21773 headless install
2 parents 1888b33 + 39a2cf5 commit a40b4f3

File tree

3 files changed

+13
-32
lines changed

3 files changed

+13
-32
lines changed

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private static void WriteFile(string FileName, List<string> Lines )
154154
}
155155
}
156156

157-
public static bool InstallMaya(string version, bool verbose=true, bool commandsOnly=false)
157+
public static bool InstallMaya(string version, bool verbose=true)
158158
{
159159
// check if package installed
160160
string moduleTemplatePath = GetModuleTemplatePath(version);
@@ -165,10 +165,6 @@ public static bool InstallMaya(string version, bool verbose=true, bool commandsO
165165
return false;
166166
}
167167

168-
// TODO: detect maya2017 installation
169-
170-
// TODO: if not maya2017 installed warn user
171-
172168
// check for {USER} modules folder
173169
string modulePath = GetModulePath(version);
174170

@@ -248,43 +244,22 @@ public static bool InstallMaya(string version, bool verbose=true, bool commandsO
248244
// TODO: print message package already installed else where
249245
}
250246

251-
if (commandsOnly)
252-
throw new NotImplementedException();
253-
254-
// TODO: configure maya to auto-load plugin on next startup
255-
256247
return true;
257248
}
258249

259250
public static void InstallMaya2017()
260251
{
261252
const bool verbose = true;
262-
const bool commandsOnly = false;
263253
const string version = Integrations.MAYA_VERSION;
264254

265255
Debug.Log(string.Format("Installing Maya {0} Integration", version));
266256

267-
if (InstallMaya (version, verbose, commandsOnly)) {
257+
if (InstallMaya (version, verbose)) {
268258
if (verbose) Debug.Log (string.Format ("Completed installation of Maya {0} Integration.", version));
269259
} else {
270260
if (verbose) Debug.Log (string.Format ("Failed to install Maya {0} Integration.", version));
271261
}
272262
}
273-
274-
public static void InstallMaya2017CommandsOnly ()
275-
{
276-
const bool verbose = true;
277-
const bool commandsOnly = true;
278-
const string version = Integrations.MAYA_VERSION;
279-
280-
Debug.Log (string.Format ("Installing Maya {0} Integration (Commands Only).", version));
281-
282-
if (InstallMaya (version, verbose, commandsOnly)) {
283-
if (verbose) Debug.Log (string.Format ("Completed installation of Maya {0} Integration (Commands Only).", version));
284-
} else {
285-
if (verbose) Debug.Log (string.Format ("Failed to install Maya {0} Integration (Commands Only).", version));
286-
}
287-
}
288263
}
289264

290265
namespace Editors
@@ -296,7 +271,7 @@ class IntegrationsUI
296271
[MenuItem (MenuItemName, false, 0)]
297272
public static void OnMenuItem ()
298273
{
299-
if (Integrations.InstallMaya(Integrations.MAYA_VERSION, true, false))
274+
if (Integrations.InstallMaya(Integrations.MAYA_VERSION))
300275
{
301276
string title = string.Format("Completed installation of Maya {0} Integration.", Integrations.MAYA_VERSION);
302277
string message = "Please run the following MEL commands to configure auto-loading of the plugin in Maya.\n\nloadPlugin unityOneClickPlugin; pluginInfo -edit -autoload true unityOneClickPlugin;\n";

Assets/FbxExporters/README.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ else
3636
"${UNITY3D_PATH}" -projectPath "${PROJECT_PATH}" -importPackage ${PACKAGE_PATH} -quit
3737

3838
# Install Maya2017 Integration
39-
# Use "InstallMaya2017CommandsOnly" to install without UI
4039
"${UNITY3D_PATH}" -batchMode -projectPath "${PROJECT_PATH}" -executeMethod FbxExporters.Integrations.InstallMaya2017 -quit
4140

4241
# Configuring Maya2017 to auto-load integration
@@ -45,7 +44,8 @@ else
4544
if [ ! -f "${MAYA_PATH}" ]; then
4645
echo "Maya2017 not installed"
4746
else
48-
"${MAYA_PATH}" -command "loadPlugin unityOneClickPlugin; pluginInfo -edit -autoload true unityOneClickPlugin; quit;"
47+
# To configure without user interface prepend the following command: optionVar -intValue \"UnityOneClick_Headless\" 1;
48+
"${MAYA_PATH}" -command "optionVar -intValue \"UnityOneClick_Headless\" 1; loadPlugin unityOneClickPlugin; pluginInfo -edit -autoload true unityOneClickPlugin; quit;"
4949
fi
5050
fi
5151

Assets/Integrations/Autodesk/maya2017/plug-ins/unityOneClickPlugin.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
import sys
1919

2020
import maya.OpenMayaMPx as OpenMayaMPx
21+
import maya.cmds
2122

2223
from unityOneClick import (version, commands, ui, debug)
2324

2425
kPluginInfo = { 'name': version.pluginName(), 'version': version.versionName(), 'vendor': version.vendorName() }
2526
kVerbose = True
27+
kHeadlessInstall = maya.cmds.optionVar( exists='UnityOneClick_Headless' )
2628

2729
# initialize the script plug-in
2830
def initializePlugin(mobject):
@@ -32,7 +34,9 @@ def initializePlugin(mobject):
3234
sys.stdout.write('loading %s\n'%kPluginInfo['name'])
3335

3436
commands.register(pluginFn)
35-
ui.register(pluginFn)
37+
38+
if not kHeadlessInstall:
39+
ui.register(pluginFn)
3640

3741
except Exception as e:
3842
assert isinstance(sys.stderr.write, object)
@@ -46,7 +50,9 @@ def uninitializePlugin(mobject):
4650
if debug.EnableDebugMessages:
4751
sys.stdout.write('unloading %s\n'%kPluginInfo['name'])
4852

49-
ui.unregister(pluginFn)
53+
if not kHeadlessInstall:
54+
ui.unregister(pluginFn)
55+
5056
commands.unregister(pluginFn)
5157

5258
except:

0 commit comments

Comments
 (0)