提交 b390b078 编写于 作者: A Adrian T

Added test to check that instance's NavMeshData .asset file gets deleted when...

Added test to check that instance's NavMeshData .asset file gets deleted when the instance reverts back to prefab structure.
上级 51e3946a
......@@ -493,7 +493,7 @@ public IEnumerator NavMeshSurfacePrefab_WhenRebakedButNotSaved_TheRebakedAssetNo
var navMeshAssetName = prefabSurface.navMeshData.name + ".asset";
var combinedAssetPath = Path.Combine(assetFolderPath, navMeshAssetName);
Assert.IsTrue(System.IO.File.Exists(combinedAssetPath), "NavMeshData file exists. ({0})", combinedAssetPath);
Assert.IsTrue(System.IO.File.Exists(combinedAssetPath), "NavMeshData file must exist. ({0})", combinedAssetPath);
StageManager.instance.GoToMainStage();
......@@ -513,13 +513,13 @@ public IEnumerator NavMeshSurfacePrefab_WhenRebaked_TheOldAssetExistsUntilSaving
var navMeshAssetName = prefabSurface.navMeshData.name + ".asset";
var combinedAssetPath = Path.Combine(assetFolderPath, navMeshAssetName);
Assert.IsTrue(System.IO.File.Exists(combinedAssetPath), "NavMeshData file exists. ({0})", combinedAssetPath);
Assert.IsTrue(System.IO.File.Exists(combinedAssetPath), "NavMeshData file must exist. ({0})", combinedAssetPath);
prefabSurface.defaultArea = k_GrayArea;
prefabSurface.BuildNavMesh();
CreateNavMeshAsset(prefabSurface);
Assert.IsTrue(System.IO.File.Exists(combinedAssetPath), "NavMeshData file exists. ({0})", combinedAssetPath);
Assert.IsTrue(System.IO.File.Exists(combinedAssetPath), "The initial NavMeshData file must exist after prefab rebake. ({0})", combinedAssetPath);
prefabScene.SavePrefab();
Assert.IsFalse(System.IO.File.Exists(combinedAssetPath), "NavMeshData file still exists after saving. ({0})", combinedAssetPath);
......@@ -583,14 +583,14 @@ public IEnumerator NavMeshSurfacePrefab_AfterModifiedInstanceAppliedBack_TheOldA
var navMeshAssetName = instanceSurface.navMeshData.name + ".asset";
var combinedAssetPath = Path.Combine(assetFolderPath, navMeshAssetName);
Assert.IsTrue(System.IO.File.Exists(combinedAssetPath), "Prefab's NavMeshData file exists. ({0})", combinedAssetPath);
Assert.IsTrue(System.IO.File.Exists(combinedAssetPath), "Prefab's NavMeshData file must exist. ({0})", combinedAssetPath);
instanceSurface.defaultArea = k_RedArea;
instanceSurface.BuildNavMesh();
CreateNavMeshAsset(instanceSurface);
Assert.IsTrue(System.IO.File.Exists(combinedAssetPath),
"Prefab's NavMeshData file exists after instance has changed. ({0})", combinedAssetPath);
"Prefab's NavMeshData file exists after the instance has changed. ({0})", combinedAssetPath);
PrefabUtility.ApplyPrefabInstance(instance);
......@@ -723,6 +723,36 @@ public IEnumerator NavMeshSurfacePrefab_WhenInstanceRevertsBack_InstanceIsLikePr
yield return null;
}
[UnityTest]
public IEnumerator NavMeshSurfacePrefab_WhenInstanceRevertsBack_TheInstanceAssetNoLongerExists()
{
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(m_PrefabPath);
var instance = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
Assert.IsNotNull(instance);
instance.name = "PrefabInstance";
TestNavMeshExistsAloneAtPosition(k_PrefabDefaultArea, Vector3.zero);
var instanceSurface = instance.GetComponent<NavMeshSurface>();
Assert.IsNotNull(instanceSurface);
instanceSurface.defaultArea = k_RedArea;
instanceSurface.BuildNavMesh();
CreateNavMeshAsset(instanceSurface);
var assetFolderPath = GetAndEnsureTargetPath(instanceSurface);
var navMeshAssetName = instanceSurface.navMeshData.name + ".asset";
var combinedAssetPath = Path.Combine(assetFolderPath, navMeshAssetName);
Assert.IsTrue(System.IO.File.Exists(combinedAssetPath), "Instance's NavMeshData file must exist. ({0})", combinedAssetPath);
PrefabUtility.RevertPrefabInstance(instance);
Assert.IsFalse(System.IO.File.Exists(combinedAssetPath), "Instance's NavMeshData file still exists after revert. ({0})", combinedAssetPath);
Object.DestroyImmediate(instance);
yield return null;
}
[UnityTest]
public IEnumerator NavMeshSurfacePrefab_WhenDeleted_InstancesMakeCopiesOfData()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册