Example #1
0
        public void InitAssetManager(GameObject go, System.Action callback)
        {
            //首先加载 资产加载路径清单
            string assetLoadConfigXml = "";

            if (!File.Exists(PUBLIC_PATH_DEFINE.AssetLoadConfigListPath) || //若读写路径中不存在资源配置文件,则拷贝包中自带的文件。
                !Version.CheckMainVersionNum())                             //若主版本号不同,则拷贝
            {
                RawAssetsMover.MoveAssetConfig2IOPath(PUBLIC_PATH_DEFINE.RawAssetLoadConfigListPath, PUBLIC_PATH_DEFINE.AssetLoadConfigListPath, true);
            }

            StreamReader sr = File.OpenText(PUBLIC_PATH_DEFINE.AssetLoadConfigListPath);

            using (sr)
            {
                assetLoadConfigXml = sr.ReadToEnd();
            }

            //DebugConsole.Log("xml = " + assetLoadConfigXml, DebugConsole.Color.green);
            BundleAssetConfig.Instance.Load(assetLoadConfigXml);

            //创建Bundle Provider
            bundleAssetProvider = go.AddComponent <BundleAssetProvider>();

            bundleAssetProvider.LoadCommon("common", callback);
        }
Example #2
0
    public static void GenAssetsMenu()
    {
        string[] assetsMenu = AssetDatabase.GetAllAssetPaths();

        Dictionary <string, BundleAssetConfigTableData> assetsData = new Dictionary <string, BundleAssetConfigTableData>();

        foreach (var s in assetsMenu)
        {//遍历Assets资产库下所有路径
            //过滤
            bool pass = false;
            foreach (var f in filterConfig)
            {
                if (s.Contains(f))
                {
                    pass = true;
                    break;
                }
            }

            //生成资产目录文件
            if (!pass)
            {
                if (!File.Exists(s))
                {//文件存在验证
                    //DebugConsole.LogError("file doesn't exists path = " + s);
                    continue;
                }

                if (s.Contains("Resources"))
                {//resources data
                    //DebugConsole.Log("Resources Assets Path = " + s);
                    AddData(s, AssetType.ResourcesAsset, ref assetsData);
                }
                else if (s.Contains("AssetBundles/Raw"))
                {//bundle data
                    //DebugConsole.Log("StreamingAssets Assets Path = " + s);
                    AddData(s, AssetType.BundleAsset, ref assetsData);
                }
            }
        }

        //生成配置
        GenAssetMenuFile(PUBLIC_PATH_DEFINE.RawAssetLoadConfigListGenPath, assetsData.Values);
#if UNITY_EDITOR
        // Editor下强制更新资产库
        RawAssetsMover.MoveAssetConfig2IOPath(PUBLIC_PATH_DEFINE.RawAssetLoadConfigListPath, Application.persistentDataPath + "/AssetLoadConfigList.xml", true);
        DebugConsole.Log("本地资产清单已输出到:" + Application.persistentDataPath);
#endif
    }
Example #3
0
 /// <summary>
 /// 检测版本,拷贝资源
 /// </summary>
 /// <param name="mono">Monobehavior环境</param>
 /// <param name="callback">回调</param>
 public static void CheckVersionAndCopyAssets(MonoBehaviour mono, Action callback)
 {
     try
     {
         if (!Version.CheckMainVersionNum())   //主版本号不同移动资源
         {
             RawAssetsMover.MoveStreamingAssets2IOPath(mono, PUBLIC_PATH_DEFINE.StreamingAssetsPath, PUBLIC_PATH_DEFINE.AssetBundlesRootPath, callback);
             DebugConsole.Log("拷贝 ./StreamingAsset/ 下的资源");
         }
         else
         {//不需移动资源直接调用回调
             if (callback != null)
             {
                 callback.Invoke();
             }
         }
     }
     catch (Exception ex)
     {
         DebugConsole.LogError(ex.Message);
         DebugConsole.LogError(ex.StackTrace);
     }
 }
Example #4
0
 public static void MoveAssetMenu()
 {
     RawAssetsMover.MoveAssetConfig2IOPath(PUBLIC_PATH_DEFINE.RawAssetLoadConfigListPath, Application.persistentDataPath + "/AssetsLoadConfigList.xml", true);
     DebugConsole.Log("本地资产清单已输出到:" + Application.persistentDataPath);
 }