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

外贸网站建设 福田b2b电子商务网站都有哪些

外贸网站建设 福田,b2b电子商务网站都有哪些,临沂市建设局网站公示,互联网广告营销公司以下内容是根据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.tj-hxxt.cn/news/83082.html

相关文章:

  • 用个人的信息备案网站如何建网站不花钱
  • 南京网站建设优化线下宣传渠道和宣传方式
  • 免费做网站有哪些家今天全国疫情最新消息
  • 网站英文怎么写网站怎么做
  • 九江有没有做网站的公司邹平县seo网页优化外包
  • 赌博网站游戏怎么做广州全网推广
  • 信阳市住房和城乡建设局网站全网营销推广软件
  • 广告设计素材免费的网站seo排名资源
  • 可以做免费广告的网站电脑办公软件培训班
  • 深圳网页设计制作网站计算机培训机构
  • 济南微信网站百度的代理商有哪些
  • 南通网站制作专家windows优化大师免费
  • 重庆时时彩在线网站制作推广app下载
  • 深圳市手机网站建设报价百度网站大全首页
  • 那个网站做苗木网站的优化从哪里进行
  • 有用建站宝盒做网站的吗推广普通话宣传语100字
  • 如何提高网站用户体验北京百度竞价托管
  • 移动web网站开发我想做app推广怎么做
  • 高密哪里做网站百度推广最近怎么了
  • 汕头网站建设公司有哪些网络销售是什么
  • 盐城网站建设渠道合作博客程序seo
  • 关于行业网站建设意见推广员网站
  • 乐清做网站建设公司哪家好pageadmin建站系统
  • 四川建设网官网地址天津seo实战培训
  • 网页建设与网站设计广东网络推广运营
  • 网站建设联系方式友情链接检测结果
  • nofollow标签对网站收录的影响网络营销怎么推广
  • 湖南佳程建设有限公司网站seo的主要内容
  • 一般公司网站是什么设计师做如何建立独立网站
  • 手机网站建设价格低网络策划是做什么的