Beispiel #1
0
        IEnumerator OnUpdateResource()
        {
            string random      = DateTime.Now.ToString("yyyymmddhhmmss");
            string versionFile = SAGameVersion.asset_path + SAAppConfig.LanguagePlatform + "/" + MD5_NAME + "?rd=" + random;

            WWW www = new WWW(versionFile);

            yield return(www);

            if (www.error != null)
            {
                //抱错喽~~~
                print("抱错喽~~~ : " + versionFile);
                yield break;
            }
            SAUtils.Log("文件加载完毕");
            convertXML        = SALang.stringConvertXML(www.text);//等待写入
            newVersion        = getXmlToDictionary(convertXML.DocumentElement.ChildNodes);
            progressData.info = "更新资源...";

            resListEN  = newVersion.GetEnumerator();
            totalNum   = newVersion.Count;
            currentNum = 0;
            dispatchEvent(SAACollection.REFRESH + ActionCollection.LocalFile);
            yield return(StartCoroutine(download()));
        }
Beispiel #2
0
        private void downloadComplete()
        {
            StopAllCoroutines();
            SALang.MakDirValid(SAAppConfig.RemotePath);

            convertXML.Save(Path.Combine(SAAppConfig.RemotePath, MD5_NAME));//写入本地最新XML
            version = newVersion;
            //资源缓存
            SACache.LoadLuaPackage(SAAppConfig.RemotePath, SAAppConfig.LanguagePlatform + "/" + SAAppConfig.LuaPathName); //lua 缓存
            //unity资源
            abs          = new AssetBundle[(version.Count - 3) / 2 + 2];                                                  //Platform Platform.manifest lua.bytes other.manifest
            abs_position = 0;
            //shader
            loadAssetBundleManifest(SAAppConfig.LanguagePlatform + "s");
            //资源
            loadAssetBundleManifest(SAAppConfig.LanguagePlatform);
            for (int i = 0; i < abs.Length; ++i)
            {
                if (null != abs[i])
                {
                    abs[i].Unload(false);
                    abs[i] = null;
                }
            }
            SACache.getResDictionary(SAACollection.AtlasStr).Clear();

            abs_position = 0;
            removeEventDispatcher(SAACollection.REFRESH + ActionCollection.LocalFile);                  //资源加载
            dispatchEvent(SAACollection.REFRESH + ActionCollection.LocalFile + SAACollection.COMPLETE); //更新完成
        }
Beispiel #3
0
    static private bool _PackStreamDatas(string ext, int encrypt)
    {
        string outputFilename = SALang.NormalizePath(Path.Combine(SAAppConfig.DevResDir, SAAppConfig.LuaByteDir));
        string inputDir       = SALang.NormalizePath(SAAppConfig.DevLuaDir);

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

        extNames.AddRange(ext.Split(';'));
        Debug.Log("_PackStreamDatas");
        return(VfsPack.PackFile(outputFilename, inputDir, extNames, encrypt) > 0);
    }
Beispiel #4
0
    private void ReleaseFile(BuildTarget target, string fileName)
    {
        string path = Path.Combine(SAAppConfig.DevResDir, SAAppConfig.DataDir) + fileName;

        FileInfo fileInfo       = new FileInfo(path);
        string   AbsReleasePath = BuildPipelinePanel.GetPlatformAbsReleasePath(target);

        SALang.MakDirValid(AbsReleasePath);
        path = Path.Combine(AbsReleasePath, fileName);
        SALang.ForceDeleteFile(path);
        fileInfo.CopyTo(path);
    }
Beispiel #5
0
        private IEnumerator download()
        {
            if (resListEN.MoveNext())
            {
                string fileKey = resListEN.Current.Key;
                localFilePath = Path.Combine(SAAppConfig.RemotePath, fileKey);
                bool isExist = File.Exists(localFilePath);//判断本地文件

                progressData.info = "正在更新资源 : " + fileKey;
                dispatchEvent(SAACollection.REFRESH + ActionCollection.LocalFile);
                if (isExist)
                {
                    isExist = version.ContainsKey(fileKey) && version[fileKey].Equals(resListEN.Current.Value);
                    if (!isExist)
                    {
                        File.Delete(localFilePath);
                    }
                }
                if (!isExist)//需要下载
                {
                    progressData.name = resListEN.Current.Key;
                    stopWatch.Start();
                    //loadFileWithName(fileKey);
                    string remoteFilePath = SAGameVersion.asset_path + fileKey;
                    WWW    www            = new WWW(remoteFilePath);
                    yield return(www);

                    if (www.error != null)
                    {
                        //抱错喽~~~
                        SAUtils.Log("抱错喽~~~ : " + remoteFilePath);
                        yield break;
                    }
                    SALang.writeLocalByteWithName(www.bytes, resListEN.Current.Key);
                }
                ++currentNum;
                yield return(StartCoroutine(download()));
            }
            else
            {
                progressData.info = "更新完毕";
                dispatchEvent(SAACollection.REFRESH + ActionCollection.LocalFile);
                downloadComplete();
            }
        }
Beispiel #6
0
 /// <summary>
 /// 更新本地版本信息缓存
 /// </summary>
 protected void refreshLocalVersionInfo()
 {
     SAUtils.Log("refresh version...");
     //获取当前(旧的)版本
     version = getXmlToDictionary(SALang.getLocalXMLWithName(MD5_NAME).DocumentElement.ChildNodes);
     //加载远程(最新)版本信息
     progressData.info = "加载版本文件信息...";
     addEventDispatcherWithHandle(SAACollection.REFRESH + ActionCollection.LocalFile + SAACollection.COMPLETE, updateLocalFileComplete);//资源加载完成
     //加载
     if (SAAppConfig.UIRelease)
     {
         addEventDispatcherWithHandle(SAACollection.REFRESH + ActionCollection.LocalFile, updateLocalFile);//资源加载
         StartCoroutine(OnUpdateResource());
     }
     else
     {
         dispatchEvent(SAACollection.REFRESH + ActionCollection.LocalFile + SAACollection.COMPLETE);//更新完成
     }
 }
Beispiel #7
0
    private static void CopyFolder(string source, string target)
    {
        SALang.MakDirValid(target);

        DirectoryInfo direcInfo = new DirectoryInfo(source);

        FileInfo[] files = direcInfo.GetFiles();

        foreach (FileInfo file in files)
        {
            string   filename = Path.Combine(target, file.Name);
            FileInfo fi       = file.CopyTo(filename, true);
            fi.Attributes = FileAttributes.Normal;
        }

        DirectoryInfo[] direcInfoArr = direcInfo.GetDirectories();
        foreach (DirectoryInfo dir in direcInfoArr)
        {
            CopyFolder(Path.Combine(source, dir.Name), Path.Combine(target, dir.Name));
        }
    }
Beispiel #8
0
 public void removeListenerButtonClick(GameObject button)
 {
     SALang.removeListenerButtonClick(button);
 }
Beispiel #9
0
 public void addListenerButtonClick(GameObject button, LuaFunction luafunc)
 {
     SALang.addListenerButtonClick(button, luafunc);
 }
Beispiel #10
0
    public static bool Execute(UnityEditor.BuildTarget target, BuildAssetBundleOptions bbo, string ext, string[] dirs, string[] extNames, bool fixedAssetName, string assetName)
    {
        string ReleasePath    = BuildPipelinePanel.GetPlatformReleasePath(target, ext);    //相对路径
        string AbsReleasePath = BuildPipelinePanel.GetPlatformAbsReleasePath(target, ext); //绝对路径

        SALang.MakDirValid(AbsReleasePath);
        string rootDir = SALang.NormalizePath(SAAppConfig.DevResDir);// 根目录
        int    dirLen  = dirs.Length;
        int    fileLen;
        int    i = 0, j;
        string searchDir;

        string[]      filePaths;
        List <string> files;

        string[] resourcesAssets;
        List <AssetBundleBuild> abbs = new List <AssetBundleBuild>();
        AssetBundleBuild        abb;
        string assetsFullPath;

        for (; i < dirLen; ++i)
        {
            searchDir = Path.Combine(rootDir, dirs[i]);
            filePaths = SALang.GetFileList(searchDir, extNames[i], true);
            if (null == filePaths || filePaths.Length == 0)
            {
                Debug.Log(string.Format("目录{0}没有需要打包的文件...", searchDir));
                continue;
            }
            files = new List <string>();
            files.AddRange(filePaths);

            fileLen = filePaths.Length;
            int languageDot;
            //所有文件
            for (j = 0; j < fileLen; ++j)
            {
                string filename = SALang.NormalizePath(filePaths[j]);                 //绝对路径
                if (filename.Substring(filename.LastIndexOf(".") + 1).Equals("meta")) //验证后缀
                {
                    continue;
                }
                assetsFullPath = filename.Replace(SAAppConfig.DevResDir, "");        //转换为相对路径
                filename       = ConvertToAssetBundleName(assetsFullPath).ToLower(); //转换为

                languageDot = filename.LastIndexOf(".", filename.LastIndexOf(".") - 1);
                string language = filename.Substring(languageDot + 1, SAAppConfig.Language.Length);
                if (!language.Equals(SAAppConfig.Language))
                {
                    continue;
                }
                if (dirs[i].Equals(SAAppConfig.LuaByteDir) || dirs[i].Equals(SAAppConfig.DataDir))
                {
                    filename       = filename.Substring(filename.IndexOf(".") + 1);
                    assetsFullPath = Path.Combine(AbsReleasePath, filename);
                    FileInfo fileInfo = new FileInfo(filePaths[j]);
                    SALang.ForceDeleteFile(assetsFullPath);
                    fileInfo.CopyTo(assetsFullPath, false);
                }
                else
                {
                    //filename += ".sa";
                    resourcesAssets    = new string[1];
                    resourcesAssets[0] = Path.Combine(SAAppConfig.LocalDevDir, assetsFullPath);
                    DoSetAssetBundleName(filePaths[j] + ".meta", filename);
                    abb = new AssetBundleBuild();
                    abb.assetBundleName = fixedAssetName ? assetName : filename;
                    abb.assetNames      = resourcesAssets;
                    abbs.Add(abb);
                }
            }
        }
        BuildPipeline.BuildAssetBundles(ReleasePath, abbs.ToArray(), bbo, target);
        AssetDatabase.Refresh();
        return(true);
    }