当前位置: 首页 > news >正文

手机网站制作公司选哪家/最新实时新闻

手机网站制作公司选哪家,最新实时新闻,免费用的云服务器,素材天下免费素材网1.资源的创建 注意一下命名规则,一个面板及其相关的东西都放在同一个文件夹中,如果文件夹命名为xxx,则面板预制要命名为xxxPanel 2.打包 以文件夹为单位进行打包,打包类为Packager.cs。这里要打包的东西分两种,一种为…

1.资源的创建

注意一下命名规则,一个面板及其相关的东西都放在同一个文件夹中,如果文件夹命名为xxx,则面板预制要命名为xxxPanel


2.打包

以文件夹为单位进行打包,打包类为Packager.cs。这里要打包的东西分两种,一种为图片等资源,另一种为代码资源(即lua脚本)。对lua脚本的打包已经被框架搞好了,不需要我们考虑,我们要考虑的是对前者的打包,详细的见Packager.cs的HandleExampleBundle方法,这里我做了个小工具:

using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
using System.IO;
using System.Text;public enum SuffixEnum
{Prefab,Png,Csv,Txt,
}public class AddBuildMapUtility : EditorWindow {int count = 0;List<string> bundleNameList = new List<string>();List<SuffixEnum> suffixList = new List<SuffixEnum>();List<string> pathList = new List<string>();Vector2 scrollValue = Vector2.zero;[MenuItem("LuaFramework/AddBuildMapUtility")]static void SetAssetBundleNameExtension(){EditorWindow.GetWindow<AddBuildMapUtility>();}void OnGUI(){EditorGUILayout.BeginHorizontal();if (GUILayout.Button("添加一项")){AddItem();}if (GUILayout.Button("清除所有项")){Clear();}if (GUILayout.Button("读取文件(.csv)")){Clear();string path = EditorUtility.OpenFilePanel("", Application.dataPath, "csv");string content = File.ReadAllText(path);string[] contents = content.Split(new string[] { "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries);for (int i = 0; i < contents.Length; i++){string[] a = contents[i].Split(',');AddItem(a[0], StringToEnum(a[1]), a[2]);}}if (GUILayout.Button("保存")){string path = EditorUtility.SaveFilePanel("", Application.dataPath, "AssetBundleInfo", "csv");StringBuilder sb = new StringBuilder();for (int i = 0; i < count; i++){if (string.IsNullOrEmpty(bundleNameList[i])) break;sb.Append(bundleNameList[i] + ",");sb.Append(EnumToString(suffixList[i]) + ",");sb.Append(pathList[i] + "\r\n");}File.WriteAllText(path, sb.ToString());AssetDatabase.Refresh();}if (GUILayout.Button("自动填写(所有选中的)")){int startIndex = count;for (int i = 0; i < Selection.objects.Length; i++){AddItem();AutoFill(startIndex, Selection.objects[i]);startIndex++;}}EditorGUILayout.EndHorizontal();EditorGUILayout.LabelField("注意:请以文件夹为单位进行选择!!!文件夹名即为包名!!!");scrollValue = EditorGUILayout.BeginScrollView(scrollValue);for (int i = 0; i < count; i++){EditorGUILayout.BeginVertical();EditorGUILayout.BeginHorizontal();EditorGUILayout.LabelField(i.ToString() + "AB包名");bundleNameList[i] = EditorGUILayout.TextField("", bundleNameList[i]);suffixList[i] = (SuffixEnum)EditorGUILayout.EnumPopup("类型", suffixList[i]);pathList[i] = EditorGUILayout.TextField("路径", pathList[i]);if (GUILayout.Button("自动填写(单个)")){AutoFill(i, Selection.objects[0]);}if (GUILayout.Button("输出路径")){Debug.Log(pathList[i]);}if (GUILayout.Button("删除该项")){RemoveItem(i);}EditorGUILayout.EndHorizontal();EditorGUILayout.EndVertical();}EditorGUILayout.EndScrollView();}void Clear(){count = 0;bundleNameList = new List<string>();suffixList = new List<SuffixEnum>();pathList = new List<string>();}void AddItem(string bundleName = "", SuffixEnum suffix = SuffixEnum.Prefab, string path = ""){count++;bundleNameList.Add(bundleName);suffixList.Add(suffix);pathList.Add(path);}void RemoveItem(int index){count--;bundleNameList.Remove(bundleNameList[index]);suffixList.Remove(suffixList[index]);pathList.Remove(pathList[index]);}void AutoFill(int index, Object selectedObject){string path = AssetDatabase.GetAssetPath(selectedObject);bundleNameList[index] = path.Remove(0, path.LastIndexOf("/") + 1).ToLower() + LuaFramework.AppConst.ExtName;string[] files = Directory.GetFiles(path);string[] temp = files[0].Split('.');suffixList[index] = StringToEnum("*." + temp[1]);pathList[index] = path;}public static string EnumToString(SuffixEnum se){switch (se){case SuffixEnum.Prefab:return "*.prefab";case SuffixEnum.Png:return "*.png";case SuffixEnum.Csv:return "*.csv";case SuffixEnum.Txt:return "*.txt";default:return "null";}}public static SuffixEnum StringToEnum(string s){switch (s){case "*.prefab":return SuffixEnum.Prefab;case "*.png":return SuffixEnum.Png;case "*.csv":return SuffixEnum.Csv;case "*.txt":return SuffixEnum.Txt;default:return SuffixEnum.Prefab;}}} 





然后对HandleExampleBundle这个方法进行修改:

UGUI版本:

    static void HandleExampleBundle(){string resPath = AppDataPath + "/" + AppConst.AssetDir + "/";if (!Directory.Exists(resPath)) Directory.CreateDirectory(resPath);//AddBuildMap("prompt" + AppConst.ExtName, "*.prefab", "Assets/LuaFramework/Examples/Builds/Prompt");//AddBuildMap("message" + AppConst.ExtName, "*.prefab", "Assets/LuaFramework/Examples/Builds/Message");//AddBuildMap("prompt_asset" + AppConst.ExtName, "*.png", "Assets/LuaFramework/Examples/Textures/Prompt");//AddBuildMap("shared_asset" + AppConst.ExtName, "*.png", "Assets/LuaFramework/Examples/Textures/Shared");string content = File.ReadAllText(Application.dataPath + "/AssetBundleInfo.csv");string[] contents = content.Split(new string[] { "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries);for (int i = 0; i < contents.Length; i++){string[] a = contents[i].Split(',');//UnityEngine.Debug.Log(a[0]); UnityEngine.Debug.Log(a[1]); UnityEngine.Debug.Log(a[2]);AddBuildMap(a[0], a[1], a[2]);}}

NGUI版本:

NGUI版本有些不同,它使用的是4.x的打包方式,为了配合5.x的打包,需要修改一下:


    static void 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(new string[] { "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries);for (int i = 0; i < contents.Length; i++){string[] a = contents[i].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>();static void 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[i] = files[i].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来重新打包!



3.编写
a.在Assets\LuaFramework\Lua下的Controller和View下,模仿编写lua
b.在CtrlManager、Game、define这三个lua文件中模仿添加修改东西


4.运行

建立一个空物体,挂上Main脚本,在Canvas(UGUI版本的框架)下建一个空物体,赋予GuiCamera这个tag,将位置和宽高置0,然后拉伸宽高,然后运行,这样就可以了!



Ps:

NGUI版本注意点:

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视图搜索即可。

http://www.jmfq.cn/news/5296861.html

相关文章:

  • 重庆承越网站制作公司/优化大师网页版
  • 做网站什么语言好/安顺seo
  • 做网站如何可以实现窗口切换功能/最经典最常用的网站推广方式
  • 做图片推广的网站/产品推广策划
  • 京东做代码的网站吗/网站搜索引擎拓客
  • 愿景 做中国最受欢迎的互联网网站/国内重大新闻10条
  • 如何增加网站权重/十大免费cms建站系统介绍
  • 单位的网站的建设/seo职位要求
  • 电子商务网站建设哪本教材比较适合中等专业学校用/免费发布外链
  • 香港特别行政区的区花是什么花/天津seo代理商
  • dedecms做电商网站/全国疫情高峰感染高峰进度
  • 团队如何分工做网站/全国免费发布广告信息平台
  • 黑客软件/开封网站优化公司
  • 小公司企业简介怎么写/黑帽seo优化软件
  • 软件公司网站素材/优化设计七年级下册语文答案
  • diango是做网站的后端吗/如何制作百度网页
  • 国外做电商平台的网站还有什么/优化大师的作用
  • 做网站要固定电话/软文街
  • 哪些网站做科技专题/百度seo优化招聘
  • 用PS怎么做网站图片/站长工具网站排名
  • 做网站赚钱多吗/口碑营销的定义
  • 可以做宣传的网站有哪些/营销案例最新
  • wordpress文章网格/seo链接优化
  • 房门户网站如何做优化/厦门关键词优化报价
  • 现在有男的做外围女网站客服吗/福州百度网站排名优化
  • 网站建设交易平台/灰色词首页排名接单
  • 为什么要做一个营销型网站/百度竞价推广是什么工作
  • 建设一个网站可以做什么/线上营销平台有哪些
  • 商洛市住户和城乡建设局网站信息价/世界球队最新排名
  • 可以做用户旅程图的网站/站长网站