Skip to content

Commit d099e85

Browse files
committed
replace Maya installation code path with Maya LT installation
- also removed some old turntable related code
1 parent 473cdf9 commit d099e85

File tree

4 files changed

+57
-199
lines changed

4 files changed

+57
-199
lines changed

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 56 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ class MayaIntegration : DCCIntegration
8888

8989
public override string IntegrationZipPath { get { return "FbxExporters/UnityFbxForMaya.zip"; } }
9090

91-
public const string TEMP_SAVE_PATH = "_safe_to_delete";
91+
private string FBX_EXPORT_SETTINGS_PATH { get { return "/Integrations/Autodesk/maya/scripts/unityFbxExportSettings.mel"; } }
9292

93-
protected virtual string FBX_EXPORT_SETTINGS_PATH { get { return "/Integrations/Autodesk/maya/scripts/unityFbxExportSettings.mel"; } }
93+
private string FBX_IMPORT_SETTINGS_PATH { get { return "/Integrations/Autodesk/maya/scripts/unityFbxImportSettings.mel"; } }
9494

95-
protected virtual string MODULE_TEMPLATE_PATH { get { return "Integrations/Autodesk/maya/" + MODULE_FILENAME + ".txt"; } }
96-
protected virtual string MODULE_FILENAME { get { return "UnityFbxForMaya"; } }
95+
private string MODULE_TEMPLATE_PATH { get { return "Integrations/Autodesk/maya/" + MODULE_FILENAME + ".txt"; } }
96+
private string MODULE_FILENAME { get { return "UnityFbxForMaya"; } }
9797

9898
private const string PACKAGE_NAME = "FbxExporters";
9999
private const string VERSION_FILENAME = "README.txt";
@@ -102,9 +102,11 @@ class MayaIntegration : DCCIntegration
102102
private const string PROJECT_TAG = "{UnityProject}";
103103
private const string INTEGRATION_TAG = "{UnityIntegrationsPath}";
104104

105-
private const string MAYA_INSTRUCTION_FILENAME = "_safe_to_delete/_temp.txt";
105+
private const string MAYA_USER_STARTUP_SCRIPT = "userSetup.mel";
106+
107+
private const string USER_STARTUP_CALL = "if(`exists setupUnityUI`){ setupUnityUI; }";
106108

107-
protected static string MAYA_DOCUMENTS_PATH {
109+
private static string MAYA_DOCUMENTS_PATH {
108110
get {
109111
switch (Application.platform) {
110112
case RuntimePlatform.WindowsEditor:
@@ -123,6 +125,12 @@ private static string MAYA_MODULES_PATH {
123125
}
124126
}
125127

128+
private static string MAYA_SCRIPTS_PATH {
129+
get {
130+
return System.IO.Path.Combine(GetUserFolder(), MAYA_DOCUMENTS_PATH + "/scripts");
131+
}
132+
}
133+
126134
// Use string to define escaped quote
127135
// Windows needs the backslash
128136
protected static string ESCAPED_QUOTE {
@@ -138,11 +146,10 @@ protected static string ESCAPED_QUOTE {
138146
}
139147
}
140148

141-
protected virtual string MAYA_CONFIG_COMMAND { get {
142-
return string.Format("configureUnityFbxForMaya {0}{1}{0} {0}{2}{0} {0}{3}{0} {0}{4}{0} {0}{5}{0} {6};",
143-
ESCAPED_QUOTE, GetProjectPath(), GetAppPath(), GetTempSavePath(),
144-
GetExportSettingsPath(), GetMayaInstructionPath(), (IsHeadlessInstall() ? 1 : 0));
145-
}}
149+
protected string MAYA_CONFIG_COMMAND { get {
150+
return string.Format("configureUnityFbxForMaya {0}{1}{0} {0}{2}{0} {0}{3}{0} {4};",
151+
ESCAPED_QUOTE, GetProjectPath(), GetExportSettingsPath(), GetImportSettingsPath(), (IsHeadlessInstall()?1:0));
152+
}}
146153

147154
private string MAYA_CLOSE_COMMAND { get {
148155
return string.Format("scriptJob -idleEvent quit;");
@@ -171,48 +178,37 @@ public string GetModuleTemplatePath()
171178
return System.IO.Path.Combine(INTEGRATION_FOLDER_PATH, MODULE_TEMPLATE_PATH);
172179
}
173180

174-
public static string GetAppPath()
175-
{
176-
return EditorApplication.applicationPath.Replace("\\","/");
177-
}
178-
179181
public static string GetPackagePath()
180182
{
181183
return System.IO.Path.Combine(Application.dataPath, PACKAGE_NAME);
182184
}
183185

184-
public static string GetTempSavePath()
185-
{
186-
return TEMP_SAVE_PATH.Replace("\\", "/");
187-
}
188-
189186
/// <summary>
190-
/// Gets the maya instruction path relative to the Assets folder.
191-
/// Assets folder is not included in the path.
187+
/// Gets the path to the export settings file.
188+
/// Returns a relative path with forward slashes as path separators.
192189
/// </summary>
193-
/// <returns>The relative maya instruction path.</returns>
194-
public static string GetMayaInstructionPath()
190+
/// <returns>The export settings path.</returns>
191+
public string GetExportSettingsPath()
195192
{
196-
return MAYA_INSTRUCTION_FILENAME;
193+
return INTEGRATION_FOLDER_PATH + FBX_EXPORT_SETTINGS_PATH;
197194
}
198195

199196
/// <summary>
200-
/// Gets the full maya instruction path as an absolute Unity path.
197+
/// Gets the path to the import settings file.
198+
/// Returns a relative path with forward slashes as path separators.
201199
/// </summary>
202-
/// <returns>The full maya instruction path.</returns>
203-
public static string GetFullMayaInstructionPath()
204-
{
205-
return Application.dataPath + "/" + FbxExporters.Editor.MayaIntegration.GetMayaInstructionPath ();
200+
/// <returns>The import settings path.</returns>
201+
public string GetImportSettingsPath(){
202+
return INTEGRATION_FOLDER_PATH + FBX_IMPORT_SETTINGS_PATH;
206203
}
207204

208205
/// <summary>
209-
/// Gets the path to the export settings file.
206+
/// Gets the user startup script path.
210207
/// Returns a relative path with forward slashes as path separators.
211208
/// </summary>
212-
/// <returns>The export settings path.</returns>
213-
public string GetExportSettingsPath()
214-
{
215-
return INTEGRATION_FOLDER_PATH + FBX_EXPORT_SETTINGS_PATH;
209+
/// <returns>The user startup script path.</returns>
210+
private static string GetUserStartupScriptPath(){
211+
return MAYA_SCRIPTS_PATH + "/" + MAYA_USER_STARTUP_SCRIPT;
216212
}
217213

218214
public static string GetPackageVersion()
@@ -399,7 +395,7 @@ public int ConfigureMaya(string mayaPath)
399395
return ExitCode;
400396
}
401397

402-
public virtual bool InstallMaya(bool verbose = false)
398+
public bool InstallMaya(bool verbose = false)
403399
{
404400
// What's happening here is that we copy the module template to
405401
// the module path, basically:
@@ -482,87 +478,10 @@ public virtual bool InstallMaya(bool verbose = false)
482478
// TODO: print message package already installed else where
483479
}
484480

485-
return true;
486-
}
487-
488-
489-
public override int InstallIntegration (string mayaExe)
490-
{
491-
if (!InstallMaya(verbose: true)) {
492-
return -1;
493-
}
494-
495-
return ConfigureMaya (mayaExe);
496-
}
497-
498-
/// <summary>
499-
/// Determines if folder is already unzipped at the specified path
500-
/// by checking if UnityFbxForMaya.txt exists at expected location.
501-
/// </summary>
502-
/// <returns><c>true</c> if folder is already unzipped at the specified path; otherwise, <c>false</c>.</returns>
503-
/// <param name="path">Path.</param>
504-
public override bool FolderAlreadyUnzippedAtPath(string path)
505-
{
506-
if (string.IsNullOrEmpty (path)) {
507-
return false;
508-
}
509-
return System.IO.File.Exists (System.IO.Path.Combine (path, MODULE_TEMPLATE_PATH));
510-
}
511-
}
512-
513-
class MayaLTIntegration : MayaIntegration
514-
{
515-
public override string DccDisplayName { get { return "Maya LT"; } }
516-
517-
public override string IntegrationZipPath { get { return "FbxExporters/UnityFbxForMayaLT.zip"; } }
518-
519-
protected override string MODULE_TEMPLATE_PATH { get { return "Integrations/Autodesk/mayalt/" + MODULE_FILENAME + ".txt"; } }
520-
521-
protected override string MODULE_FILENAME { get { return "UnityFbxForMayaLT"; } }
522-
523-
protected override string FBX_EXPORT_SETTINGS_PATH { get { return "/Integrations/Autodesk/mayalt/scripts/unityFbxExportSettings.mel"; } }
524-
525-
protected string FBX_IMPORT_SETTINGS_PATH { get { return "/Integrations/Autodesk/mayalt/scripts/unityFbxImportSettings.mel"; } }
526-
527-
private const string MAYA_USER_STARTUP_SCRIPT = "userSetup.mel";
528-
529-
private const string USER_STARTUP_CALL = "if(`exists setupUnityUI`){ setupUnityUI; }";
530-
531-
protected override string MAYA_CONFIG_COMMAND { get {
532-
return string.Format("configureUnityFbxForMayaLT {0}{1}{0} {0}{2}{0} {0}{3}{0} {4};",
533-
ESCAPED_QUOTE, GetProjectPath(), GetExportSettingsPath(), GetImportSettingsPath(), (IsHeadlessInstall()?1:0));
534-
}}
535-
536-
private static string MAYA_SCRIPTS_PATH {
537-
get {
538-
return System.IO.Path.Combine(GetUserFolder(), MAYA_DOCUMENTS_PATH + "/scripts");
539-
}
540-
}
541-
542-
/// <summary>
543-
/// Gets the path to the import settings file.
544-
/// Returns a relative path with forward slashes as path separators.
545-
/// </summary>
546-
/// <returns>The import settings path.</returns>
547-
public string GetImportSettingsPath(){
548-
return INTEGRATION_FOLDER_PATH + FBX_IMPORT_SETTINGS_PATH;
481+
return SetupUserStartupScript (verbose);
549482
}
550483

551-
/// <summary>
552-
/// Gets the user startup script path.
553-
/// Returns a relative path with forward slashes as path separators.
554-
/// </summary>
555-
/// <returns>The user startup script path.</returns>
556-
private static string GetUserStartupScriptPath(){
557-
return MAYA_SCRIPTS_PATH + "/" + MAYA_USER_STARTUP_SCRIPT;
558-
}
559-
560-
public override bool InstallMaya (bool verbose = false)
561-
{
562-
if (!base.InstallMaya (verbose)) {
563-
return false;
564-
}
565-
484+
private bool SetupUserStartupScript(bool verbose = false){
566485
// setup user startup script
567486
string mayaStartupScript = GetUserStartupScriptPath ();
568487
string fileContents = string.Format("\n{0}", USER_STARTUP_CALL);
@@ -608,14 +527,33 @@ public override bool InstallMaya (bool verbose = false)
608527
return true;
609528
}
610529

611-
public override int InstallIntegration (string mayaLTExe)
530+
public override int InstallIntegration (string mayaExe)
612531
{
613532
if (!InstallMaya(verbose: true)) {
614533
return -1;
615534
}
616535

617-
return ConfigureMaya (mayaLTExe);
536+
return ConfigureMaya (mayaExe);
618537
}
538+
539+
/// <summary>
540+
/// Determines if folder is already unzipped at the specified path
541+
/// by checking if UnityFbxForMaya.txt exists at expected location.
542+
/// </summary>
543+
/// <returns><c>true</c> if folder is already unzipped at the specified path; otherwise, <c>false</c>.</returns>
544+
/// <param name="path">Path.</param>
545+
public override bool FolderAlreadyUnzippedAtPath(string path)
546+
{
547+
if (string.IsNullOrEmpty (path)) {
548+
return false;
549+
}
550+
return System.IO.File.Exists (System.IO.Path.Combine (path, MODULE_TEMPLATE_PATH));
551+
}
552+
}
553+
554+
class MayaLTIntegration : MayaIntegration
555+
{
556+
public override string DccDisplayName { get { return "Maya LT"; } }
619557
}
620558

621559
class MaxIntegration : DCCIntegration

Assets/FbxExporters/Editor/ReviewLastSavedModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static void OnPostprocessAllAssets(
3333
foreach (var assetPath in importedAssets) {
3434
if (assetPath.StartsWith(tempSavePath) && assetPath.EndsWith(".fbx")) {
3535
// if the instruction file exists, then run the turntable and delete the file
36-
string instructionFile = FbxExporters.Editor.MayaIntegration.GetFullMayaInstructionPath ();
36+
string instructionFile = "";//FbxExporters.Editor.MayaIntegration.GetFullMayaInstructionPath ();
3737
if(System.IO.File.Exists(instructionFile)){
3838
LastSavedModel ();
3939
System.IO.File.Delete (instructionFile);

Assets/FbxExporters/Editor/UnitTests/IntegrationsTest.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ void LogNonEmptyString(string name, string str) {
2525
Assert.IsFalse(string.IsNullOrEmpty(str));
2626
}
2727

28-
/// <summary>
29-
/// Checks if the given text contains "mayalt" as one word.
30-
/// </summary>
31-
/// <param name="text">Text.</param>
32-
void ContainsMayaLT(string text){
33-
Assert.IsFalse (string.IsNullOrEmpty (text));
34-
Assert.IsTrue (text.ToLower ().Contains ("mayalt"));
35-
}
36-
3728
[Test]
3829
public void BasicTest() {
3930
// test Maya integration
@@ -46,14 +37,7 @@ public void BasicTest() {
4637
Assert.IsFalse (Editor.MayaIntegration.IsHeadlessInstall ());
4738

4839
LogNonEmptyString ("module template path", mayaIntegration.GetModuleTemplatePath ());
49-
LogNonEmptyString ("app path", Editor.MayaIntegration.GetAppPath ());
5040
LogNonEmptyString ("package path", Editor.MayaIntegration.GetPackagePath ());
51-
LogNonEmptyString ("temp path", Editor.MayaIntegration.GetTempSavePath ());
52-
LogNonEmptyString ("instruction path", Editor.MayaIntegration.GetMayaInstructionPath ());
53-
LogNonEmptyString ("full instruction path", Editor.MayaIntegration.GetFullMayaInstructionPath ());
54-
55-
// make sure the path is absolute
56-
Assert.IsTrue (System.IO.Path.IsPathRooted (Editor.MayaIntegration.GetFullMayaInstructionPath ()));
5741

5842
LogNonEmptyString ("export settings path", mayaIntegration.GetExportSettingsPath ());
5943
LogNonEmptyString ("package version", Editor.MayaIntegration.GetPackageVersion ());
@@ -64,12 +48,8 @@ public void BasicTest() {
6448
Assert.IsFalse (mayaIntegration.FolderAlreadyUnzippedAtPath ("X:/a/b/a/c"));
6549

6650
// test that the paths don't contain backslashes
67-
Assert.IsFalse (Editor.MayaIntegration.GetAppPath ().Contains ("\\"));
6851
Assert.IsFalse (Editor.MayaIntegration.GetProjectPath ().Contains ("\\"));
69-
Assert.IsFalse (Editor.MayaIntegration.GetTempSavePath ().Contains ("\\"));
7052
Assert.IsFalse (mayaIntegration.GetExportSettingsPath ().Contains ("\\"));
71-
Assert.IsFalse (Editor.MayaIntegration.GetMayaInstructionPath ().Contains ("\\"));
72-
Assert.IsFalse (Editor.MayaIntegration.GetFullMayaInstructionPath ().Contains ("\\"));
7353
}
7454

7555
// test Maya LT integration
@@ -78,16 +58,6 @@ public void BasicTest() {
7858

7959
// make sure that the values we get are for Maya LT since it inherits a lot from Maya Integration
8060
Assert.AreEqual ("Maya LT", mayaLTIntegration.DccDisplayName);
81-
ContainsMayaLT (mayaLTIntegration.IntegrationZipPath);
82-
83-
LogNonEmptyString ("import settings path", mayaLTIntegration.GetImportSettingsPath ());
84-
85-
ContainsMayaLT (mayaLTIntegration.GetModuleTemplatePath ());
86-
ContainsMayaLT (mayaLTIntegration.GetExportSettingsPath ());
87-
88-
// test that the paths don't contain backslashes
89-
Assert.IsFalse (mayaLTIntegration.GetExportSettingsPath ().Contains ("\\"));
90-
Assert.IsFalse (mayaLTIntegration.GetImportSettingsPath ().Contains ("\\"));
9161
}
9262

9363
// test 3ds Max integration

Assets/Integrations/Autodesk/maya/scripts/UnityFbxForMaya/version.py

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

0 commit comments

Comments
 (0)