Skip to content

Commit 3a2b994

Browse files
committed
separate max + maya zip files
1 parent 822579a commit 3a2b994

File tree

3 files changed

+117
-29
lines changed

3 files changed

+117
-29
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[Bb]in/
1111
[Dd]ebug/
1212

13-
[Aa]ssets/FbxExporters/unityoneclick_for_maya.zip
13+
[Aa]ssets/FbxExporters/*.zip
1414

1515
# vim temp files
1616
*.swp

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 91 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using UnityEditor;
33
using System;
44
using System.Collections.Generic;
5+
using FbxExporters.EditorTools;
56

67
namespace FbxExporters.Editor
78
{
@@ -375,7 +376,7 @@ class MaxIntegration
375376
private const string MaxScriptsPath = "Integrations/Autodesk/max/scripts/";
376377

377378
private const string PluginName = "UnityFbxForMaxPlugin.ms";
378-
private const string PluginPath = MaxScriptsPath + PluginName;
379+
public const string PluginPath = MaxScriptsPath + PluginName;
379380

380381
private const string ConfigureMaxScript = MaxScriptsPath + "configureUnityFbxForMax.ms";
381382

@@ -386,6 +387,24 @@ class MaxIntegration
386387
private const string ProjectTag = "UnityProject";
387388
private const string ExportSettingsTag = "UnityFbxExportSettings";
388389

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+
389408
/// <summary>
390409
/// Gets the absolute Unity path for relative path in Integrations folder.
391410
/// </summary>
@@ -479,7 +498,8 @@ private static void ShowSuccessDialog(string dcc, int exitCode){
479498
UnityEditor.EditorUtility.DisplayDialog (title, message, "Ok");
480499
}
481500

482-
const string IntegrationZipPath = "FbxExporters/unityoneclick_for_maya.zip";
501+
const string MayaIntegrationZipPath = "FbxExporters/UnityFbxForMaya.zip";
502+
const string MaxIntegrationZipPath = "FbxExporters/UnityFbxForMax.zip";
483503

484504
private static string DefaultIntegrationSavePath
485505
{
@@ -497,23 +517,14 @@ public static void InstallDCCIntegration ()
497517
return;
498518
}
499519

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-
511520
string dccType = System.IO.Path.GetFileNameWithoutExtension (dccExe).ToLower();
512521
if (dccType.Equals ("maya")) {
522+
GetIntegrationFolder (ExportSettings.DCCType.Maya);
513523
InstallMayaIntegration (dccExe);
514524
return;
515525
}
516526
if (dccType.Equals ("3dsmax")) {
527+
GetIntegrationFolder (ExportSettings.DCCType.Max);
517528
InstallMaxIntegration (dccExe);
518529
return;
519530
}
@@ -534,10 +545,49 @@ public static void InstallMaxIntegration(string maxExe){
534545
ShowSuccessDialog ("3DsMax", exitCode);
535546
}
536547

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)
538576
{
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+
539589
// 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,"");
541591
if (string.IsNullOrEmpty (unzipFolder)) {
542592
// user has cancelled, do nothing
543593
return false;
@@ -563,7 +613,7 @@ private static bool DecompressIntegrationZipFile()
563613

564614
// if file already unzipped in this location, then prompt user
565615
// if they would like to continue unzipping or use what is there
566-
if (FolderAlreadyUnzippedAtPath (unzipFolder)) {
616+
if (FolderAlreadyUnzippedAtPath (unzipFolder, dcc)) {
567617
var result = UnityEditor.EditorUtility.DisplayDialogComplex ("Integrations Exist at Path",
568618
string.Format ("Directory \"{0}\" already contains the decompressed integration", unzipFolder),
569619
"Overwrite",
@@ -572,16 +622,16 @@ private static bool DecompressIntegrationZipFile()
572622
);
573623

574624
if (result == 0) {
575-
DecompressZip (GetIntegrationZipFullPath(), unzipFolder);
625+
DecompressZip (zipPath, unzipFolder);
576626
} else if (result == 2) {
577627
return false;
578628
}
579629
} else {
580630
// unzip Integration folder
581-
DecompressZip (GetIntegrationZipFullPath(), unzipFolder);
631+
DecompressZip (zipPath, unzipFolder);
582632
}
583633

584-
Integrations.INTEGRATION_FOLDER_PATH = unzipFolder;
634+
SetIntegrationFolderPath(unzipFolder, dcc);
585635

586636
return true;
587637
}
@@ -590,9 +640,20 @@ private static bool DecompressIntegrationZipFile()
590640
/// Gets the integration zip full path as an absolute Unity-style path.
591641
/// </summary>
592642
/// <returns>The integration zip full path.</returns>
593-
private static string GetIntegrationZipFullPath()
643+
private static string GetIntegrationZipFullPath(ExportSettings.DCCType dcc)
594644
{
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;
596657
}
597658

598659
/// <summary>
@@ -601,9 +662,16 @@ private static string GetIntegrationZipFullPath()
601662
/// </summary>
602663
/// <returns><c>true</c> if folder is already unzipped at the specified path; otherwise, <c>false</c>.</returns>
603664
/// <param name="path">Path.</param>
604-
public static bool FolderAlreadyUnzippedAtPath(string path)
665+
public static bool FolderAlreadyUnzippedAtPath(string path, ExportSettings.DCCType dcc)
605666
{
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+
}
607675
}
608676

609677
/// <summary>

CMakeLists.txt

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,21 @@ add_custom_target(
106106
###########################################################################
107107
# Zip integrations folder
108108
set(MAYA_INTEGRATION_TARGET zip_maya_integration)
109-
set(MAYA_INTEGRATION_ZIP_NAME "unityoneclick_for_maya.zip")
109+
set(MAYA_INTEGRATION_ZIP_NAME "UnityFbxForMaya.zip")
110110

111-
# remove existing zip file
111+
set(MAX_INTEGRATION_TARGET zip_max_integration)
112+
set(MAX_INTEGRATION_ZIP_NAME "UnityFbxForMax.zip")
113+
114+
# remove existing zip files
112115
file(REMOVE "${CMAKE_SOURCE_DIR}/Assets/FbxExporters/${MAYA_INTEGRATION_ZIP_NAME}")
116+
file(REMOVE "${CMAKE_SOURCE_DIR}/Assets/FbxExporters/${MAX_INTEGRATION_ZIP_NAME}")
117+
113118
# remove .pyc files that we don't want to ship
114119
file(GLOB PYC_FILES "${CMAKE_SOURCE_DIR}/Assets/Integrations/Autodesk/maya/scripts/unityOneClick/*.pyc")
115120
IF( PYC_FILES )
116121
file(REMOVE ${PYC_FILES})
117122
ENDIF()
123+
118124
# remove .meta files from Integrations
119125
file(GLOB_RECURSE META_FILES "${CMAKE_SOURCE_DIR}/Assets/Integrations/*.meta")
120126

@@ -123,21 +129,35 @@ add_custom_command(OUTPUT ${MAYA_INTEGRATION_ZIP_NAME}
123129
COMMAND ${CMAKE_COMMAND} -E remove ${META_FILES}
124130
ENDIF
125131
COMMAND ${CMAKE_COMMAND} -E tar "cfv" ${CMAKE_SOURCE_DIR}/Assets/FbxExporters/${MAYA_INTEGRATION_ZIP_NAME} --format=zip
126-
"${CMAKE_SOURCE_DIR}/Assets/Integrations"
132+
"${CMAKE_SOURCE_DIR}/Assets/Integrations/Autodesk/maya"
133+
"${CMAKE_SOURCE_DIR}/Assets/Integrations/BringToFront.exe"
134+
"${CMAKE_SOURCE_DIR}/Assets/Integrations/.gitignore"
127135
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Assets
128136
COMMENT "Zipping Maya Integration folder"
129137
)
130138
add_custom_target(${MAYA_INTEGRATION_TARGET} DEPENDS ${MAYA_INTEGRATION_ZIP_NAME})
131139

140+
141+
add_custom_command(OUTPUT ${MAX_INTEGRATION_ZIP_NAME}
142+
IF(META_FILES)
143+
COMMAND ${CMAKE_COMMAND} -E remove ${META_FILES}
144+
ENDIF
145+
COMMAND ${CMAKE_COMMAND} -E tar "cfv" ${CMAKE_SOURCE_DIR}/Assets/FbxExporters/${MAX_INTEGRATION_ZIP_NAME} --format=zip
146+
"${CMAKE_SOURCE_DIR}/Assets/Integrations/Autodesk/max"
147+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Assets
148+
COMMENT "Zipping 3DsMax Integration folder"
149+
)
150+
add_custom_target(${MAX_INTEGRATION_TARGET} DEPENDS ${MAX_INTEGRATION_ZIP_NAME})
151+
132152
###########################################################################
133153
# Add target for creating a package
134154
add_custom_command(
135155
OUTPUT ${PACKAGE_PATH}
136156
COMMAND "${UNITY_EDITOR_PATH}" -batchmode -projectPath ${CMAKE_SOURCE_DIR} -exportPackage Assets/FbxExporters ${PACKAGE_PATH} -quit
137157
COMMENT "Creating Unity Package ${PACKAGE_PATH}"
138-
DEPENDS ${MAYA_INTEGRATION_TARGET}
158+
DEPENDS ${MAYA_INTEGRATION_TARGET} ${MAX_INTEGRATION_TARGET}
139159
)
140-
add_custom_target(unitypackage ALL DEPENDS ${PACKAGE_PATH} ${FBXSDK_PACKAGE_TARGET} ${MAYA_INTEGRATION_TARGET} ${README_TARGET})
160+
add_custom_target(unitypackage ALL DEPENDS ${PACKAGE_PATH} ${FBXSDK_PACKAGE_TARGET} ${MAYA_INTEGRATION_TARGET} ${MAX_INTEGRATION_TARGET} ${README_TARGET})
141161

142162
enable_testing()
143163
add_test(NAME run-all COMMAND "${UNITY_EDITOR_PATH}" -batchmode -projectPath ${CMAKE_SOURCE_DIR} runEditorTests -quit)

0 commit comments

Comments
 (0)