void Start() { OCSceneConfig config = OCGenerator.GetSceneConfig(sceneName); if (config.IsStreamScene) { var ocDataFilePath = MultiScene.GetOCDataFilePath(config.GetSceneAssetPath(), config.SceneNamePattern); if (!File.Exists(ocDataFilePath)) { EditorUtility.DisplayDialog("文件不存在", string.Format("OC 数据文件 {0} 不存在!", ocDataFilePath), "确定"); return; } int TileDimension = config.TileDimension; byte[] data = null; using (var fileStream = File.Open(ocDataFilePath, FileMode.Open)) { data = new byte[fileStream.Length]; if (fileStream.Read(data, 0, data.Length) != data.Length) { EditorUtility.DisplayDialog("文件读取失败", string.Format("读取 OC 数据文件 {0} 失败!", ocDataFilePath), "确定"); return; } } streamScene = new MultiScene(config.GetSceneAssetPath(), config.SceneNamePattern, TileDimension, config.TileSize, data); //streamScene.Load (); foreach (var index in config.indices) { if (index.x == _tileX && index.y == _tileY) { int tileDimension = config.TileDimension; for (int x = 0; x < tileDimension; ++x) { for (int y = 0; y < tileDimension; ++y) { if (index.x >= 0 && index.y >= 0) { if (Math.Abs(x - index.x) > 1 || Math.Abs(y - index.y) > 1) { continue; } } //sceneNames.Add(String.Format("{0}/{1}.unity", config.GetSceneAssetPath(), //String.Format(config.SceneNamePattern, x, y))); streamScene.Load(x, y); } } //streamScene.Load (index.x, index.y); } } } }
public void Do() { if (config.IsStreamScene) { var ocDataFilePath = MultiScene.GetOCDataFilePath(config.GetSceneAssetPath(), config.SceneNamePattern); if (!File.Exists(ocDataFilePath)) { EditorUtility.DisplayDialog("文件不存在", string.Format("OC 数据文件 {0} 不存在!", ocDataFilePath), "确定"); return; } int TileDimension = config.TileDimension; byte[] data = null; using (var fileStream = File.Open(ocDataFilePath, FileMode.Open)) { data = new byte[fileStream.Length]; if (fileStream.Read(data, 0, data.Length) != data.Length) { EditorUtility.DisplayDialog("文件读取失败", string.Format("读取 OC 数据文件 {0} 失败!", ocDataFilePath), "确定"); return; } } streamScene = new MultiScene(config.GetSceneAssetPath(), config.SceneNamePattern, TileDimension, config.TileSize, data); for (int i = 0; i < config.TileDimension; i++) { for (int j = 0; j < config.TileDimension; j++) { streamScene.Load(i, j); } } } else { singleScene = new OC.SingleScene(config.GetSceneAssetPath(), config.SceneNamePattern, Index.InValidIndex); singleScene.TestLoad(); } //var name = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; //SingleScene scene = new OC.SingleScene("", name, null); //scene.Load(); int width = _width; int height = _height; RenderTexture renderTex = RenderTexture.GetTemporary(width, height, 16, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB); RenderTexture.active = renderTex; cam.targetTexture = renderTex; Texture2D tex = new Texture2D(width, height, TextureFormat.ARGB32, false); if (config.IsStreamScene) { foreach (var tile in streamScene.tileMap) { var scene = tile.Value as SingleScene; for (int v = 0; v < scene.volumelList.Count; v++) { string title = "test volume " + v + "/" + scene.volumelList.Count; string info = ""; var volume = scene.volumelList[v]; int finalCellCount = volume.cellList.Count; for (int i = 0; i < finalCellCount; i++) { info = "cell " + i + "/" + finalCellCount; bool bCancel = EditorUtility.DisplayCancelableProgressBar(title, info, (float)i / finalCellCount); if (bCancel) { break; } var cell = volume.cellList[i]; MoveCamera(scene, tex, cell.aabb.center); } } } } else { for (int v = 0; v < singleScene.volumelList.Count; v++) { string title = "test volume " + v + "/" + singleScene.volumelList.Count; string info = ""; var volume = singleScene.volumelList[v]; int finalCellCount = volume.cellList.Count; for (int i = 0; i < finalCellCount; i++) { info = "cell " + i + "/" + finalCellCount; bool bCancel = EditorUtility.DisplayCancelableProgressBar(title, info, (float)i / finalCellCount); if (bCancel) { break; } var cell = volume.cellList[i]; MoveCamera(singleScene, tex, cell.aabb.center); } } } EditorUtility.ClearProgressBar(); }