示例#1
0
 /// <summary>
 /// 加载assetbundle 映射表
 /// file map assetbundle name
 /// </summary>
 private void LoadAssetBundleMapping()
 {
     LoadAssetFromBundle(ConstantData.assetBundleMappingName, ConstantData.assetBundleMappingName, typeof(AssetBundleMapping), (data) =>
     {
         m_Mapping = data as AssetBundleMapping;
         if (null != m_Mapping)
         {
             m_Mapping.Init();
         }
     }, false, false, true);
 }
示例#2
0
文件: LoadMgr.cs 项目: 741645596/Golf
        /*private void InitVersionData(bool start = true)
         * {
         *  Clear();
         *
         *  m_origns.Clear();
         *  for (int i = 0; i < VersionData.Inst.Items.Length; ++i)
         *  {
         *      VersionData.VersionItem item = VersionData.Inst.Items[i];
         *      m_origns.Add(item.Name, item.Md5);
         *  }
         *
         *  if (start)
         *  {
         *      LoadManifest();
         *  }
         * }*/

        /*public void SetPatchData(JSONClass list, bool clear = false)
         * {
         *  if (clear)
         *  {
         *      Clear();
         *  }
         *
         *  m_patchs.Clear();
         *  if (list != null)
         *  {
         *      foreach (KeyValuePair<string, JSONNode> item in list)
         *      {
         *          m_patchs.Add(item.Key, item.Value["md5"]);
         *      }
         *  }
         *
         *  LoadManifest();
         * }*/

        /*private void LoadVersion()
         * {
         *  Logger.Log("LoadVersion");
         *  if (ConstantData.EnableMd5Name)
         *  {
         *      string pathPatch = string.Format("{0}/version_patch", Application.persistentDataPath);
         *      bool hasPatch = false;
         *
         *      if (ConstantData.EnablePatch)
         *      {
         *          hasPatch = File.Exists(pathPatch);
         *      }
         *
         *      InitVersionData(!hasPatch);
         *
         *      if (hasPatch)
         *      {
         *          LoadStream(pathPatch, (data) =>
         *          {
         *              byte[] bytes = data as byte[];
         *              if (bytes == null)
         *              {
         *                  Logger.LogError("Load patch version Failed!");
         *                  return;
         *              }
         *
         *              string text = Encoding.UTF8.GetString(bytes);
         *              JSONClass json = JSONNode.Parse(text) as JSONClass;
         *              if (json == null)
         *              {
         *                  Logger.LogError("Load patch version Failed!");
         *                  return;
         *              }
         *
         *              JSONClass jsonList = null;
         *              if (string.Equals(json["version"], LogicConstantData.Version))
         *              {
         *                  jsonList = json["list"] as JSONClass;
         *              }
         *
         *              m_urlPatch = json["url"];
         *              SetPatchData(jsonList);
         *          }, false, false, true);
         *      }
         *  }
         *  else
         *  {
         *      LoadManifest();
         *  }
         * }*/

        // 加载资源清单
        private void LoadManifest()
        {
            Logger.Log("LoadManifest");

            if (m_manifest != null)
            {
                Object.DestroyImmediate(m_manifest, true);
                m_manifest = null;
            }

            if (m_mapping != null)
            {
                Object.DestroyImmediate(m_mapping, true);
                m_mapping = null;
            }

            // 加载AssetBundle依赖文件
            LoadAssetBundle(null, ConstantData.AssetbundleManifest, (group, data) => {
                AssetBundleInfo ab = data as AssetBundleInfo;
                if (ab != null)
                {
                    m_manifest = ab.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
                }
            }, false, false, false);

            // 加载资源到AssetBundle映射表
            string name = ConstantData.AssetbundleMapping;

            LoadAssetFromBundle(null, name, name, typeof(AssetBundleMapping), (group, data) => {
                m_mapping = data as AssetBundleMapping;
                if (m_mapping != null)
                {
                    m_mapping.Init();
                }
            }, false);

            Logger.Log("LoadManifest End");
        }