|
1.导入插件
https://pan.baidu.com/s/1dH0mBW
2.自动打包
##修改Packager脚本的HandleExampleBundle方法
staticvoid HandleExampleBundle(BuildTarget target) { Object mainAsset = null; //主素材名,单个 Object[] addis = null; //附加素材名,多个string assetfile = string.Empty; //素材文件名 BuildAssetBundleOptions options = BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.DeterministicAssetBundle; string dataPath = Util.DataPath; if (Directory.Exists(dataPath)) { Directory.Delete(dataPath, true); } string assetPath = AppDataPath + "/StreamingAssets/"; if (Directory.Exists(dataPath)) { Directory.Delete(assetPath, true); } if (!Directory.Exists(assetPath)) Directory.CreateDirectory(assetPath); /////-----------------------------生成共享的关联性素材绑定-------------------------------------//BuildPipeline.PushAssetDependencies();//assetfile = assetPath + "shared" + AppConst.ExtName;//mainAsset = LoadAsset("Shared/Atlas/Dialog.prefab");//BuildPipeline.BuildAssetBundle(mainAsset, null, assetfile, options, target);/////------------------------------生成PromptPanel素材绑定-----------------------------------//BuildPipeline.PushAssetDependencies();//mainAsset = LoadAsset("Prompt/Prefabs/PromptPanel.prefab");//addis = new Object[1];//addis[0] = LoadAsset("Prompt/Prefabs/PromptItem.prefab");//assetfile = assetPath + "prompt" + AppConst.ExtName;//BuildPipeline.BuildAssetBundle(mainAsset, addis, assetfile, options, target);//BuildPipeline.PopAssetDependencies();/////------------------------------生成MessagePanel素材绑定-----------------------------------//BuildPipeline.PushAssetDependencies();//mainAsset = LoadAsset("Message/Prefabs/MessagePanel.prefab");//assetfile = assetPath + "message" + AppConst.ExtName;//BuildPipeline.BuildAssetBundle(mainAsset, null, assetfile, options, target);//BuildPipeline.PopAssetDependencies();/////-------------------------------刷新---------------------------------------//BuildPipeline.PopAssetDependencies();//////////////////////////////////////////////////////////////////////////////string content = File.ReadAllText(Application.dataPath + "/AssetBundleInfo.csv"); string[] contents = content.Split(newstring[] { "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < contents.Length; i++) { string[] a = contents.Split(','); //UnityEngine.Debug.Log(a[0]); UnityEngine.Debug.Log(a[1]); UnityEngine.Debug.Log(a[2]); AddBuildMap(a[0], a[1], a[2]); } string resPath = "Assets/" + "StreamingAssets"; BuildAssetBundleOptions option = BuildAssetBundleOptions.DeterministicAssetBundle | BuildAssetBundleOptions.UncompressedAssetBundle; BuildPipeline.BuildAssetBundles(resPath, maps.ToArray(), option, target); maps.Clear(); } static List<AssetBundleBuild> maps = new List<AssetBundleBuild>(); staticvoid AddBuildMap(string bundleName, string pattern, string path) { string[] files = Directory.GetFiles(path, pattern); if (files.Length == 0) return; for (int i = 0; i < files.Length; i++) { files = files.Replace('\\', '/'); } AssetBundleBuild build = new AssetBundleBuild(); build.assetBundleName = bundleName; build.assetNames = files; maps.Add(build); }
,每一次打包,先点击LuaFramework/AddBuildMapUtility,准备好AB包的信息,然后点击LuaFramework/Build xxx Resource来进行打包,在window平台下,检查Assets\StreamingAssets中的资源是否正确。还有最重要的一点,每次对lua文件或者其他资源更改后,都要点击菜单栏LuaFramework/Build xxx Resource来重新打包!
在StreamingAssets下查看是否打包成功
运行出现
1.打包运行后可能会提示FileNotFoundException: Could not find file “c:\luaframework\shared.unity3d”.这个错误,追踪错误到ResourceManager.cs中的initialize方法,如果AppConst.ExampleMode为true,则需要shared.unity3d这个AB包。因此,打包的时候需要把shared文件夹也选上哦。。
2.生成的面板会在GUI这个物体下,那么如何修改这个物体呢?找到GameManager.cs中的InitGui方法,修改一下即可。GUI这个预制体,可以在Project视图搜索即可。 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|