/// <summary> /// Save the selected assets into a PackageConfigurationSave file. /// Uses _save_name variable as name for the PackageConfiguration. /// </summary> /// <seealso cref="_save_name"/> private void SaveConfiguration() { if (string.IsNullOrEmpty(_save_name) == false) { // Create a new instance of PackageConfigurationSave PackageConfigurationSave save = ScriptableObject.CreateInstance <PackageConfigurationSave>(); string asset_path = _plugin_path; // If plugin path is not set save configurations into Assets/PackageConfigurations if (string.IsNullOrEmpty(asset_path) == true) { asset_path = "Assets"; } asset_path += "/PackageConfigurations"; save.SavePackageConfiguration(_path_holder); // Create folder if needed if (AssetDatabase.IsValidFolder(asset_path) == false) { AssetDatabase.CreateFolder(Directory.GetParent(asset_path).ToString(), "PackageConfigurations"); } AssetDatabase.CreateAsset(save, asset_path + "/" + _save_name + ".asset"); AssetDatabase.SaveAssets(); RefreshContent(); // Select freshly saved configuration SelectSaveByName(save.name); } else { Debug.LogWarning("Invalid file name: configuration has not been saved :S."); } }
/// <summary> /// Load a give PackageConfigurationSave and apply the according selections. /// </summary> /// <param name="package_config_save">Package Configuration to load.</param> /// <seealso cref="PackageConfigurationSave"/> /// <remarks>If a file has been saved in a PackageConfigurationSave but doesn't exist anymore /// it will be ignored.</remarks> public void LoadSave(PackageConfigurationSave package_config_save) { if (package_config_save == null || package_config_save.asset_path_list == null) { return; } foreach (AssetInfo assetinfo in _assets) { assetinfo.SetSelected(false); foreach (string path in package_config_save.asset_path_list) { if (assetinfo.path == path) { assetinfo.SetSelected(true); break; } } } }