//准备资源
 public bool Prepare()
 {
     //m_AssetBundleCollection.Clear();  //无需清空,Load方法内已情况
     return(m_AssetBundleCollection.Load());
 }
コード例 #2
0
        public event GameFrameworkAction <SourceAsset[]> EventOnAssetUnassigned = null; //取消分配资源的事件

        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":      //要筛选并包含的资源类型
                        m_SourceAssetUnionTypeFilter = xmlNode.InnerText;
                        break;

                    case "SourceAssetUnionLabelFilter":     //要筛选并包含的标签类型,默认会包含带有 AssetBundleInclusive 标签(l:AssetBundleInclusive)的资源。
                        m_SourceAssetUnionLabelFilter = xmlNode.InnerText;
                        break;

                    case "SourceAssetExceptTypeFilter":     //要筛选并排除的资源类型,默认会排除脚本(t:Script)资源
                        m_SourceAssetExceptTypeFilter = xmlNode.InnerText;
                        break;

                    case "SourceAssetExceptLabelFilter":        //要筛选并排除的标签类型,默认会排除带有 AssetBundleExclusive 标签(l:AssetBundleExclusive)的资源。
                        m_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);
        }