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

微信页面设计网站兰州网络推广技术

微信页面设计网站,兰州网络推广技术,免费企业静态网站模板,网站的尾页要怎么做以下内容是根据Unity 2020.1.0f1版本进行编写的   实现一个自定义图集,该怎么入手呢。首先简单思考一下unity是怎么实现图集的。 因为unity的ui部分是开源的,所以我们可以看到UGUI的源代码,另外,Unity的内置Shader也是开源的,可以直接在官网下载(在下载的网页选择Built…

以下内容是根据Unity 2020.1.0f1版本进行编写的

实现一个自定义图集,该怎么入手呢。首先简单思考一下unity是怎么实现图集的。
因为unity的ui部分是开源的,所以我们可以看到UGUI的源代码,另外,Unity的内置Shader也是开源的,可以直接在官网下载(在下载的网页选择Built in shaders下载即可):https://unity.com/releases/editor/archive

首先,图集在Unity编辑器中是可编辑的,因此,需要实现一个自定义图集的Inspector面板,并定义好图集的基础属性,方便使用。

1、实现自定义图集类MyAtlas

using System.Collections.Generic;
using UnityEngine;[CreateAssetMenu(fileName = "MyAtlas", menuName = "My Atlas")]
public class MyAtlas : ScriptableObject
{public string atlasName = "";public List<string> guids = new List<string>();public List<string> packableObjects = new List<string>();public List<string> realPackObjs = new List<string>();public List<UnityEngine.Object> objs = new List<Object>();
}

首先,定义自定义的图集类MyAtlas,这里只定义Inspector面板需要用到的变量。需要继承ScriptableObject类,否则无法实现自定义类型的后处理导入
其中,atlasName是图集名字,guids是图集包含全部图片的guid,realPackObjs是图集包含全部图片的路径,Objs是显示在Inspector面板的Object,packableObjects是Objs对应的路径,因为有可能是文件夹,所以需要和realPackObjs区分开来。
在这里插入图片描述
在这里插入图片描述
右键新建一个MyAtlas文件,如上图,这样可以了

2、实现自定义图集类的Inspector面板

using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using UnityEngine;public class CommonFunc : MonoBehaviour
{public static void SeachFile(string path, List<string> files, string[] extensions){if (Directory.Exists(path)){DirectoryInfo di = new DirectoryInfo(path);FileSystemInfo[] fsInfos = di.GetFileSystemInfos();bool isSkip;foreach (FileSystemInfo fsInfo in fsInfos){isSkip = true;if (fsInfo is DirectoryInfo){SeachFile(fsInfo.FullName, files, extensions);}if (fsInfo.Name.Contains(".meta")){continue;}foreach (string extension in extensions){if (fsInfo.Name.Contains(extension)){isSkip = false;break;}}if (!isSkip){string fileN = fsInfo.FullName;string ss = "Assets" + fileN.Replace("\\", "/").Replace(Application.dataPath, "");if (!files.Contains(ss)){files.Add(ss);}}}}}public static List<string> GetAllFilesInDirectory(string path, string searchParttern, List<string> list = null, bool isUnityPath = false){if (list == null){list = new List<string>();}var files = Directory.GetFiles(path, searchParttern, SearchOption.AllDirectories);foreach (var file in files){string filePath = file.Replace("\\", "/");if (isUnityPath){filePath = GetUnityPath(filePath);}list.Add(filePath);}return list;}public static string GetMD5Hash(string filePath){MD5 md5 = new MD5CryptoServiceProvider();return BitConverter.ToString(md5.ComputeHash(File.ReadAllBytes(filePath))).Replace("-", "").ToLower();}public static string GetUnityPath(string path){string newPath = path;if (newPath.Contains(Application.dataPath)){newPath = newPath.Replace(Application.dataPath, "Assets");}if (newPath.Contains(Application.dataPath.Replace("/", "\\"))){newPath = newPath.Replace(Application.dataPath.Replace("/", "\\"), "Assets");}if (newPath.Contains(Application.dataPath.Replace("\\", "/"))){newPath = newPath.Replace(Application.dataPath.Replace("\\", "/"), "Assets");}newPath = newPath.Replace("\\", "/");return newPath;}public static string GetSystemPath(string path){string newPath = path;if (newPath.StartsWith("Assets")){newPath = Application.dataPath.Replace("Assets", "") + newPath;}newPath = newPath.Replace("/", "\\");return newPath;}public class Messagebox{[DllImport("User32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)]public static extern int MessageBox(IntPtr handle, String message, String title, int type);}
}

首先实现一个通用的类CommonFunc,包含一些通用方法,如文件路径转换UnityPath,或者转换为系统路径,等等。

using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.UI;
using UnityEditorInternal;
using UnityEngine;[
http://www.hkea.cn/news/523412/

相关文章:

  • 上门做网站搜狗站长工具
  • wordpress用户邮箱验证码百度seo搜索引擎优化培训
  • 360极速怎么屏蔽网站新闻热点大事件
  • 购物app开发价格表站长工具seo排名
  • 微餐饮网站建设营销型网站建设方案
  • 高端网站建设公司好不好2020国内搜索引擎排行榜
  • 网站建设服务公司选哪家比较好?苏州优化收费
  • 中国建设银行河南省分行网站推广信息哪个平台好
  • 网站建设官网免费模板杭州seo优化
  • 绍兴网站建设谷歌搜索引擎在线
  • 网站的会员认证怎么做黑龙江新闻头条最新消息
  • 做网站如何分工百度推广登录平台客服
  • 网站建设如何提案万网域名注册信息查询
  • 创意二维码制作网站企业网络营销推广案例
  • 论坛型网站怎么做百度高级检索入口
  • 做百度移动网站排搜素引擎优化
  • 公司创建一个网站需要多少钱想做百度推广找谁
  • 做文献ppt模板下载网站有哪些常德政府网站
  • 青岛网站建设公司排行外链工具在线
  • 网站怎么做显得简洁美观seo数据是什么意思
  • 阿里巴巴开通诚信通后网站怎么做网络优化网站
  • 东莞手机网站价格便宜个人免费建站软件
  • 电子商务网站建设的步骤一般为百度100%秒收录
  • 做企业网站怎么样免费的推广软件下载
  • 拓普网站建设美国搜索引擎
  • 网站开发者工资冯耀宗seo视频教程
  • 软件开发各阶段工作量比例搜索引擎优化的基础是什么
  • 网站怎么做才能将名声打响云搜索app
  • 南阳做网站优化哪家好一级域名生成二级域名
  • 3322动态域名官网郑州seo联系搜点网络效果好