public bool SyncFromProject() { ResourceCollection resourceCollection = new ResourceCollection(); string[] assetBundleNames = GetUsedAssetBundleNames(); foreach (string assetBundleName in assetBundleNames) { string name = assetBundleName; string variant = null; int dotPosition = assetBundleName.LastIndexOf('.'); if (dotPosition > 0 && dotPosition < assetBundleName.Length - 1) { name = assetBundleName.Substring(0, dotPosition); variant = assetBundleName.Substring(dotPosition + 1); } if (!resourceCollection.AddResource(name, variant, null, LoadType.LoadFromFile, false)) { return(false); } string[] assetNames = GetAssetPathsFromAssetBundle(assetBundleName); foreach (string assetName in assetNames) { string guid = AssetDatabase.AssetPathToGUID(assetName); if (string.IsNullOrEmpty(guid)) { return(false); } if (!resourceCollection.AssignAsset(guid, name, variant)) { return(false); } } } return(resourceCollection.Save()); }
public bool Save() { try { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.AppendChild(xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null)); XmlElement xmlRoot = xmlDocument.CreateElement("UnityGameFramework"); xmlDocument.AppendChild(xmlRoot); XmlElement xmlEditor = xmlDocument.CreateElement("ResourceEditor"); xmlRoot.AppendChild(xmlEditor); XmlElement xmlSettings = xmlDocument.CreateElement("Settings"); xmlEditor.AppendChild(xmlSettings); XmlElement xmlElement = null; XmlAttribute xmlAttribute = null; xmlElement = xmlDocument.CreateElement("SourceAssetRootPath"); xmlElement.InnerText = SourceAssetRootPath.ToString(); xmlSettings.AppendChild(xmlElement); xmlElement = xmlDocument.CreateElement("SourceAssetSearchPaths"); xmlSettings.AppendChild(xmlElement); foreach (string sourceAssetSearchRelativePath in m_SourceAssetSearchRelativePaths) { XmlElement xmlElementInner = xmlDocument.CreateElement("SourceAssetSearchPath"); xmlAttribute = xmlDocument.CreateAttribute("RelativePath"); xmlAttribute.Value = sourceAssetSearchRelativePath; xmlElementInner.Attributes.SetNamedItem(xmlAttribute); xmlElement.AppendChild(xmlElementInner); } xmlElement = xmlDocument.CreateElement("SourceAssetUnionTypeFilter"); xmlElement.InnerText = SourceAssetUnionTypeFilter ?? string.Empty; xmlSettings.AppendChild(xmlElement); xmlElement = xmlDocument.CreateElement("SourceAssetUnionLabelFilter"); xmlElement.InnerText = SourceAssetUnionLabelFilter ?? string.Empty; xmlSettings.AppendChild(xmlElement); xmlElement = xmlDocument.CreateElement("SourceAssetExceptTypeFilter"); xmlElement.InnerText = SourceAssetExceptTypeFilter ?? string.Empty; xmlSettings.AppendChild(xmlElement); xmlElement = xmlDocument.CreateElement("SourceAssetExceptLabelFilter"); xmlElement.InnerText = SourceAssetExceptLabelFilter ?? string.Empty; xmlSettings.AppendChild(xmlElement); xmlElement = xmlDocument.CreateElement("AssetSorter"); xmlElement.InnerText = AssetSorter.ToString(); xmlSettings.AppendChild(xmlElement); string configurationDirectoryName = Path.GetDirectoryName(m_ConfigurationPath); if (!Directory.Exists(configurationDirectoryName)) { Directory.CreateDirectory(configurationDirectoryName); } xmlDocument.Save(m_ConfigurationPath); AssetDatabase.Refresh(); } catch { if (File.Exists(m_ConfigurationPath)) { File.Delete(m_ConfigurationPath); } return(false); } return(m_ResourceCollection.Save()); }