Skip to content

Commit ff3db28

Browse files
committed
fix InstallIntegration and ManualUpdateEditorWindow warnings
- Changes to ManualUpdateEditorWindow are: -- added class to namespace -- in Init() added check if fbxPrefab is null -- removed setter for Verbose
1 parent 8da187b commit ff3db28

File tree

4 files changed

+219
-183
lines changed

4 files changed

+219
-183
lines changed

Assets/com.unity.formats.fbx.tests/IntegrationsTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@ public void BasicTest() {
4141

4242
Assert.IsTrue (MayaIntegration.IsHeadlessInstall () == 0);
4343

44-
LogNonEmptyString ("module template path", mayaIntegration.GetModuleTemplatePath ());
45-
LogNonEmptyString ("package path", MayaIntegration.GetPackagePath ());
44+
LogNonEmptyString ("module template path", mayaIntegration.ModuleTemplatePath);
45+
LogNonEmptyString ("package path", MayaIntegration.PackagePath);
4646

47-
LogNonEmptyString ("export settings path", mayaIntegration.GetExportSettingsPath ());
48-
LogNonEmptyString ("package version", MayaIntegration.GetPackageVersion ());
47+
LogNonEmptyString ("export settings path", mayaIntegration.ExportSettingsPath);
48+
LogNonEmptyString ("package version", MayaIntegration.PackageVersion);
4949

5050
// check if folder is unzipped at invalid paths
5151
Assert.IsFalse (mayaIntegration.FolderAlreadyUnzippedAtPath (null));
5252
Assert.IsFalse (mayaIntegration.FolderAlreadyUnzippedAtPath (""));
5353
Assert.IsFalse (mayaIntegration.FolderAlreadyUnzippedAtPath ("X:/a/b/a/c"));
5454

5555
// test that the paths don't contain backslashes
56-
Assert.IsFalse (MayaIntegration.GetProjectPath ().Contains ("\\"));
57-
Assert.IsFalse (mayaIntegration.GetExportSettingsPath ().Contains ("\\"));
56+
Assert.IsFalse (MayaIntegration.ProjectPath.Contains ("\\"));
57+
Assert.IsFalse (mayaIntegration.ExportSettingsPath.Contains ("\\"));
5858
}
5959

6060
// test Maya LT integration

Packages/com.unity.formats.fbx/Editor/Scripts/FbxPrefabAutoUpdater.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ public static void Append<TKey1, TKey2, TValue>(ref Dictionary<TKey1, Dictionary
516516
/// Exception that denotes a likely programming error.
517517
/// </summary>
518518
[System.Serializable]
519-
internal class FbxPrefabException : System.Exception
519+
public class FbxPrefabException : System.Exception
520520
{
521521
public FbxPrefabException() { }
522522
public FbxPrefabException(string message) : base(message) { }

Packages/com.unity.formats.fbx/Editor/Scripts/InstallIntegration.cs

Lines changed: 73 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,50 @@ public abstract class DCCIntegration
99
public abstract string DccDisplayName { get; }
1010
public abstract string IntegrationZipPath { get; }
1111

12-
private static string m_integrationFolderPath = null;
13-
public static string INTEGRATION_FOLDER_PATH
12+
private static string s_integrationFolderPath = null;
13+
public static string IntegrationFolderPath
1414
{
1515
get{
16-
if (string.IsNullOrEmpty (m_integrationFolderPath)) {
17-
m_integrationFolderPath = Application.dataPath;
16+
if (string.IsNullOrEmpty (s_integrationFolderPath)) {
17+
s_integrationFolderPath = Application.dataPath;
1818
}
19-
return m_integrationFolderPath;
19+
return s_integrationFolderPath;
2020
}
2121
set{
2222
if (!string.IsNullOrEmpty (value) && System.IO.Directory.Exists (value)) {
23-
m_integrationFolderPath = value;
23+
s_integrationFolderPath = value;
2424
} else {
2525
Debug.LogError (string.Format("Failed to set integration folder path, invalid directory \"{0}\"", value));
2626
}
2727
}
2828
}
2929

3030
public void SetIntegrationFolderPath(string path){
31-
INTEGRATION_FOLDER_PATH = path;
31+
IntegrationFolderPath = path;
3232
}
3333

3434
/// <summary>
3535
/// Gets the integration zip full path as an absolute Unity-style path.
3636
/// </summary>
3737
/// <returns>The integration zip full path.</returns>
38-
public string GetIntegrationZipFullPath()
38+
public string IntegrationZipFullPath
3939
{
40-
return System.IO.Path.GetFullPath("Packages/com.unity.formats.fbx/Editor/Integrations").Replace("\\", "/") + "/" + IntegrationZipPath;
40+
get
41+
{
42+
return System.IO.Path.GetFullPath("Packages/com.unity.formats.fbx/Editor/Integrations").Replace("\\", "/") + "/" + IntegrationZipPath;
43+
}
4144
}
4245

4346
/// <summary>
4447
/// Gets the project path.
4548
/// </summary>
4649
/// <returns>The project path.</returns>
47-
public static string GetProjectPath()
50+
public static string ProjectPath
4851
{
49-
return System.IO.Directory.GetParent(Application.dataPath).FullName.Replace("\\","/");
52+
get
53+
{
54+
return System.IO.Directory.GetParent(Application.dataPath).FullName.Replace("\\", "/");
55+
}
5056
}
5157

5258
/// <summary>
@@ -120,19 +126,19 @@ private static string MAYA_DOCUMENTS_PATH {
120126

121127
private static string MAYA_MODULES_PATH {
122128
get {
123-
return System.IO.Path.Combine(GetUserFolder(), MAYA_DOCUMENTS_PATH + "/modules");
129+
return System.IO.Path.Combine(UserFolder, MAYA_DOCUMENTS_PATH + "/modules");
124130
}
125131
}
126132

127133
private static string MAYA_SCRIPTS_PATH {
128134
get {
129-
return System.IO.Path.Combine(GetUserFolder(), MAYA_DOCUMENTS_PATH + "/scripts");
135+
return System.IO.Path.Combine(UserFolder, MAYA_DOCUMENTS_PATH + "/scripts");
130136
}
131137
}
132138

133139
// Use string to define escaped quote
134140
// Windows needs the backslash
135-
protected static string ESCAPED_QUOTE {
141+
protected static string EscapedQuote {
136142
get {
137143
switch (Application.platform) {
138144
case RuntimePlatform.WindowsEditor:
@@ -145,24 +151,28 @@ protected static string ESCAPED_QUOTE {
145151
}
146152
}
147153

148-
protected string MAYA_CONFIG_COMMAND { get {
154+
protected string MayaConfigCommand { get {
149155
return string.Format("unityConfigure {0}{1}{0} {0}{2}{0} {0}{3}{0} {4} {5};",
150-
ESCAPED_QUOTE, GetProjectPath(), GetExportSettingsPath(), GetImportSettingsPath(), (IsHeadlessInstall()), (HideSendToUnityMenu));
156+
EscapedQuote, ProjectPath, ExportSettingsPath, ImportSettingsPath, (IsHeadlessInstall()), (HideSendToUnityMenu));
151157
}}
152158

153159
private string MAYA_CLOSE_COMMAND { get {
154160
return string.Format("scriptJob -idleEvent quit;");
155161
}}
156162

157-
protected static string GetUserFolder()
163+
protected static string UserFolder
158164
{
159-
switch (Application.platform) {
160-
case RuntimePlatform.WindowsEditor:
161-
return System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
162-
case RuntimePlatform.OSXEditor:
163-
return System.Environment.GetEnvironmentVariable("HOME");
164-
default:
165-
throw new NotImplementedException ();
165+
get
166+
{
167+
switch (Application.platform)
168+
{
169+
case RuntimePlatform.WindowsEditor:
170+
return System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
171+
case RuntimePlatform.OSXEditor:
172+
return System.Environment.GetEnvironmentVariable("HOME");
173+
default:
174+
throw new NotImplementedException();
175+
}
166176
}
167177
}
168178

@@ -178,33 +188,45 @@ public static int HideSendToUnityMenu
178188
}
179189
}
180190

181-
public string GetModuleTemplatePath()
191+
public string ModuleTemplatePath
182192
{
183-
return System.IO.Path.Combine(INTEGRATION_FOLDER_PATH, MODULE_TEMPLATE_PATH);
193+
get
194+
{
195+
return System.IO.Path.Combine(IntegrationFolderPath, MODULE_TEMPLATE_PATH);
196+
}
184197
}
185198

186-
public static string GetPackagePath()
199+
public static string PackagePath
187200
{
188-
return System.IO.Path.Combine(Application.dataPath, PACKAGE_NAME);
201+
get
202+
{
203+
return System.IO.Path.Combine(Application.dataPath, PACKAGE_NAME);
204+
}
189205
}
190206

191207
/// <summary>
192208
/// Gets the path to the export settings file.
193209
/// Returns a relative path with forward slashes as path separators.
194210
/// </summary>
195211
/// <returns>The export settings path.</returns>
196-
public string GetExportSettingsPath()
212+
public string ExportSettingsPath
197213
{
198-
return INTEGRATION_FOLDER_PATH + FBX_EXPORT_SETTINGS_PATH;
214+
get
215+
{
216+
return IntegrationFolderPath + FBX_EXPORT_SETTINGS_PATH;
217+
}
199218
}
200219

201220
/// <summary>
202221
/// Gets the path to the import settings file.
203222
/// Returns a relative path with forward slashes as path separators.
204223
/// </summary>
205224
/// <returns>The import settings path.</returns>
206-
public string GetImportSettingsPath(){
207-
return INTEGRATION_FOLDER_PATH + FBX_IMPORT_SETTINGS_PATH;
225+
public string ImportSettingsPath{
226+
get
227+
{
228+
return IntegrationFolderPath + FBX_IMPORT_SETTINGS_PATH;
229+
}
208230
}
209231

210232
/// <summary>
@@ -216,9 +238,12 @@ private static string GetUserStartupScriptPath(){
216238
return MAYA_SCRIPTS_PATH + "/" + MAYA_USER_STARTUP_SCRIPT;
217239
}
218240

219-
public static string GetPackageVersion()
241+
public static string PackageVersion
220242
{
221-
return ModelExporter.GetVersionFromReadme();
243+
get
244+
{
245+
return ModelExporter.GetVersionFromReadme();
246+
}
222247
}
223248

224249
private static List<string> ParseTemplateFile(string FileName, Dictionary<string,string> Tokens )
@@ -337,11 +362,11 @@ public int ConfigureMaya(string mayaPath)
337362
{
338363
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
339364
myProcess.StartInfo.CreateNoWindow = false;
340-
myProcess.StartInfo.Arguments = string.Format(commandString, MAYA_CONFIG_COMMAND);
365+
myProcess.StartInfo.Arguments = string.Format(commandString, MayaConfigCommand);
341366
}
342367
else
343368
{
344-
myProcess.StartInfo.Arguments = string.Format(commandString, MAYA_CONFIG_COMMAND + MAYA_CLOSE_COMMAND);
369+
myProcess.StartInfo.Arguments = string.Format(commandString, MayaConfigCommand + MAYA_CLOSE_COMMAND);
345370
}
346371

347372
myProcess.EnableRaisingEvents = true;
@@ -384,7 +409,7 @@ public bool InstallMaya(bool verbose = false)
384409
// - done.
385410
// But it's complicated because we can't trust any files actually exist.
386411

387-
string moduleTemplatePath = GetModuleTemplatePath();
412+
string moduleTemplatePath = ModuleTemplatePath;
388413
if (!System.IO.File.Exists(moduleTemplatePath))
389414
{
390415
Debug.LogError(string.Format("Missing Maya module file at: \"{0}\"", moduleTemplatePath));
@@ -432,9 +457,9 @@ public bool InstallMaya(bool verbose = false)
432457
{
433458
Dictionary<string,string> Tokens = new Dictionary<string,string>()
434459
{
435-
{VERSION_TAG, GetPackageVersion() },
436-
{PROJECT_TAG, GetProjectPath() },
437-
{INTEGRATION_TAG, INTEGRATION_FOLDER_PATH },
460+
{VERSION_TAG, PackageVersion },
461+
{PROJECT_TAG, ProjectPath },
462+
{INTEGRATION_TAG, IntegrationFolderPath },
438463
};
439464

440465
// parse template, replace "{UnityProject}" with project path
@@ -502,13 +527,13 @@ private bool SetupUserStartupScript(bool verbose = false){
502527
return true;
503528
}
504529

505-
public override int InstallIntegration (string mayaExe)
530+
public override int InstallIntegration (string exe)
506531
{
507532
if (!InstallMaya(verbose: true)) {
508533
return -1;
509534
}
510535

511-
return ConfigureMaya (mayaExe);
536+
return ConfigureMaya (exe);
512537
}
513538

514539
/// <summary>
@@ -559,15 +584,15 @@ public class MaxIntegration : DCCIntegration
559584
/// <returns>The absolute path.</returns>
560585
/// <param name="relPath">Relative path.</param>
561586
public static string GetAbsPath(string relPath){
562-
return MayaIntegration.INTEGRATION_FOLDER_PATH + "/" + relPath;
587+
return MayaIntegration.IntegrationFolderPath + "/" + relPath;
563588
}
564589

565590
private static string GetInstallScript(){
566591
Dictionary<string,string> Tokens = new Dictionary<string,string>()
567592
{
568593
{PluginSourceTag, GetAbsPath(PluginPath) },
569594
{PluginNameTag, PluginName },
570-
{ProjectTag, GetProjectPath() },
595+
{ProjectTag, ProjectPath },
571596
{ExportSettingsTag, GetAbsPath(ExportSettingsFile) },
572597
{ImportSettingsTag, GetAbsPath(ImportSettingsFile) }
573598
};
@@ -642,8 +667,8 @@ public static int InstallMaxPlugin(string maxExe){
642667
return ExitCode;
643668
}
644669

645-
public override int InstallIntegration(string maxExe){
646-
return MaxIntegration.InstallMaxPlugin (maxExe);
670+
public override int InstallIntegration(string exe){
671+
return MaxIntegration.InstallMaxPlugin (exe);
647672
}
648673

649674
/// <summary>
@@ -661,7 +686,7 @@ public override bool FolderAlreadyUnzippedAtPath(string path)
661686
}
662687
}
663688

664-
class IntegrationsUI
689+
static class IntegrationsUI
665690
{
666691
/// <summary>
667692
/// The path of the DCC executable.
@@ -734,7 +759,7 @@ public static void InstallDCCIntegration ()
734759

735760
private static bool GetIntegrationFolder(DCCIntegration dcc){
736761
// decompress zip file if it exists, otherwise try using default location
737-
var zipPath = dcc.GetIntegrationZipFullPath();
762+
var zipPath = dcc.IntegrationZipFullPath;
738763
if (System.IO.File.Exists (zipPath)) {
739764
return DecompressIntegrationZipFile (zipPath, dcc);
740765
}

0 commit comments

Comments
 (0)