Skip to content

Commit 449bf51

Browse files
committed
CR changes
1 parent 4036da4 commit 449bf51

File tree

16 files changed

+91
-2014
lines changed

16 files changed

+91
-2014
lines changed

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 72 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,33 @@
88

99
namespace FbxExporters
1010
{
11-
class Integrations
12-
{
11+
class Integrations
12+
{
13+
const string MenuItemName = "FbxExporters/Install Maya2017 Integration";
14+
15+
private const string MAYA_VERSION = "2017";
16+
private const string MODULE_FILENAME = "unityoneclick.mod";
1317
private const string PACKAGE_NAME = "FbxExporters";
1418
private const string VERSION_FILENAME = "README.txt";
1519
private const string VERSION_FIELD = "**Version**";
20+
private const string VERSION_TAG = "{Version}";
21+
private const string PROJECT_TAG = "{UnityProject}";
22+
1623
private static Char[] FIELD_SEPARATORS = new Char[] {':'};
1724

18-
private const string REL_MODULE_TEMPLATE_PATH = "Integrations/Autodesk/maya<version>/unityoneclick.mod";
25+
private const string MODULE_TEMPLATE_PATH = "Integrations/Autodesk/maya"+VERSION_TAG+"/unityoneclick.mod";
1926

20-
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
21-
private const string REL_MAYA_MODULES_PATH = "Library/Preferences/Autodesk/Maya/<version>/modules";
22-
#elif UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
23-
private const string REL_MAYA_MODULES_PATH = "Maya/<version>/modules";
27+
#if UNITY_EDITOR_OSX
28+
private const string REL_MAYA_MODULES_PATH = "Library/Preferences/Autodesk/Maya/"+VERSION_TAG+"/modules";
29+
#elif UNITY_EDITOR_LINUX
30+
private const string REL_MAYA_MODULES_PATH = "Maya/"+VERSION_TAG+"/modules";
2431
#else
25-
private const string REL_MAYA_MODULES_PATH = "My Documents/Maya/<version>/modules";
32+
private const string REL_MAYA_MODULES_PATH = "My Documents/Maya/"+VERSION_TAG+"/modules";
2633
#endif
2734

2835
private static string GetUserFolder()
2936
{
30-
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX
37+
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_EDITOR_LINUX
3138
return System.Environment.GetEnvironmentVariable("HOME");
3239
#else
3340
return System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)
@@ -38,14 +45,14 @@ private static string GetModulePath(string version)
3845
{
3946
string result = System.IO.Path.Combine(GetUserFolder(), REL_MAYA_MODULES_PATH);
4047

41-
return result.Replace("<version>",version);
48+
return result.Replace(VERSION_TAG,version);
4249
}
4350

4451
private static string GetModuleTemplatePath(string version)
4552
{
46-
string result = System.IO.Path.Combine(Application.dataPath, REL_MODULE_TEMPLATE_PATH);
53+
string result = System.IO.Path.Combine(Application.dataPath, MODULE_TEMPLATE_PATH);
4754

48-
return result.Replace("<version>",version);
55+
return result.Replace(VERSION_TAG,version);
4956
}
5057

5158
private static string GetProjectPath()
@@ -152,21 +159,11 @@ private static void WriteFile(string FileName, List<string> Lines )
152159
}
153160
}
154161

155-
#if DEBUG_INSTALLER
156-
const string MenuItemName = "File/Install Maya2017 Integration";
157-
[MenuItem (MenuItemName, false)]
158-
public static void OnMenuItem ()
159-
{
160-
InstallMaya2017 ();
161-
}
162-
#endif
163-
164-
public static void InstallMaya2017()
162+
private static void _InstallMaya2017(bool verbose=true, bool commandsOnly=false)
165163
{
166-
Debug.Log("Installing Maya2017 Integration");
167-
168164
// check if package installed
169-
string moduleTemplatePath = GetModuleTemplatePath("2017");
165+
string moduleTemplatePath = GetModuleTemplatePath(MAYA_VERSION);
166+
if (verbose) Debug.Log(moduleTemplatePath);
170167

171168
if (!System.IO.File.Exists(moduleTemplatePath))
172169
{
@@ -179,14 +176,16 @@ public static void InstallMaya2017()
179176
// TODO: if not maya2017 installed warn user
180177

181178
// check for {USER} modules folder
182-
string modulePath = GetModulePath("2017");
183-
string moduleFilePath = System.IO.Path.Combine( modulePath, "unityoneclick.mod");
179+
string modulePath = GetModulePath(MAYA_VERSION);
180+
if (verbose) Debug.Log(modulePath);
181+
182+
string moduleFilePath = System.IO.Path.Combine( modulePath, MODULE_FILENAME);
184183

185184
bool installed = false;
186185

187186
if (!System.IO.Directory.Exists(modulePath))
188187
{
189-
Debug.Log(string.Format("Creating Maya Modules Folder {0}", modulePath));
188+
if (verbose) Debug.Log(string.Format("Creating Maya Modules Folder {0}", modulePath));
190189

191190
try
192191
{
@@ -217,9 +216,9 @@ public static void InstallMaya2017()
217216
System.IO.File.Delete(moduleFilePath);
218217
installed = false;
219218
}
220-
catch
219+
catch
221220
{
222-
Debug.LogError(string.Format ("Failed to delete plugin module file {0}", moduleFilePath));
221+
Debug.LogWarning(string.Format ("Failed to delete plugin module file {0}", moduleFilePath));
223222
}
224223
}
225224
}
@@ -229,14 +228,14 @@ public static void InstallMaya2017()
229228
{
230229
Dictionary<string,string> Tokens = new Dictionary<string,string>()
231230
{
232-
{"{UnityOneClickVersion}", GetPackageVersion() },
233-
{"{UnityProject}", GetProjectPath() }
231+
{VERSION_TAG, GetPackageVersion() },
232+
{PROJECT_TAG, GetProjectPath() }
234233
};
235234

236235
// parse template, replace "{UnityProject}" with project path
237236
List<string> lines = ParseTemplateFile(moduleTemplatePath, Tokens);
238237

239-
Debug.Log(string.Format("Installing plugin module file: {0}",moduleFilePath));
238+
if (verbose) Debug.Log(string.Format("Installing plugin module file to {0}",moduleFilePath));
240239

241240
// write out .mod file
242241
WriteFile(moduleFilePath, lines);
@@ -256,9 +255,47 @@ public static void InstallMaya2017()
256255
// TODO: print message package already installed else where
257256
}
258257

258+
if (commandsOnly)
259+
throw new NotImplementedException();
260+
259261
// TODO: configure maya to auto-load plugin on next startup
260262

261-
Debug.Log("Finished installing Maya 2017 Integration.");
262263
}
263-
}
264+
265+
public static void InstallMaya2017()
266+
{
267+
bool verbose=true;
268+
269+
Debug.Log(string.Format("Installing Maya {0} Integration",MAYA_VERSION));
270+
271+
_InstallMaya2017(verbose);
272+
273+
if (verbose) Debug.Log(string.Format("Finished installing Maya {0} Integration.",MAYA_VERSION));
274+
}
275+
276+
public static void InstallMaya2017CommandsOnly()
277+
{
278+
bool verbose=true;
279+
280+
Debug.Log(string.Format("Installing Maya {0} Integration Commands Only",MAYA_VERSION));
281+
282+
_InstallMaya2017(verbose, true);
283+
284+
if (verbose) Debug.Log(string.Format("Finished installing Maya {0} Integration Commands Only.",MAYA_VERSION));
285+
}
286+
}
287+
288+
namespace Editors
289+
{
290+
class IntegrationsUI
291+
{
292+
const string MenuItemName = "FbxExporters/Install Maya2017 Integration";
293+
294+
[MenuItem (MenuItemName, false, 0)]
295+
public static void OnMenuItem ()
296+
{
297+
Integrations.InstallMaya2017();
298+
}
299+
}
300+
}
264301
}

Assets/FbxExporters/README.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Requirements
1212

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

15-
Installing Maya2017 Integration
16-
-------------------------------
15+
Command-line Installing Maya2017 Integration
16+
--------------------------------------------
1717

1818
You can install the package and integrations from the command-line using the following script:
1919

20-
MacOS / Ubuntu
20+
MacOS
2121

2222
export UNITY3D_PATH=/Applications/Unity\ 2017.1.0f3/Unity.app/Contents/MacOS/Unity
2323

@@ -27,7 +27,9 @@ export PACKAGE_VERSION={CurrentVersion}
2727
export FBXEXPORTERS_PACKAGE_PATH=${PROJECT_PATH}/${PACKAGE_NAME}_${PACKAGE_VERSION}.unitypackage
2828

2929
"${UNITY3D_PATH}" -projectPath "${PROJECT_PATH}" -importPackage ${FBXSDK_PACKAGE_PATH} -quit
30-
"${UNITY3D_PATH}" -projectPath "${PROJECT_PATH}" -executeMethod FbxExporters.Integrations.InstallMaya2017 -quit
30+
31+
# Use "InstallMaya2017CommandsOnly" to install an integration with no UI
32+
"${UNITY3D_PATH}" -batchMode -projectPath "${PROJECT_PATH}" -executeMethod FbxExporters.Integrations.InstallMaya2017 -quit
3133

3234
Configuring Maya2017
3335
--------------------

Assets/Integrations/Autodesk/maya2017/README.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
########################################################################
2-
# Unity Technologies Aps.
3-
# [2017] - . All Rights Reserved.
2+
# Copyright (c) 2017 Unity Technologies. All rights reserved.
43
# NOTICE: All information contained herein is, and remains
54
# the property of Unity Technologies Aps. and its suppliers,
65
# if any. The intellectual and technical concepts contained
@@ -30,10 +29,9 @@ Installation
3029
Running Unit Tests
3130
==================
3231

33-
MacOS / Ubuntu
32+
MacOS
3433

3534
export MAYAPY_PATH=/Applications/Autodesk/maya2017/Maya.app/Contents/bin/mayapy
36-
export UNITY_PROJECT_PATH=~/Development/FbxExporters
3735
export MAYA_INTEGRATION_PATH=${UNITY_PROJECT_PATH}/Assets/Integrations/Autodesk/maya2017
3836
export PYTHONPATH=${MAYA_INTEGRATION_PATH}/scripts
3937

Assets/Integrations/Autodesk/maya2017/doc/README.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)