@@ -7,7 +7,7 @@ namespace FbxExporters
7
7
{
8
8
class Integrations
9
9
{
10
- private const string MAYA_VERSION = "2017" ;
10
+ public const string MAYA_VERSION = "2017" ;
11
11
private const string MODULE_FILENAME = "unityoneclick.mod" ;
12
12
private const string PACKAGE_NAME = "FbxExporters" ;
13
13
private const string VERSION_FILENAME = "README.txt" ;
@@ -154,23 +154,23 @@ private static void WriteFile(string FileName, List<string> Lines )
154
154
}
155
155
}
156
156
157
- private static void _InstallMaya2017 ( bool verbose = true , bool commandsOnly = false )
157
+ public static bool InstallMaya ( string version , bool verbose = true , bool commandsOnly = false )
158
158
{
159
159
// check if package installed
160
- string moduleTemplatePath = GetModuleTemplatePath ( MAYA_VERSION ) ;
160
+ string moduleTemplatePath = GetModuleTemplatePath ( version ) ;
161
161
162
162
if ( ! System . IO . File . Exists ( moduleTemplatePath ) )
163
163
{
164
164
Debug . LogError ( string . Format ( "FbxExporters package not installed, please install first" ) ) ;
165
- return ;
165
+ return false ;
166
166
}
167
167
168
168
// TODO: detect maya2017 installation
169
169
170
170
// TODO: if not maya2017 installed warn user
171
171
172
172
// check for {USER} modules folder
173
- string modulePath = GetModulePath ( MAYA_VERSION ) ;
173
+ string modulePath = GetModulePath ( version ) ;
174
174
175
175
string moduleFilePath = System . IO . Path . Combine ( modulePath , MODULE_FILENAME ) ;
176
176
@@ -187,12 +187,12 @@ private static void _InstallMaya2017(bool verbose=true, bool commandsOnly=false)
187
187
catch
188
188
{
189
189
Debug . LogError ( string . Format ( "Failed to create Maya Modules Folder {0}" , modulePath ) ) ;
190
- return ;
190
+ return false ;
191
191
}
192
192
193
193
if ( ! System . IO . Directory . Exists ( modulePath ) ) {
194
194
Debug . LogError ( string . Format ( "Failed to create Maya Modules Folder {0}" , modulePath ) ) ;
195
- return ;
195
+ return false ;
196
196
}
197
197
198
198
installed = false ;
@@ -253,41 +253,57 @@ private static void _InstallMaya2017(bool verbose=true, bool commandsOnly=false)
253
253
254
254
// TODO: configure maya to auto-load plugin on next startup
255
255
256
+ return true ;
256
257
}
257
258
258
259
public static void InstallMaya2017 ( )
259
260
{
260
- bool verbose = true ;
261
+ const bool verbose = true ;
262
+ const bool commandsOnly = false ;
263
+ const string version = Integrations . MAYA_VERSION ;
261
264
262
- Debug . Log ( string . Format ( "Installing Maya {0} Integration" , MAYA_VERSION ) ) ;
265
+ Debug . Log ( string . Format ( "Installing Maya {0} Integration" , version ) ) ;
263
266
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
+ }
267
272
}
268
273
269
- public static void InstallMaya2017CommandsOnly ( )
274
+ public static void InstallMaya2017CommandsOnly ( )
270
275
{
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 ;
274
279
275
- _InstallMaya2017 ( verbose , true ) ;
280
+ Debug . Log ( string . Format ( "Installing Maya {0} Integration (Commands Only)." , version ) ) ;
276
281
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
+ }
278
287
}
279
288
}
280
289
281
290
namespace Editors
282
291
{
283
292
class IntegrationsUI
284
293
{
285
- const string MenuItemName = "FbxExporters/Install Maya2017 Integration" ;
294
+ const string MenuItemName = "FbxExporters/Install Maya" + Integrations . MAYA_VERSION + " Integration" ;
286
295
287
296
[ MenuItem ( MenuItemName , false , 0 ) ]
288
297
public static void OnMenuItem ( )
289
298
{
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 \n loadPlugin unityOneClickPlugin; pluginInfo -edit -autoload true unityOneClickPlugin;\n " ;
303
+
304
+ EditorUtility . DisplayDialog ( title , message , "Ok" ) ;
305
+ Debug . Log ( message ) ;
306
+ }
291
307
}
292
308
}
293
309
}
0 commit comments