public bool Prepare() { m_AssetBundleCollection.Clear(); return(m_AssetBundleCollection.Load()); }
public bool BuildAssetBundles() { if (!IsValidOutputDirectory) { return(false); } //初始化版本文件信息 _initVersion(string.Format("{0}({1})", ApplicableGameVersion, InternalResourceVersion), MinAppVersion); Icarus.GameFramework.Utility.Zip.SetZipHelper(new DefaultZipHelper()); if (Directory.Exists(OutputPackagePath)) { Directory.Delete(OutputPackagePath, true); } Directory.CreateDirectory(OutputPackagePath); if (Directory.Exists(BuildReportPath)) { Directory.Delete(BuildReportPath, true); } Directory.CreateDirectory(BuildReportPath); if (Directory.Exists(OutputZipPath)) { Directory.Delete(OutputZipPath, true); } Directory.CreateDirectory(OutputZipPath); BuildAssetBundleOptions buildAssetBundleOptions = GetBuildAssetBundleOptions(); m_BuildReport.Initialize(BuildReportPath, ProductName, CompanyName, GameIdentifier, ApplicableGameVersion, InternalResourceVersion, UnityVersion, WindowsSelected, MacOSXSelected, IOSSelected, AndroidSelected, WindowsStoreSelected, RecordScatteredDependencyAssetsSelected, (int)buildAssetBundleOptions, m_AssetBundleDatas); try { m_BuildReport.LogInfo("Build Start Time: {0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); if (m_BuildEventHandler != null) { m_BuildReport.LogInfo("Execute build event handler 'PreProcessBuildAll'..."); m_BuildEventHandler.PreProcessBuildAll( ProductName, CompanyName, GameIdentifier, ApplicableGameVersion, InternalResourceVersion, UnityVersion, buildAssetBundleOptions, OutputDirectory, WorkingPath, OutputPackagePath, OutputZipPath, BuildReportPath); } m_BuildReport.LogInfo("Start prepare AssetBundle collection..."); if (!m_AssetBundleCollection.Load()) { m_BuildReport.LogError("Can not parse 'AssetBundleCollection.xml', please use 'AssetBundle Editor' tool first."); m_BuildReport.SaveReport(); return(false); } m_BuildReport.LogInfo("Prepare AssetBundle collection complete."); m_BuildReport.LogInfo("Start analyze assets dependency..."); m_AssetBundleAnalyzerController.Analyze(); m_BuildReport.LogInfo("Analyze assets dependency complete."); m_BuildReport.LogInfo("Start prepare build map..."); AssetBundleBuild[] buildMap = GetBuildMap(); if (buildMap == null || buildMap.Length <= 0) { m_BuildReport.LogError("Build map is empty."); m_BuildReport.SaveReport(); return(false); } m_BuildReport.LogInfo("Prepare build map complete."); m_BuildReport.LogInfo("Start build AssetBundles for selected build targets..."); if (WindowsSelected) { BuildAssetBundles(buildMap, buildAssetBundleOptions, BuildTarget.StandaloneWindows); } if (MacOSXSelected) { #if UNITY_2017_3_OR_NEWER BuildTarget buildTarget = BuildTarget.StandaloneOSX; #else BuildTarget buildTarget = BuildTarget.StandaloneOSXUniversal; #endif BuildAssetBundles(buildMap, buildAssetBundleOptions, buildTarget); } if (IOSSelected) { BuildAssetBundles(buildMap, buildAssetBundleOptions, BuildTarget.iOS); } if (AndroidSelected) { BuildAssetBundles(buildMap, buildAssetBundleOptions, BuildTarget.Android); } if (WindowsStoreSelected) { BuildAssetBundles(buildMap, buildAssetBundleOptions, BuildTarget.WSAPlayer); } ProcessRecord(OutputDirectory); if (m_BuildEventHandler != null) { m_BuildReport.LogInfo("Execute build event handler 'PostProcessBuildAll'..."); m_BuildEventHandler.PostProcessBuildAll(ProductName, CompanyName, GameIdentifier, ApplicableGameVersion, InternalResourceVersion, UnityVersion, buildAssetBundleOptions, OutputDirectory, WorkingPath, OutputPackagePath, OutputZipPath, BuildReportPath); } m_BuildReport.LogInfo("Build AssetBundles for selected build targets complete."); m_BuildReport.SaveReport(); return(true); } catch (Exception exception) { m_BuildReport.LogError(exception.Message); m_BuildReport.SaveReport(); if (BuildAssetBundlesError != null) { BuildAssetBundlesError(exception.Message); } throw exception; return(false); } }
public bool Load() { if (!File.Exists(m_ConfigurationPath)) { return(false); } try { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(m_ConfigurationPath); XmlNode xmlRoot = xmlDocument.SelectSingleNode("UnityGameFramework"); XmlNode xmlEditor = xmlRoot.SelectSingleNode("AssetBundleEditor"); XmlNode xmlSettings = xmlEditor.SelectSingleNode("Settings"); XmlNodeList xmlNodeList = null; XmlNode xmlNode = null; xmlNodeList = xmlSettings.ChildNodes; for (int i = 0; i < xmlNodeList.Count; i++) { xmlNode = xmlNodeList.Item(i); switch (xmlNode.Name) { case "SourceAssetRootPath": SourceAssetRootPath = xmlNode.InnerText; break; case "SourceAssetSearchPaths": m_SourceAssetSearchRelativePaths.Clear(); XmlNodeList xmlNodeListInner = xmlNode.ChildNodes; XmlNode xmlNodeInner = null; for (int j = 0; j < xmlNodeListInner.Count; j++) { xmlNodeInner = xmlNodeListInner.Item(j); if (xmlNodeInner.Name != "SourceAssetSearchPath") { continue; } m_SourceAssetSearchRelativePaths.Add(xmlNodeInner.Attributes.GetNamedItem("RelativePath").Value); } break; case "SourceAssetUnionTypeFilter": SourceAssetUnionTypeFilter = xmlNode.InnerText; break; case "SourceAssetUnionLabelFilter": SourceAssetUnionLabelFilter = xmlNode.InnerText; break; case "SourceAssetExceptTypeFilter": SourceAssetExceptTypeFilter = xmlNode.InnerText; break; case "SourceAssetExceptLabelFilter": SourceAssetExceptLabelFilter = xmlNode.InnerText; break; case "AssetSorter": AssetSorter = (AssetSorterType)Enum.Parse(typeof(AssetSorterType), xmlNode.InnerText); break; } } RefreshSourceAssetSearchPaths(); } catch { File.Delete(m_ConfigurationPath); return(false); } ScanSourceAssets(); m_AssetBundleCollection.Load(); return(true); }