public void ChangeSceneCacheOnDirectPrefab() { //Initial setup const string DEST_PREFAB_PATH = "Assets/TestSceneCache.prefab"; const string ASSETS_FOLDER = "Assets/TestSceneCacheAssets"; bool prefabCreated = SceneCachePlayerEditorUtility.CreateSceneCachePlayerAndPrefab( Path.GetFullPath(MeshSyncTestEditorConstants.CUBE_TEST_DATA_PATH), DEST_PREFAB_PATH, ASSETS_FOLDER, out SceneCachePlayer player, out GameObject prefab ); Assert.IsTrue(prefabCreated); //Check the prefab Assert.IsFalse(prefab.IsPrefabInstance()); Assert.IsTrue(prefab.IsPrefab()); SceneCachePlayer prefabPlayer = prefab.GetComponent <SceneCachePlayer>(); Assert.IsNotNull(prefabPlayer); Camera cam0 = prefabPlayer.GetComponentInChildren <Camera>(); Light light0 = prefabPlayer.GetComponentInChildren <Light>(); //Change TestDataComponents comps = ChangeSceneCacheFileAndVerify(prefabPlayer, Path.GetFullPath(MeshSyncTestEditorConstants.SPHERE_TEST_DATA_PATH) ); Assert.AreEqual(cam0, comps.cam); Assert.AreEqual(light0, comps.light); //Cleanup Object.DestroyImmediate(player.gameObject); DeleteSceneCachePlayerPrefab(prefab); }
//---------------------------------------------------------------------------------------------------------------------- static TestDataComponents ChangeSceneCacheFileAndVerify(SceneCachePlayer player, string scPath) { SceneCachePlayerEditorUtility.ChangeSceneCacheFile(player, scPath); string savedScFilePath = player.GetSceneCacheFilePath(); Assert.AreEqual(AssetEditorUtility.NormalizePath(scPath), savedScFilePath); Assert.IsTrue(AssetEditorUtility.IsPathNormalized(savedScFilePath), $"{savedScFilePath} is not normalized"); Assert.IsTrue(player.transform.childCount > 0); TestDataComponents ret = new TestDataComponents( player.GetComponentInChildren <Camera>(), player.GetComponentInChildren <Light>(), player.GetComponentInChildren <MeshRenderer>() ); Assert.IsNotNull(ret.cam); Assert.IsNotNull(ret.light); Assert.IsNotNull(ret.meshRenderer); return(ret); }