예제 #1
0
    /// <summary>
    /// 删除所有可下载信息
    /// </summary>
    public static void ClearAllInfoDown()
    {
        string outPath = QPathHelper.GetAssetBundleOutPath() + "/" + Modules;

        Directory.Delete(outPath, true);
        File.Delete(outPath + ".meta");
    }
예제 #2
0
    static void BundleAndroidAB()
    {
        string outPath = QPathHelper.GetAssetBundleOutPath();

//        Debug.Log("path: " + outPath);
        BuildPipeline.BuildAssetBundles(outPath, 0, target);
        Debug.Log("打包成功");
        AssetDatabase.Refresh();
    }
예제 #3
0
    static void CreatFiles()
    {
        //创建各个文件的版本标识
        string outPath = QPathHelper.GetAssetBundleOutPath() + "/" + Modules;
        string file    = outPath + "/files.txt";

        if (File.Exists(file))
        {
            File.Delete(file);
        }

        List <string> pathList = new List <string>();

        DirectoryInfo Direinfo = new DirectoryInfo(outPath);

        GetAllFileName(Direinfo, ref pathList, "concretegame", new List <string>()
        {
            "ModulesConfig.txt", "concretegameConfig.txt"
        });

        FileStream   fs    = new FileStream(file, FileMode.CreateNew);
        StreamWriter sw    = new StreamWriter(fs);
        Hashtable    jd    = new Hashtable();
        Hashtable    files = new Hashtable();

        foreach (var info in pathList)
        {
            string md5 = GetFileMd5(info);

            string fileName = info.Replace(outPath + "/", string.Empty);
            fileName        = Modules + "/" + fileName;
            files[fileName] = md5;
        }
        files[Modules + "/files.txt"] = System.DateTime.Now.ToString();
        files["ModulesConfig.txt"]    = System.DateTime.Now.ToString();
        jd ["files"] = files;
        sw.Write(MiniJSON.jsonEncode(jd));
        sw.Close();
        fs.Close();

        Debug.Log(Modules + "创建文本标识成功");
        AssetDatabase.Refresh();
    }
예제 #4
0
    void initFinsh()
    {
        string mcfgPath = QPathHelper.GetAssetBundleOutPath() + "/ModulesConfig.txt";

        if (!System.IO.File.Exists(mcfgPath))
        {
            Debug.Log("[AppMng.Init]未检测到ModulesConfig文件,开始拷贝资源文件夹");
            ABTool.Download(Application.streamingAssetsPath + "/" + QPathHelper.GetPlatformName(), "hall/files.txt", "...", (val) =>
            {
                Debug.LogFormat("[AppMng.Init]正在拷贝hall资源文件,已完成:{0}%", val * 100);
                if (val == 1)
                {
                    DataMng.Instance.ReadText(mcfgPath, (_mcfg_json) =>
                    {
                        byte downCount = 0;
                        Hashtable mcfg = MiniJSON.jsonDecode(_mcfg_json) as Hashtable;
                        Hashtable ms   = mcfg["ms"] as Hashtable;
                        foreach (var jd in ms.Values)
                        {
                            string modules = (jd as Hashtable) ["modules"].ToString();
                            ABTool.Download(Application.streamingAssetsPath + "/" + QPathHelper.GetPlatformName(), modules + "/files.txt", "...", (_val) =>
                            {
                                Debug.LogFormat("[AppMng.Init]正在拷贝{1}资源文件,已完成:{0}%", _val * 100, modules);
                                if (_val == 1)
                                {
                                    downCount++;
                                    if (downCount == ms.Count)
                                    {
                                        checkUpdates();
                                    }
                                }
                            });
                        }
                    });
                }
            });
        }
        else
        {
            checkUpdates();
        }
    }
예제 #5
0
    static void loadGO()
    {
        if (loadGOs.Count == 0)
        {
            return;
        }
        LoadGOData  data    = loadGOs[0];
        string      ab_name = QPathHelper.GetAssetBundleOutPath() + data.Path;
        AssetBundle ab      = null;

        if (ab_dict.ContainsKey(ab_name))
        {
            ab = ab_dict[ab_name];
        }
        else
        {
            ab = AssetBundle.LoadFromFile(ab_name);
            ab_dict.Add(ab_name, ab);
        }
        if (ab != null)
        {
            GameObject go = ab.LoadAsset <GameObject> (data.Name);
            if (go != null)
            {
                data.Callback(go);
            }
            else
            {
                Debug.LogErrorFormat("[ABTool.loadGO]资源加载为空:{0}.{1}", data.Path, data.Name);
            }
        }
        else
        {
            Debug.LogError("[ABTool.loadGO]资源加载为空:" + data.Path);
        }
        loadGOs.RemoveAt(0);
        loadGO();
    }
예제 #6
0
    public static LuaTable LoadSprieList(string _path, LuaTable _tab)
    {
        string      ab_name = QPathHelper.GetAssetBundleOutPath() + _path;
        AssetBundle ab      = null;

        if (ab_dict.ContainsKey(ab_name))
        {
            ab = ab_dict[ab_name];
        }
        else
        {
            ab = AssetBundle.LoadFromFile(ab_name);
            ab_dict.Add(ab_name, ab);
        }
        if (ab != null)
        {
            LuaTable sprites = AppMng.luaEnv.NewTable();
            _tab.ForEach <int, string> ((k, v) =>
            {
                Sprite go = ab.LoadAsset <Sprite> (v);
                if (go != null)
                {
                    sprites.Set <string, Sprite> (v, go);
                }
                else
                {
                    Debug.LogErrorFormat("[ABTool.LoadSprieList]资源加载为空:{0}.{1}", _path, v);
                }
            });
            return(sprites);
        }
        else
        {
            Debug.LogError("[ABTool.LoadSprieList]资源加载为空:" + _path);
            return(null);
        }
    }
예제 #7
0
    IEnumerator download(string _newFileIP, string _newFilesPath, string _oldFilesPath, Action <float> _peogress)
    {
        string newFilesJson;
        string loadNewFileUrl = _newFileIP + "/" + _newFilesPath;

        if (loadNewFileUrl.IndexOf("file:///") == -1 && loadNewFileUrl.IndexOf("http") != 0)
        {
            loadNewFileUrl = "file:///" + loadNewFileUrl;
        }
        using (WWW loadNewFiles = new WWW(loadNewFileUrl))
        {
            yield return(loadNewFiles);

            if (!string.IsNullOrEmpty(loadNewFiles.error))
            {
                HttpSerMng.Instance.HttpErr(loadNewFiles.url, "[ABDownLoad.download]文件下载失败:" + loadNewFiles.error);
            }
            newFilesJson = loadNewFiles.text;
            loadNewFiles.Dispose();
        }

        string oldFilesJson;

        if (_oldFilesPath.IndexOf("file:///") == -1 && _oldFilesPath.IndexOf("http") != 0)
        {
            _oldFilesPath = "file:///" + _oldFilesPath;
        }
        using (WWW loadOldFiles = new  WWW(_oldFilesPath))
        {
            yield return(loadOldFiles);

            oldFilesJson = loadOldFiles.text;
            loadOldFiles.Dispose();
        }

        Hashtable kvs_new = null, kvs_old = null;

        kvs_new = (MiniJSON.jsonDecode(newFilesJson) as Hashtable) ["files"] as Hashtable;
        if (!string.IsNullOrEmpty(oldFilesJson))
        {
            kvs_old = (MiniJSON.jsonDecode(oldFilesJson) as Hashtable) ["files"] as Hashtable;
        }

        foreach (string k in kvs_new.Keys)
        {
            if (kvs_old == null || !kvs_old.Contains(k) || kvs_new[k].ToString() != kvs_old[k].ToString())
            {
                string filePath = QPathHelper.GetAssetBundleOutPath() + "/" + k;
                InitABFile(filePath);
                string downUrl = _newFileIP + "/" + k;
                if (downUrl.IndexOf("file:///") == -1 && downUrl.IndexOf("http") != 0)
                {
                    downUrl = "file:///" + downUrl;
                }
                using (UnityWebRequest uwr = new UnityWebRequest(downUrl))
                {
                    uwr.downloadHandler = new DownloadHandlerFile(filePath);
                    yield return(uwr.SendWebRequest());

                    if (!string.IsNullOrEmpty(uwr.error))
                    {
                        HttpSerMng.Instance.HttpErr(uwr.url, "[ABDownLoad.download]文件下载失败:" + uwr.error);
                    }
                }
            }
            m_downCount++;
            if (_peogress != null)
            {
                _peogress(m_downCount / kvs_new.Keys.Count);
            }
        }
        Destroy(this);
    }