private void Refresh() { _applications = new List <ApplicationData>(); _missingDependencies = new List <string>(); //Applications DirectoryInfo applicationsDirectoryInfo = CreateApplicationsFolderIfNeeded(); if (applicationsDirectoryInfo == null) { return; } string[] applicationsFiles = Directory.GetFiles(applicationsDirectoryInfo.FullName, "*.json"); if (applicationsFiles.Length == 0) { Debug.LogWarning("Morph couldn't find any applications in the folder"); return; } Debug.LogFormat("Morph has found {0} applications", applicationsFiles.Length); //Dependencies DirectoryInfo dependenciesDirectoryInfo = CreateDependenciesFolderIfNeeded(); if (dependenciesDirectoryInfo == null) { return; } //Parse applications files foreach (var applicationFile in applicationsFiles) { string fileContent = File.ReadAllText(applicationFile); ApplicationData data = JsonUtility.FromJson <ApplicationData>(fileContent); _applications.Add(data); Debug.LogFormat("Morph found application {0}", data.Name); } //Find current application file if (!File.Exists(ApplicationPath)) { Debug.LogWarning("Morph couldn't find any applications in the folder"); //If no application file found, create one with first available application if (_applications.Count > 0) { File.WriteAllText(ApplicationPath, JsonUtility.ToJson(_applications[0])); } else { Debug.LogWarning( "Morph couldn't find current application, and no application to use has been found"); return; } } else { ApplicationData appData = JsonUtility.FromJson <ApplicationData>(File.ReadAllText(ApplicationPath)); for (var applicationIndex = 0; applicationIndex < _applications.Count; applicationIndex++) { if (appData.Equals(_applications[applicationIndex])) { _selectedApplication = applicationIndex; Debug.Log($"Morph current application is {appData.Name}"); break; } } } //Look if all dependencies are found foreach (var dependency in _applications[_selectedApplication].Dependencies) { if (!HasDependency(dependency)) { _missingDependencies.Add(dependency); } } //Look if MorphMain can be found foreach (var rootGameObject in SceneManager.GetActiveScene().GetRootGameObjects()) { _morphMain = rootGameObject.GetComponentInChildren <MorphMain>(); if (_morphMain) { break; } } }
public bool Equals(ApplicationData other) { return(string.Equals(Name, other.Name)); }