Skip to content

Commit 4fb67bf

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into UNI-24636-1.2.0b1-forum-release
2 parents b31dcde + 1a7f996 commit 4fb67bf

File tree

4 files changed

+68
-56
lines changed

4 files changed

+68
-56
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ private static string DefaultIntegrationSavePath {
294294
/// </summary>
295295
public static string[] DCCVendorLocations {
296296
get{
297-
var environmentVariable = Environment.GetEnvironmentVariable("UNITY_FBX_3DAPP_VENDOR_LOCATIONS");
297+
var environmentVariable = Environment.GetEnvironmentVariable("UNITY_3DAPP_VENDOR_LOCATIONS");
298298
if (environmentVariable != null)
299299
{
300300
string[] locations = environmentVariable.Split(';');
@@ -410,6 +410,11 @@ public void SetDCCOptionNames(List<string> newList)
410410
dccOptionNames = newList;
411411
}
412412

413+
public void SetDCCOptionPaths(List<string> newList)
414+
{
415+
dccOptionPaths = newList;
416+
}
417+
413418
public void ClearDCCOptionNames()
414419
{
415420
dccOptionNames.Clear();

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -825,18 +825,6 @@ protected bool ExportCamera (GameObject unityGO, FbxScene fbxScene, FbxNode fbxN
825825
fbxCamera.SetFarPlane (unityCamera.farClipPlane*UnitScaleFactor);
826826
#endregion
827827

828-
// Export backgroundColor as a custom property
829-
// NOTE: export on fbxNode so that it will show up in Maya
830-
ExportColorProperty (fbxNode, unityCamera.backgroundColor,
831-
MakeName("backgroundColor"),
832-
"The color with which the screen will be cleared.");
833-
834-
// Export clearFlags as a custom property
835-
// NOTE: export on fbxNode so that it will show up in Maya
836-
ExportIntProperty (fbxNode, (int)unityCamera.clearFlags,
837-
MakeName("clearFlags"),
838-
"How the camera clears the background.");
839-
840828
fbxNode.SetNodeAttribute (fbxCamera);
841829

842830
// set +90 post rotation to counteract for FBX camera's facing +X direction by default
@@ -861,47 +849,6 @@ protected void SetDefaultCamera (FbxScene fbxScene)
861849
fbxScene.GetGlobalSettings ().SetDefaultCamera (DefaultCamera);
862850
}
863851

864-
/// <summary>
865-
/// Export Component's color property
866-
/// </summary>
867-
bool ExportColorProperty (FbxObject fbxObject, Color value, string name, string label)
868-
{
869-
// create a custom property for component value
870-
var fbxProperty = FbxProperty.Create (fbxObject, Globals.FbxColor4DT, name, label);
871-
if (!fbxProperty.IsValid ()) {
872-
throw new System.NullReferenceException ();
873-
}
874-
875-
FbxColor fbxColor = new FbxColor(value.r, value.g, value.b, value.a );
876-
877-
fbxProperty.Set (fbxColor);
878-
879-
// Must be marked user-defined or it won't be shown in most DCCs
880-
fbxProperty.ModifyFlag (FbxPropertyFlags.EFlags.eUserDefined, true);
881-
fbxProperty.ModifyFlag (FbxPropertyFlags.EFlags.eAnimatable, true);
882-
883-
return true;
884-
}
885-
886-
/// <summary>
887-
/// Export Component's int property
888-
/// </summary>
889-
bool ExportIntProperty (FbxObject fbxObject, int value, string name, string label)
890-
{
891-
// create a custom property for component value
892-
var fbxProperty = FbxProperty.Create (fbxObject, Globals.FbxIntDT, name, label);
893-
if (!fbxProperty.IsValid ()) {
894-
throw new System.NullReferenceException ();
895-
}
896-
fbxProperty.Set (value);
897-
898-
// Must be marked user-defined or it won't be shown in most DCCs
899-
fbxProperty.ModifyFlag (FbxPropertyFlags.EFlags.eUserDefined, true);
900-
fbxProperty.ModifyFlag (FbxPropertyFlags.EFlags.eAnimatable, true);
901-
902-
return true;
903-
}
904-
905852
/// <summary>
906853
/// Ensures that the inputted name is unique.
907854
/// If a duplicate name is found, then it is incremented.
@@ -1318,6 +1265,9 @@ private void ReplaceFile ()
13181265
} catch (IOException) {
13191266
}
13201267

1268+
// refresh the database so Unity knows the file's been deleted
1269+
AssetDatabase.Refresh();
1270+
13211271
if (File.Exists (m_lastFilePath)) {
13221272
Debug.LogWarning ("Failed to delete file: " + m_lastFilePath);
13231273
}

Assets/FbxExporters/Editor/UnitTests/FbxExportSettingsTest.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,56 @@ public void TestFindPreferredProgram()
213213
Assert.AreEqual(preferred, -1);
214214
}
215215

216+
[Test]
217+
public void TestGetDCCOptions()
218+
{
219+
//Our.exe file
220+
string executableName = "/maya.exe";
221+
222+
//Our folder names
223+
string firstSubFolder = "/maya 3000";
224+
string secondSubFolder = "/maya 3001";
225+
226+
//Make a folder structure to mimic an 'autodesk' type hierarchy
227+
string testFolder = Path.GetRandomFileName();
228+
var firstPath = Directory.CreateDirectory(testFolder + firstSubFolder);
229+
var secondPath = Directory.CreateDirectory(testFolder + secondSubFolder);
230+
231+
try
232+
{
233+
//Create any files we need within the folders
234+
FileInfo firstExe = new FileInfo(firstPath.FullName + executableName);
235+
using (FileStream s = firstExe.Create()) { }
236+
237+
//Add the paths which will be copied to DCCOptionPaths
238+
List<string> testPathList = new List<string>();
239+
testPathList.Add(firstPath.FullName + executableName); //this path is valid!
240+
testPathList.Add(secondPath.FullName + executableName);
241+
testPathList.Add(null);
242+
testPathList.Add("cookies/milk/foo/bar");
243+
244+
//Add the names which will be copied to DCCOptionNames
245+
List<string> testNameList = new List<string>();
246+
testNameList.Add(firstSubFolder.TrimStart('/'));
247+
testNameList.Add(secondSubFolder.TrimStart('/'));
248+
testNameList.Add(null);
249+
testNameList.Add("Cookies & Milk");
250+
251+
ExportSettings.instance.SetDCCOptionNames(testNameList);
252+
ExportSettings.instance.SetDCCOptionPaths(testPathList);
253+
254+
GUIContent[] options = ExportSettings.GetDCCOptions();
255+
256+
//We expect 1, as the others are purposefully bogus
257+
Assert.AreEqual(options.Length, 1);
258+
259+
Assert.IsTrue(options[0].text == "maya 3000");
260+
}
261+
finally
262+
{
263+
Directory.Delete(testFolder, true);
264+
}
265+
}
266+
216267
}
217268
}

Assets/FbxExporters/Editor/UnitTests/FbxPrefabTest.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,16 @@ public void TestTransformAndReparenting()
425425
var newCopyPath = ModelExporter.ExportObject(
426426
GetRandomFbxFilePath(), root);
427427
SleepForFileTimestamp();
428+
429+
var destFile = new FbxPrefabAutoUpdater.FbxPrefabUtility (original.GetComponent<FbxPrefab> ()).GetFbxAssetPath ();
430+
if (System.IO.File.Exists (destFile)) {
431+
System.IO.File.Delete (destFile);
432+
}
433+
AssetDatabase.Refresh ();
428434
System.IO.File.Copy(
429435
newCopyPath,
430-
new FbxPrefabAutoUpdater.FbxPrefabUtility(original.GetComponent<FbxPrefab>()).GetFbxAssetPath(),
431-
overwrite: true);
436+
destFile,
437+
overwrite: false);
432438
AssetDatabase.Refresh();
433439

434440
// Make sure the update took.

0 commit comments

Comments
 (0)