public List <MATProject> GetProjects(String path, bool orderByRecent = false) { List <MATProject> projects = new List <MATProject>(); foreach (var dir in Directory.GetDirectories(path)) { var directoryInfo = new DirectoryInfo(dir); var project = new MATProject(Path.GetFileName(dir), new FileInfo(dir)); projects.Add(project); var files = directoryInfo.GetFiles("*.avrs", SearchOption.AllDirectories).OrderBy(f => f.CreationTime); foreach (var file in files) { if (file == null) { continue; } var thumbs = Directory.GetFiles(file.DirectoryName, "*.jpg", SearchOption.TopDirectoryOnly); Texture2D thumb = new Texture2D(1, 1); if (thumbs.Length > 0) { if (File.Exists(thumbs[0])) { var bytes = File.ReadAllBytes(thumbs[0]); thumb.LoadImage(bytes); thumb.Apply(); } else { UnityEngine.Debug.LogWarning("Project is without thumbnail"); } } var view = new Avrs(file.FullName, thumb); view.OnProjectChanged = this.ProjectChanged; var tScene = TempScene.Get(file.FullName); project.views.Add(view); } } projects = projects.OrderByDescending(f => f.fileInfo.LastWriteTime).ToList(); projects[0].isOpenedInUI = true; // First is always open return(projects); }
public void Import(Avrs project) { EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); if (!string.IsNullOrEmpty(project.projectPath)) { this.isCurrentlyImporting = true; _tempScene = TempScene.Get(project.projectPath); // Check if scene already exist var deserializer = new AvrsDeserializer(); deserializer.DeserializeFile(project.projectPath, (MScene scene) => { EditingInstanceController.Instance.AddSceneController(deserializer.sceneController); new BimDataComponent(deserializer.sceneController); if (project.isOpened) { project.root = GameObject.Find(project.name + "_Root"); } if (project.root == null) { project.root = new GameObject(project.name + "_Root"); } if (_tempScene == null) { PrepareToSync(project, scene, null, deserializer); _tempScene = TempScene.Create(project.projectPath); _tempScene.Initialize(scene, project.projectPath, deserializer.sceneController); } else { PrepareToSync(project, scene, _tempScene.mScene, deserializer); } }, (float p) => { }, (string error) => { }); } }