Exemple #1
0
        public void Load(string path, Action onLoaded)
        {
            this.onLoaded = onLoaded;

            if (Application.isEditor)
            {
                //这里开个同步接口 为了单元测试用
                if (File.Exists(path))
                {
                    BDebug.Log("manifest加载成功!");
                    var text = File.ReadAllText(path);
                    this.Manifest = new ManifestConfig(text);
                    this.onLoaded?.Invoke();
                    this.onLoaded = null;
                }
                else
                {
                    Debug.LogError("配置文件不存在:" + path);
                }
            }
            else
            {
                //加载manifest
                IEnumeratorTool.StartCoroutine(IE_LoadConfig(path));
            }
        }
Exemple #2
0
        private IEnumerator IE_LoadConfig(string path)
        {
            string text = "";

            if (File.Exists(path))
            {
                text = File.ReadAllText(path);
            }
            else
            {
                var www = new WWW(path);
                yield return(www);

                if (www.isDone && www.error == null)
                {
                    text = www.text;
                }
                else
                {
                    BDebug.Log("manifest加载失败!   ->" + path, "red");
                }
            }

            if (text != "")
            {
                this.Manifest = new ManifestConfig(text);
                BDebug.Log("manifest加载成功!");
                onLoaded?.Invoke();
                onLoaded = null;
            }
        }
        /// <summary>
        /// 加载menifest 主配置文件
        /// </summary>
        /// <param name="path"></param>
        /// <param name="callback"></param>
        /// <param name="isManiFest"></param>
        /// <returns></returns>
        IEnumerator IELoadManifest(string path, Action <bool> callback)
        {
            if (Application.platform == RuntimePlatform.WindowsEditor ||
                Application.platform == RuntimePlatform.WindowsPlayer)
            {
                path = "file:///" + path;
            }

            BDebug.Log("加载依赖:" + path);
            WWW www = new WWW(path);

            yield return(www);

            if (www.error == null)
            {
                //配置文件
                this.Manifest = new ManifestConfig(www.text);
                if (Manifest != null)
                {
                    callback(true);
                }
                else
                {
                    callback(false);
                }
            }
            else
            {
                Debug.LogError("错误:" + www.error);
            }
        }
Exemple #4
0
        private IEnumerator IE_LoadConfig(string path)
        {
            string text = "";

            if (File.Exists(path))
            {
                text = File.ReadAllText(path);
            }
            else
            {
                var www = new WWW(path);
                yield return(www);

                if (www.isDone && www.error == null)
                {
                    text = www.text;
                }
                else
                {
                    BDebug.Log("manifest加载失败!   ->" + path, "red");
                }
            }

            if (text != "")
            {
                this.Manifest = new ManifestConfig(text);
                BDebug.Log("manifest加载成功!");
                AssetBundlesSet = new HashSet <string>();
                var list = this.Manifest.GetAllAssetBundles();
                foreach (var l in list)
                {
                    AssetBundlesSet.Add(l);
                }

                //回调
                if (OnLoaded != null)
                {
                    OnLoaded();
                    OnLoaded = null;
                }
            }

            yield break;
        }
        /// <summary>
        /// 加载menifest 主配置文件
        /// </summary>
        /// <param name="path"></param>
        /// <param name="callback"></param>
        /// <param name="isManiFest"></param>
        /// <returns></returns>
        IEnumerator IELoadManifest(string path, Action <bool> callback)
        {
            var content = File.ReadAllText(path);

            //Debug.Log("content:"+content);
            this.Manifest = new ManifestConfig(content);
            callback(true);

            yield break;
            if (Application.platform == RuntimePlatform.WindowsEditor ||
                Application.platform == RuntimePlatform.WindowsPlayer)
            {
                path = "file:///" + path;
            }
            else if (Application.platform == RuntimePlatform.Android)
            {
                path = "jar:file://" + path;
            }

            BDebug.Log("加载依赖:" + path);
            //
            UnityWebRequest www = UnityWebRequest.Get(path);

            yield return(www.SendWebRequest());

            if (www.error == null)
            {
                //配置文件
                this.Manifest = new ManifestConfig(www.downloadHandler.text);
                if (Manifest != null)
                {
                    callback(true);
                }
                else
                {
                    callback(false);
                }
            }
            else
            {
                Debug.LogError("错误:" + www.error);
            }
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="path"></param>
 public AssetBundleManifestReference(string path)
 {
     if (Application.isEditor)
     {
         //这里开个同步接口 为了单元测试用
         if (File.Exists(path))
         {
             BDebug.Log("manifest加载成功!");
             var text = File.ReadAllText(path);
             this.Manifest = new ManifestConfig(text);
             OnLoaded?.Invoke();
             OnLoaded = null;
         }
     }
     else
     {
         //加载manifest
         IEnumeratorTool.StartCoroutine(IE_LoadConfig(path));
     }
 }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="path"></param>
        public AssetBundleManifestReference(string path)
        {
            if (File.Exists(path) == false)
            {
                Debug.LogError("manifest不存在:" + path);
                return;
            }

            //加载manifest
            var content = File.ReadAllText(path);

            //Debug.Log("content:"+content);
            this.Manifest = new ManifestConfig(content);
            BDebug.Log("manifest加载成功!");
            AssetBundlesSet = new HashSet <string>();
            var list = this.Manifest.GetAllAssetBundles();

            foreach (var l in list)
            {
                AssetBundlesSet.Add(l);
            }
        }
 public void SetDebugManifest(ManifestConfig config)
 {
     this.config = config;
 }