Ejemplo n.º 1
0
        /// <summary>
        /// 将unity依赖转为自己的
        /// </summary>
        /// <param name="mainfest"></param>
        /// <returns></returns>
        public static DependenciesData Manifest2Dependence(AssetBundleManifest mainfest)
        {
            string[] abNames = mainfest.GetAllAssetBundles();

            List <SingleDepenciesData> singleDatas = new List <SingleDepenciesData>();

            for (int j = 0; j < abNames.Length; j++)
            {
                var dpNames = mainfest.GetDirectDependencies(abNames[j]);
                if (dpNames.Length <= 0)
                {
                    continue;
                }
                singleDatas.Add(new SingleDepenciesData(abNames[j], dpNames));
            }
            var data = new DependenciesData(singleDatas.ToArray());

            return(data);
        }
Ejemplo n.º 2
0
        public AssetBundleLoadHelper(string abPath, string variant, string depenenciesFileName)
        {
            m_ABPath  = string.IsNullOrEmpty(abPath) ? Application.streamingAssetsPath + "/AssetBundles" : abPath;
            m_Variant = string.IsNullOrEmpty(variant) ? ".ab" : "." + variant;

            m_ABDic     = new Dictionary <string, AssetBundle>();
            m_LoadingAB = new Dictionary <string, AssetBundleCreateRequest>();

            string dependencePath = $"{m_ABPath}/{depenenciesFileName}.json";

            if (System.IO.File.Exists(dependencePath))
            {
                string json = System.IO.File.ReadAllText(dependencePath);
                m_DependenceInfo = JsonUtility.FromJson <DependenciesData>(json);
            }
            else
            {
                m_DependenceInfo = new DependenciesData(new SingleDepenciesData[0]);
                Debug.LogWarning($"[AssetBundleHelper] 路径 {m_ABPath} 下无依赖关系");
            }
        }