2
2
using UnityEditor ;
3
3
using System ;
4
4
using System . Collections . Generic ;
5
+ using FbxExporters . EditorTools ;
5
6
6
7
namespace FbxExporters . Editor
7
8
{
@@ -375,7 +376,7 @@ class MaxIntegration
375
376
private const string MaxScriptsPath = "Integrations/Autodesk/max/scripts/" ;
376
377
377
378
private const string PluginName = "UnityFbxForMaxPlugin.ms" ;
378
- private const string PluginPath = MaxScriptsPath + PluginName ;
379
+ public const string PluginPath = MaxScriptsPath + PluginName ;
379
380
380
381
private const string ConfigureMaxScript = MaxScriptsPath + "configureUnityFbxForMax.ms" ;
381
382
@@ -386,6 +387,24 @@ class MaxIntegration
386
387
private const string ProjectTag = "UnityProject" ;
387
388
private const string ExportSettingsTag = "UnityFbxExportSettings" ;
388
389
390
+ private static string m_integrationFolderPath = null ;
391
+ public static string INTEGRATION_FOLDER_PATH
392
+ {
393
+ get {
394
+ if ( string . IsNullOrEmpty ( m_integrationFolderPath ) ) {
395
+ m_integrationFolderPath = Application . dataPath ;
396
+ }
397
+ return m_integrationFolderPath ;
398
+ }
399
+ set {
400
+ if ( ! string . IsNullOrEmpty ( value ) && System . IO . Directory . Exists ( value ) ) {
401
+ m_integrationFolderPath = value ;
402
+ } else {
403
+ Debug . LogError ( string . Format ( "Failed to set integration folder path, invalid directory \" {0}\" " , value ) ) ;
404
+ }
405
+ }
406
+ }
407
+
389
408
/// <summary>
390
409
/// Gets the absolute Unity path for relative path in Integrations folder.
391
410
/// </summary>
@@ -479,7 +498,8 @@ private static void ShowSuccessDialog(string dcc, int exitCode){
479
498
UnityEditor . EditorUtility . DisplayDialog ( title , message , "Ok" ) ;
480
499
}
481
500
482
- const string IntegrationZipPath = "FbxExporters/unityoneclick_for_maya.zip" ;
501
+ const string MayaIntegrationZipPath = "FbxExporters/UnityFbxForMaya.zip" ;
502
+ const string MaxIntegrationZipPath = "FbxExporters/UnityFbxForMax.zip" ;
483
503
484
504
private static string DefaultIntegrationSavePath
485
505
{
@@ -497,23 +517,14 @@ public static void InstallDCCIntegration ()
497
517
return ;
498
518
}
499
519
500
- // decompress zip file if it exists, otherwise try using default location
501
- if ( System . IO . File . Exists ( GetIntegrationZipFullPath ( ) ) ) {
502
- var result = DecompressIntegrationZipFile ( ) ;
503
- if ( ! result ) {
504
- // could not find integration
505
- return ;
506
- }
507
- } else {
508
- Integrations . INTEGRATION_FOLDER_PATH = DefaultIntegrationSavePath ;
509
- }
510
-
511
520
string dccType = System . IO . Path . GetFileNameWithoutExtension ( dccExe ) . ToLower ( ) ;
512
521
if ( dccType . Equals ( "maya" ) ) {
522
+ GetIntegrationFolder ( ExportSettings . DCCType . Maya ) ;
513
523
InstallMayaIntegration ( dccExe ) ;
514
524
return ;
515
525
}
516
526
if ( dccType . Equals ( "3dsmax" ) ) {
527
+ GetIntegrationFolder ( ExportSettings . DCCType . Max ) ;
517
528
InstallMaxIntegration ( dccExe ) ;
518
529
return ;
519
530
}
@@ -534,10 +545,49 @@ public static void InstallMaxIntegration(string maxExe){
534
545
ShowSuccessDialog ( "3DsMax" , exitCode ) ;
535
546
}
536
547
537
- private static bool DecompressIntegrationZipFile ( )
548
+ private static void GetIntegrationFolder ( ExportSettings . DCCType dcc ) {
549
+ // decompress zip file if it exists, otherwise try using default location
550
+ var zipPath = GetIntegrationZipFullPath ( dcc ) ;
551
+ if ( System . IO . File . Exists ( zipPath ) ) {
552
+ var result = DecompressIntegrationZipFile ( zipPath , dcc ) ;
553
+ if ( ! result ) {
554
+ // could not find integration
555
+ return ;
556
+ }
557
+ } else {
558
+ SetIntegrationFolderPath ( DefaultIntegrationSavePath , dcc ) ;
559
+ }
560
+ }
561
+
562
+ private static void SetIntegrationFolderPath ( string path , ExportSettings . DCCType dcc ) {
563
+ switch ( dcc ) {
564
+ case ExportSettings . DCCType . Max :
565
+ MaxIntegration . INTEGRATION_FOLDER_PATH = path ;
566
+ break ;
567
+ case ExportSettings . DCCType . Maya :
568
+ Integrations . INTEGRATION_FOLDER_PATH = path ;
569
+ break ;
570
+ default :
571
+ throw new System . NotImplementedException ( ) ;
572
+ }
573
+ }
574
+
575
+ private static bool DecompressIntegrationZipFile ( string zipPath , ExportSettings . DCCType dcc )
538
576
{
577
+ var dccName = "DCC" ;
578
+ switch ( dcc ) {
579
+ case ExportSettings . DCCType . Max :
580
+ dccName = "3Ds Max" ;
581
+ break ;
582
+ case ExportSettings . DCCType . Maya :
583
+ dccName = "Maya" ;
584
+ break ;
585
+ default :
586
+ throw new System . NotImplementedException ( ) ;
587
+ }
588
+
539
589
// prompt user to enter location to unzip file
540
- var unzipFolder = EditorUtility . OpenFolderPanel ( "Select Location to Save DCC Integration" , LastIntegrationSavePath , "" ) ;
590
+ var unzipFolder = EditorUtility . OpenFolderPanel ( string . Format ( "Select Location to Save {0} Integration" , dccName ) , LastIntegrationSavePath , "" ) ;
541
591
if ( string . IsNullOrEmpty ( unzipFolder ) ) {
542
592
// user has cancelled, do nothing
543
593
return false ;
@@ -563,7 +613,7 @@ private static bool DecompressIntegrationZipFile()
563
613
564
614
// if file already unzipped in this location, then prompt user
565
615
// if they would like to continue unzipping or use what is there
566
- if ( FolderAlreadyUnzippedAtPath ( unzipFolder ) ) {
616
+ if ( FolderAlreadyUnzippedAtPath ( unzipFolder , dcc ) ) {
567
617
var result = UnityEditor . EditorUtility . DisplayDialogComplex ( "Integrations Exist at Path" ,
568
618
string . Format ( "Directory \" {0}\" already contains the decompressed integration" , unzipFolder ) ,
569
619
"Overwrite" ,
@@ -572,16 +622,16 @@ private static bool DecompressIntegrationZipFile()
572
622
) ;
573
623
574
624
if ( result == 0 ) {
575
- DecompressZip ( GetIntegrationZipFullPath ( ) , unzipFolder ) ;
625
+ DecompressZip ( zipPath , unzipFolder ) ;
576
626
} else if ( result == 2 ) {
577
627
return false ;
578
628
}
579
629
} else {
580
630
// unzip Integration folder
581
- DecompressZip ( GetIntegrationZipFullPath ( ) , unzipFolder ) ;
631
+ DecompressZip ( zipPath , unzipFolder ) ;
582
632
}
583
633
584
- Integrations . INTEGRATION_FOLDER_PATH = unzipFolder ;
634
+ SetIntegrationFolderPath ( unzipFolder , dcc ) ;
585
635
586
636
return true ;
587
637
}
@@ -590,9 +640,20 @@ private static bool DecompressIntegrationZipFile()
590
640
/// Gets the integration zip full path as an absolute Unity-style path.
591
641
/// </summary>
592
642
/// <returns>The integration zip full path.</returns>
593
- private static string GetIntegrationZipFullPath ( )
643
+ private static string GetIntegrationZipFullPath ( ExportSettings . DCCType dcc )
594
644
{
595
- return Application . dataPath + "/" + IntegrationZipPath ;
645
+ var relPath = "" ;
646
+ switch ( dcc ) {
647
+ case ExportSettings . DCCType . Max :
648
+ relPath = MaxIntegrationZipPath ;
649
+ break ;
650
+ case ExportSettings . DCCType . Maya :
651
+ relPath = MayaIntegrationZipPath ;
652
+ break ;
653
+ default :
654
+ throw new System . NotImplementedException ( ) ;
655
+ }
656
+ return Application . dataPath + "/" + relPath ;
596
657
}
597
658
598
659
/// <summary>
@@ -601,9 +662,16 @@ private static string GetIntegrationZipFullPath()
601
662
/// </summary>
602
663
/// <returns><c>true</c> if folder is already unzipped at the specified path; otherwise, <c>false</c>.</returns>
603
664
/// <param name="path">Path.</param>
604
- public static bool FolderAlreadyUnzippedAtPath ( string path )
665
+ public static bool FolderAlreadyUnzippedAtPath ( string path , ExportSettings . DCCType dcc )
605
666
{
606
- return System . IO . File . Exists ( System . IO . Path . Combine ( path , Integrations . MODULE_TEMPLATE_PATH ) ) ;
667
+ switch ( dcc ) {
668
+ case ExportSettings . DCCType . Max :
669
+ return System . IO . File . Exists ( System . IO . Path . Combine ( path , MaxIntegration . PluginPath ) ) ;
670
+ case ExportSettings . DCCType . Maya :
671
+ return System . IO . File . Exists ( System . IO . Path . Combine ( path , Integrations . MODULE_TEMPLATE_PATH ) ) ;
672
+ default :
673
+ throw new System . NotImplementedException ( ) ;
674
+ }
607
675
}
608
676
609
677
/// <summary>
0 commit comments