Skip to content

Commit d5b6190

Browse files
authored
Merge pull request #427 from Unity-Technologies/UNI-49696-fix-prefab-auto-updater-test
UNI-49696 fix prefab auto updater unit test
2 parents dee1279 + decdf33 commit d5b6190

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,6 @@ public void BasicTest ()
5555
var imported = new HashSet<string> (new string [] { "Assets/path/to/foo.fbx", m_fbxPath });
5656
Assert.IsTrue (FbxPrefabAutoUpdater.MayHaveFbxPrefabToFbxAsset (m_prefabPath, fbxPrefabPath,
5757
imported));
58-
59-
// Create an empty (and duplicate) FbxPrefab.cs to confuse the auto-updater. Make sure it's properly confused.
60-
// This test only works in 2018.2 or later; 2018.1 hard-codes the path.
61-
#if UNITY_2018_2_OR_LATER
62-
System.IO.File.WriteAllText(this.filePath + '/' + FbxPrefabAutoUpdater.FBX_PREFAB_FILE, "class CeciNestPasUnFbxPrefab : UnityEngine.MonoBehaviour {}\n");
63-
AssetDatabase.Refresh(); // force refresh
64-
// TODO: assert that we're getting a log warning, but this still works
65-
Assert.IsTrue (FbxPrefabAutoUpdater.MayHaveFbxPrefabToFbxAsset (m_prefabPath, fbxPrefabPath, imported));
66-
#endif
6758
}
6859

6960
[Test]

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ protected FbxPrefabException(SerializationInfo info, StreamingContext context) :
3838
{
3939
#if COM_UNITY_FORMATS_FBX_AS_ASSET
4040
public const string FbxPrefabFile = "/UnityFbxPrefab.dll";
41-
#elif UNITY_2018_2_OR_NEWER
42-
public const string FbxPrefabFile = "/FbxPrefab.cs";
43-
#else // Unity 2018.1 and fbx installed as a package
41+
#else
4442
public const string FbxPrefabFile = "Packages/com.unity.formats.fbx/Runtime/FbxPrefab.cs";
4543
#endif
4644

@@ -51,7 +49,7 @@ protected FbxPrefabException(SerializationInfo info, StreamingContext context) :
5149

5250
public static string FindFbxPrefabAssetPath()
5351
{
54-
#if COM_UNITY_FORMATS_FBX_AS_ASSET || UNITY_2018_2_OR_NEWER
52+
#if COM_UNITY_FORMATS_FBX_AS_ASSET
5553
// Find guids that are scripts that look like FbxPrefab.
5654
// That catches FbxPrefabTest too, so we have to make sure.
5755
var allGuids = AssetDatabase.FindAssets("FbxPrefab t:MonoScript");
@@ -72,17 +70,17 @@ public static string FindFbxPrefabAssetPath()
7270
Debug.LogWarning(string.Format("{0} not found; are you trying to uninstall {1}?", FbxPrefabFile.Substring(1), ModelExporter.PACKAGE_UI_NAME));
7371
}
7472
return foundPath;
75-
#else
76-
// In Unity 2018.1, FindAssets can't find FbxPrefab.cs in a package.
73+
#else
74+
// In Unity 2018.1 and 2018.2.0b7, FindAssets can't find FbxPrefab.cs in a package.
7775
// So we hardcode the path.
78-
var path = FBX_PREFAB_FILE;
76+
var path = FbxPrefabFile;
7977
if (System.IO.File.Exists(System.IO.Path.GetFullPath(path))) {
8078
return path;
8179
} else {
82-
Debug.LogWarning(string.Format("{0} not found; are you trying to uninstall {1}?", FBX_PREFAB_FILE, UnityEditor.Formats.Fbx.Exporter.ModelExporter.PACKAGE_UI_NAME));
80+
Debug.LogWarningFormat("{0} not found; update FbxPrefabFile variable in FbxPrefabAutoUpdater.cs to point to FbxPrefab.cs path.", FbxPrefabFile);
8381
return "";
8482
}
85-
#endif
83+
#endif
8684
}
8785

8886
public static bool IsFbxAsset(string assetPath) {

0 commit comments

Comments
 (0)