예제 #1
0
    /// <summary>
    /// 读取预加载信息,这个信息可以读取不到。
    /// </summary>
    private void TryLoadPreloadInfo()
    {
        //这不是一个必须读取成功的文件
        try
        {
            var abpi = ABSettingHelper.GetDataAnalysisXmlMoveTargetABPI();
            var ab   = AssetBundle.LoadFromFile(abpi.FullName);

            if (ab != null)
            {
                var asset = ab.LoadAsset <TextAsset>(abpi.NameWithExt);
                if (asset != null)
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(asset.text);
                    AssetBundleUseAnalysis.LoadPreloadInfo(doc);
                }
                else
                {
                    Debug.LogWarning(@"if (asset != null) : " + abpi.FullName + " Res: " + abpi.NameWithExt);
                }
                ab.Unload(false);
            }
            else
            {
                Debug.LogWarning(@"if (ab != null) : " + abpi.FullName);
                throw new NullReferenceException("if(ab != null):" + abpi.FullName);
            }


//          using (WWW www = new WWW(abpi.URI))
//          {
//              if (www.error != null)
//              {
//                  //Debug.Assert(false, "www.error != null " + www.error);
//                  Debug.LogWarning(@"www.error != null " + www.error);
//              }
//              else
//              {
//                  if (www.assetBundle != null)
//                  {
//                      var asset = www.assetBundle.LoadAsset<TextAsset>(abpi.NameWithExt);
//                      if (asset != null)
//                      {
//                          XmlDocument doc = new XmlDocument();
//                          doc.LoadXml(asset.text);
//                          AssetBundleUseAnalysis.LoadPreloadInfo(doc);
//                      }
//                      else
//                      {
//                          Debug.LogWarning(@"if (asset != null) : " + abpi.FullName + " Res: " + abpi.NameWithExt);
//                      }
//                      www.assetBundle.Unload(false);
//                  }
//                  else
//                  {
//                      Debug.LogWarning(@"if (www.assetBundle != null) : " + abpi.FullName);
//                  }
//              }
//          }
        }
        catch (Exception e)
        {
            Debug.LogWarning(e);
        }
    }