11 2022 档案
摘要:示意图 1) anchor区域 Vector2 anchorMin; anchor区域左下角与parent左下角的距离(用parent大小的百分比表示) Vector2 anchorMax; anchor区域的右上角与parent右上角的距离(用parent大小的百分比表示) 2) 节点坐标: 是相
阅读全文
摘要:1) Rect rect; a) Sprite Mode为Single时: x, y总是为0; width, height为裁掉空白像素前的大小 b) Sprite Mode为Multiple时: 则x, y为slice区域在Sprite上的位置, 大小为slice区域的大小 2) Vector2
阅读全文
摘要:开启Sprite Pack 图集打包 Packing Tag设置成相同名字的图片就会被打包进同一个图集a) 图集common_ui b) 图集icon 查看图集 菜单 -> Window -> 2D -> Sprite Packer 获取图集中的Sprite Sprite Pack打包的图集,Uni
阅读全文
摘要:代码 #if UNITY_EDITOR using System.Collections.Generic; using System.IO; using System.Text; using UnityEditor; using UnityEngine; public class CmdTool {
阅读全文
摘要:1) 获取AnimationClip public static bool TryGetAnimatorClip(Animator animator, string clipName, out AnimationClip outClip) { var clips = animator.runtime
阅读全文
摘要:原理 1) 异或运算法则:异或的两个bit相同结果为1,不同结果为02) 一个数^0还是自身, 没有任何效果,因为0^0=0, 1^0=1。例子:0b0101,1010 ^ 0b0000,0000=0b0101,10103) 单个bit^1是取反的效果,0^1=1, 1^1=0,所以一个int变量^
阅读全文
摘要:先上结论 1) 右移:左侧会使用符号位补齐,比如:对于负数,右移时左侧补1;对于正数,右移时左侧补0;2) 左移:符号位也会被左移,右侧补03) 取反:符号位也会被取反 测试代码 //有符号数 static void Print(int a) { Console.WriteLine($"{Conve
阅读全文
摘要:正数和负数的补码区别 1) 对于正数,原码和补码相同 2) 对于负数,先得到反码,再计算补码反码:除符号位外取反补码:反码+1 补码示例 1) 35原码:0010,0011补码:0010,0011 2) 18原码:0001,0010补码:0001,0010 3) -18原码:1001,0010反码:
阅读全文
摘要:方式1:使用多个overrideController文件的方式 1) 创建一个通用的状态机,以及状态动画占位文件 2) 分别为不同的角色创建状态动画文件,并用overrideController进行绑定 a) Role1Override.overrideController,这边用正方形表示Role
阅读全文
摘要:界面需要做国际化的时候,一般不会在Text组件上使用中文,而是使用id或者key来代替,这个代码用于检测直接写了中文的Text #if UNITY_EDITOR using System.Text; using System.Text.RegularExpressions; using UnityE
阅读全文
摘要:RenderTexture或Texture2D -> RenderTexture public static RenderTexture TextureRenderToRT(Texture srcTex) { var srcTempRT = RenderTexture.GetTemporary(sr
阅读全文
摘要:# 这个图框了3张小图,淡蓝色进度条,钻石图标,道具背景框,其中道具背景框还设置了border。 提取出的图片 #if UNITY_EDITOR using UnityEngine; using UnityEditor; using System.IO; public static class Sp
阅读全文
摘要:# 下载visual studio的在线安装包 下载 Visual Studio Tools - 免费安装 Windows、Mac、Linux (microsoft.com) # 在适当的位置新建一个文件夹,我是放在桌面了 C:\Users\win\Desktop\vs2022_offline #
阅读全文