public override void OverrideBuild(string outpathRoot, List <AssetBundleBuild> filteredBuildInfos)
        {
            for (int i = filteredBuildInfos.Count - 1; i >= 0; --i)
            {
                var buildInfo = filteredBuildInfos[i];
                // Remove runtime textures from buildInfos
                if (buildInfo.assetBundleName.StartsWith("Assets/" + ResConfig.UI_TEXTURE_RUNTIME) ||
                    buildInfo.assetBundleName.StartsWith(ResConfig.DEPENDENCIES_ROOT + "/" + ResConfig.UI_TEXTURE_RUNTIME))
                {
                    filteredBuildInfos.RemoveAt(i);
                }
            }

            var resPath = Application.dataPath + "/" + ResConfig.UI_TEXTURE_RUNTIME;
            var files   = ResBuildUtility.GetFiles(resPath);

            foreach (var file in files)
            {
                if (file.EndsWith(".png") == false &&
                    file.EndsWith(".jpg") == false)
                {
                    continue;
                }

                var fileName        = Path.GetFileName(file);
                var assetBundleName = file.ReplaceFirst(_rootPath + "/", "");
                assetBundleName = assetBundleName.ReplaceLast("/" + fileName, "").ReplaceFirst("Assets/", "") + ResConfig.BUNDLE_EXTENSION;
                var assetName = file.ReplaceFirst(_rootPath + "/", "");

                var index = ResBuildUtility.TryGetBuildInfo(filteredBuildInfos, assetBundleName);
                if (index == -1)
                {
                    var buildInfo = new AssetBundleBuild();
                    buildInfo.assetNames      = new string[] { assetName };
                    buildInfo.assetBundleName = assetBundleName;
                    filteredBuildInfos.Add(buildInfo);
                }
                else
                {
                    var buildInfo  = filteredBuildInfos[index];
                    var assetNames = buildInfo.assetNames.ToList();
                    if (assetNames.Contains(assetName))
                    {
                        continue;
                    }

                    assetNames.Add(assetName);
                    buildInfo.assetNames      = assetNames.ToArray();
                    filteredBuildInfos[index] = buildInfo;
                }
            }
        }
Beispiel #2
0
        public override void OverrideBuild(string outpathRoot, List <AssetBundleBuild> filteredBuildInfos)
        {
            for (int i = filteredBuildInfos.Count - 1; i >= 0; --i)
            {
                var buildInfo = filteredBuildInfos[i];
                if (buildInfo.assetBundleName.StartsWith("Assets/" + ResConfig.RES_ROOT + "/" + ResConfig.LUA_ROOT) ||
                    buildInfo.assetBundleName.StartsWith(ResConfig.DEPENDENCIES_ROOT + "/" + ResConfig.RES_ROOT + "/" + ResConfig.LUA_ROOT))
                {
                    filteredBuildInfos.RemoveAt(i);
                }
            }

            var resPath = Application.dataPath + "/" + ResConfig.RES_ROOT + "/" + ResConfig.LUA_ROOT;
            var files   = ResBuildUtility.GetFiles(resPath);

            _tmpFiles.Clear();

            foreach (var file in files)
            {
                if (file.EndsWith(ResConfig.LUA_EXTENSION) == false)
                {
                    continue;
                }

                var sourceFile = file;
                var targetFile = sourceFile.ReplaceLast(ResConfig.LUA_EXTENSION, ResConfig.MOBILE_LUA_EXTENSION);

                if (File.Exists(targetFile))
                {
                    File.Delete(targetFile);
                }
                File.Copy(sourceFile, targetFile);
                _tmpFiles.Add(targetFile);

                var assetBundleName = targetFile.ReplaceFirst(Application.dataPath + "/" + ResConfig.RES_ROOT + "/", "") + ResConfig.BUNDLE_EXTENSION;
                var assetName       = targetFile.ReplaceFirst(_rootPath + "/", "");

                var index = ResBuildUtility.TryGetBuildInfo(filteredBuildInfos, assetBundleName);
                if (index == -1)
                {
                    var buildInfo = new AssetBundleBuild();
                    buildInfo.assetNames      = new string[] { assetName };
                    buildInfo.assetBundleName = assetBundleName;
                    filteredBuildInfos.Add(buildInfo);

                    LogManager.Log("lua assetbundle " + assetBundleName);
                }
                else
                {
                    var buildInfo  = filteredBuildInfos[index];
                    var assetNames = buildInfo.assetNames.ToList();
                    if (assetNames.Contains(assetName))
                    {
                        continue;
                    }

                    assetNames.Add(assetName);
                    buildInfo.assetNames      = assetNames.ToArray();
                    filteredBuildInfos[index] = buildInfo;

                    LogManager.Log("lua assetbundle " + assetBundleName);
                }
            }
            AssetDatabase.Refresh();
        }