//TODO save location data on install // delete location data on remove // destingish between public and private modules private static void InitInstalledModule(Module m) { bool remove = false; if (Helper.ClassWithNamespaceExists(m.location_data.classname)) { m.path = GetModuleDirectory(m); if (string.IsNullOrEmpty(m.path) == false) { m.installed_module = Parser.ParseToObject <ModuleInfo>(FileHelper.ReadFileIntoString(FindModuleFilePath(m.path))); string calced_guid = AssetDatabase.AssetPathToGUID(m.path); if (m.location_data.guid != calced_guid) { SaveModuleLocationData(m, calced_guid); } } else { remove = true; } } if (remove) { FileHelper.RemoveValueFromFile(m.id, PATH.MODULES_LOCATION__DATA); m.location_data = null; } }
private static void LoadModule(ModuleCollectionInfo info, List <Module> modules) { WebHelper.DownloadStringASync(info.url, delegate(string data) { Module new_module = new Module(); new_module.url = info.url; new_module.author = info.author; new_module.id = info.id; new_module.available_module = Parser.ParseToObject <ModuleInfo>(data); new_module.available_module.version = new_module.available_module.version.Replace(",", "."); bool module_installed = LoadModuleLocationData(new_module); if (module_installed) { InitInstalledModule(new_module); } else if (Helper.ClassWithNamespaceExists(new_module.available_module.classname)) { CheckForUnregisteredInstall(new_module); } if (new_module.installed_module != null) { new_module.installed_module.version = new_module.installed_module.version.Replace(",", "."); } if (new_module.available_module.requirement != null) { new_module.available_requirement_fullfilled = new_module.available_module.requirement.Test(); } if (new_module.available_requirement_fullfilled && new_module.installed_module != null && Helper.CompareVersions(new_module.installed_module.version, new_module.available_module.version) == 1) { new_module.update_available = true; } modules.Add(new_module); UnityHelper.RepaintEditorWindow <Settings>(); }); }
private static void CheckForUnregisteredInstall(Module module) { //Debug.Log(module.available_module.classname + ":" + Helper.ClassWithNamespaceExists(module.available_module.classname)); if (Helper.ClassWithNamespaceExists(module.available_module.classname)) { module.path = ResolveFilesToDirectory(module.available_module.files.ToArray()); if (string.IsNullOrEmpty(module.path) == false) { module.installed_module = Parser.ParseToObject <ModuleInfo>(FileHelper.ReadFileIntoString(FindModuleFilePath(module.path))); SaveModuleLocationData(module, AssetDatabase.AssetPathToGUID(module.path)); } } }