Skip to content

Commit 1888b33

Browse files
authored
Merge pull request #44 from Unity-Technologies/Uni-21365-make-video
Uni-21365 tweak cmdline install
2 parents e28e7d1 + 4d75616 commit 1888b33

File tree

3 files changed

+62
-38
lines changed

3 files changed

+62
-38
lines changed

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace FbxExporters
77
{
88
class Integrations
99
{
10-
private const string MAYA_VERSION = "2017";
10+
public const string MAYA_VERSION = "2017";
1111
private const string MODULE_FILENAME = "unityoneclick.mod";
1212
private const string PACKAGE_NAME = "FbxExporters";
1313
private const string VERSION_FILENAME = "README.txt";
@@ -154,23 +154,23 @@ private static void WriteFile(string FileName, List<string> Lines )
154154
}
155155
}
156156

157-
private static void _InstallMaya2017(bool verbose=true, bool commandsOnly=false)
157+
public static bool InstallMaya(string version, bool verbose=true, bool commandsOnly=false)
158158
{
159159
// check if package installed
160-
string moduleTemplatePath = GetModuleTemplatePath(MAYA_VERSION);
160+
string moduleTemplatePath = GetModuleTemplatePath(version);
161161

162162
if (!System.IO.File.Exists(moduleTemplatePath))
163163
{
164164
Debug.LogError(string.Format("FbxExporters package not installed, please install first"));
165-
return;
165+
return false;
166166
}
167167

168168
// TODO: detect maya2017 installation
169169

170170
// TODO: if not maya2017 installed warn user
171171

172172
// check for {USER} modules folder
173-
string modulePath = GetModulePath(MAYA_VERSION);
173+
string modulePath = GetModulePath(version);
174174

175175
string moduleFilePath = System.IO.Path.Combine( modulePath, MODULE_FILENAME);
176176

@@ -187,12 +187,12 @@ private static void _InstallMaya2017(bool verbose=true, bool commandsOnly=false)
187187
catch
188188
{
189189
Debug.LogError(string.Format("Failed to create Maya Modules Folder {0}", modulePath));
190-
return;
190+
return false;
191191
}
192192

193193
if (!System.IO.Directory.Exists(modulePath)) {
194194
Debug.LogError(string.Format("Failed to create Maya Modules Folder {0}", modulePath));
195-
return;
195+
return false;
196196
}
197197

198198
installed = false;
@@ -253,41 +253,57 @@ private static void _InstallMaya2017(bool verbose=true, bool commandsOnly=false)
253253

254254
// TODO: configure maya to auto-load plugin on next startup
255255

256+
return true;
256257
}
257258

258259
public static void InstallMaya2017()
259260
{
260-
bool verbose=true;
261+
const bool verbose = true;
262+
const bool commandsOnly = false;
263+
const string version = Integrations.MAYA_VERSION;
261264

262-
Debug.Log(string.Format("Installing Maya {0} Integration",MAYA_VERSION));
265+
Debug.Log(string.Format("Installing Maya {0} Integration", version));
263266

264-
_InstallMaya2017(verbose);
265-
266-
if (verbose) Debug.Log(string.Format("Finished installing Maya {0} Integration.",MAYA_VERSION));
267+
if (InstallMaya (version, verbose, commandsOnly)) {
268+
if (verbose) Debug.Log (string.Format ("Completed installation of Maya {0} Integration.", version));
269+
} else {
270+
if (verbose) Debug.Log (string.Format ("Failed to install Maya {0} Integration.", version));
271+
}
267272
}
268273

269-
public static void InstallMaya2017CommandsOnly()
274+
public static void InstallMaya2017CommandsOnly ()
270275
{
271-
bool verbose=true;
272-
273-
Debug.Log(string.Format("Installing Maya {0} Integration Commands Only",MAYA_VERSION));
276+
const bool verbose = true;
277+
const bool commandsOnly = true;
278+
const string version = Integrations.MAYA_VERSION;
274279

275-
_InstallMaya2017(verbose, true);
280+
Debug.Log (string.Format ("Installing Maya {0} Integration (Commands Only).", version));
276281

277-
if (verbose) Debug.Log(string.Format("Finished installing Maya {0} Integration Commands Only.",MAYA_VERSION));
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+
}
278287
}
279288
}
280289

281290
namespace Editors
282291
{
283292
class IntegrationsUI
284293
{
285-
const string MenuItemName = "FbxExporters/Install Maya2017 Integration";
294+
const string MenuItemName = "FbxExporters/Install Maya" + Integrations.MAYA_VERSION + " Integration" ;
286295

287296
[MenuItem (MenuItemName, false, 0)]
288297
public static void OnMenuItem ()
289298
{
290-
Integrations.InstallMaya2017();
299+
if (Integrations.InstallMaya(Integrations.MAYA_VERSION, true, false))
300+
{
301+
string title = string.Format("Completed installation of Maya {0} Integration.", Integrations.MAYA_VERSION);
302+
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";
303+
304+
EditorUtility.DisplayDialog (title, message, "Ok");
305+
Debug.Log(message);
306+
}
291307
}
292308
}
293309
}

Assets/FbxExporters/README.txt

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ Copyright (c) 2017 Unity Technologies. All rights reserved.
55
Licensed under the ##LICENSENAME##.
66
See LICENSE.md file for full license information.
77

8-
**Version**: 0.0.5a
8+
**Version**: 0.0.6a-sprint17
99

1010
Requirements
1111
------------
1212

13-
* [FBX SDK C# Bindings v0.0.4a or higher](https://github.com/Unity-Technologies/FbxSharp)
13+
* [FBX SDK C# Bindings](https://github.com/Unity-Technologies/FbxSharp)
1414

1515
Command-line Installing Maya2017 Integration
1616
--------------------------------------------
@@ -19,25 +19,33 @@ You can install the package and integrations from the command-line using the fol
1919

2020
MacOS:
2121

22-
export UNITY3D_PATH=/Applications/Unity\ 2017.1.0f3/Unity.app/Contents/MacOS/Unity
22+
# Configure where Unity is installed
23+
# UNITY3D_VERSION=" 2017.1.0f3"
24+
UNITY3D_PATH="/Applications/Unity${UNITY3D_VERSION}/Unity.app/Contents/MacOS/Unity"
2325

24-
export PROJECT_PATH=~/Development/FbxExporters
25-
export PACKAGE_NAME=FbxExporters
26-
export PACKAGE_VERSION={CurrentVersion}
27-
export FBXEXPORTERS_PACKAGE_PATH=${PROJECT_PATH}/${PACKAGE_NAME}_${PACKAGE_VERSION}.unitypackage
26+
# Configure where unitypackage is located
27+
PACKAGE_PATH=`ls -t ~/Development/FbxExporters/FbxExporters_*.unitypackage | head -1`
2828

29-
# must be non-batch to import correctly
30-
"${UNITY3D_PATH}" -projectPath "${PROJECT_PATH}" -importPackage ${FBXEXPORTERS_PACKAGE_PATH} -quit
29+
# Configure which Unity project to install package
30+
PROJECT_PATH=~/Development/FbxExporters
3131

32-
# Use "InstallMaya2017CommandsOnly" to install without UI
33-
"${UNITY3D_PATH}" -batchMode -projectPath "${PROJECT_PATH}" -executeMethod FbxExporters.Integrations.InstallMaya2017 -quit
32+
if [ ! -f "${UNITY3D_PATH}" ]; then
33+
echo "Unity is not installed"
34+
else
35+
# Install FbxExporters package
36+
"${UNITY3D_PATH}" -projectPath "${PROJECT_PATH}" -importPackage ${PACKAGE_PATH} -quit
3437

35-
Configuring Auto-loading of plugin in Maya2017
36-
----------------------------------------------
38+
# Install Maya2017 Integration
39+
# Use "InstallMaya2017CommandsOnly" to install without UI
40+
"${UNITY3D_PATH}" -batchMode -projectPath "${PROJECT_PATH}" -executeMethod FbxExporters.Integrations.InstallMaya2017 -quit
3741

38-
MacOS:
39-
40-
export MAYA_PATH=/Applications/Autodesk/maya2017/Maya.app/Contents/bin/maya
42+
# Configuring Maya2017 to auto-load integration
43+
MAYA_PATH=/Applications/Autodesk/maya2017/Maya.app/Contents/bin/maya
4144

42-
"${MAYA_PATH}" -command "loadPlugin unityOneClickPlugin; pluginInfo -edit -autoload true unityOneClickPlugin;quit;"
45+
if [ ! -f "${MAYA_PATH}" ]; then
46+
echo "Maya2017 not installed"
47+
else
48+
"${MAYA_PATH}" -command "loadPlugin unityOneClickPlugin; pluginInfo -edit -autoload true unityOneClickPlugin; quit;"
49+
fi
50+
fi
4351

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ else
3535
UNITY_EDITOR_PATH=/opt/Unity/Editor/Unity/Unity
3636
fi
3737
"${UNITY_EDITOR_PATH}" -projectPath "${PROJECT_PATH}" -importPackage "${FBXSDK_PACKAGE_PATH}" -quit
38-
"${UNITY_EDITOR_PATH}" -batchmode -projectPath "${PROJECT_PATH}" -exportPackage Assets/FbxExporters Assets/FbxSdk "${PROJECT_PATH}/FbxExporters_${PACKAGE_VERSION}.unitypackage" -quit
38+
"${UNITY_EDITOR_PATH}" -batchmode -projectPath "${PROJECT_PATH}" -exportPackage Assets/FbxExporters Assets/FbxSdk Assets/Integrations "${PROJECT_PATH}/FbxExporters_${PACKAGE_VERSION}.unitypackage" -quit
3939
```
4040

4141
**On Windows**

0 commit comments

Comments
 (0)