Beispiel #1
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 #2
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 #3
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 #4
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);
    }