07 2023 档案

摘要:效果 代码 using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class MyInputField_CaretDragOp : MyInputField_TextSelect, IDragH 阅读全文
posted @ 2023-07-31 23:28 yanghui01 阅读(226) 评论(0) 推荐(0)
摘要:效果 代码把光标闪烁拿掉了 using UnityEngine; using UnityEngine.UI; [DisallowMultipleComponent] [RequireComponent(typeof(CanvasRenderer))] [RequireComponent(typeof 阅读全文
posted @ 2023-07-31 23:11 yanghui01 阅读(137) 评论(0) 推荐(0)
摘要:ContextMenuItem 用于给成员变量增加右键菜单 加在成员变量上,在成员变量上右键弹出右键菜单,对应的菜单函数只能是成员函数,不能是static函数 public class TestContextMenu : MonoBehaviour { [ContextMenuItem("Reset 阅读全文
posted @ 2023-07-30 23:13 yanghui01 阅读(349) 评论(0) 推荐(0)
摘要:var rtf = GetComponent<RectTransform>(); rtf.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 200); SetSizeWithCurrentAnchors不会改变anchorMin和anc 阅读全文
posted @ 2023-07-30 14:31 yanghui01 阅读(70) 评论(0) 推荐(0)
摘要:效果 using System.IO; using UnityEditor; using UnityEngine; public static class AssetDepsTool { private const string Default_Copy_Folder = "D:/UnityAsse 阅读全文
posted @ 2023-07-30 00:02 yanghui01 阅读(34) 评论(0) 推荐(0)
摘要:最终效果 代码 using System.Collections; using UnityEngine; using UnityEngine.UI; [DisallowMultipleComponent] [RequireComponent(typeof(CanvasRenderer))] [Req 阅读全文
posted @ 2023-07-28 23:47 yanghui01 阅读(280) 评论(0) 推荐(0)
摘要:1) ReferenceEquals: 仅会比较两者的引用 2) ==: 没有重载操作符就是比较引用,否则就是重载后的行为,比如System.String是先比较引用,再比较内容。 那是不是和null比较,Object.ReferenceEquals(inst, null)更好一点?因为他不会触发额 阅读全文
posted @ 2023-07-28 23:30 yanghui01 阅读(47) 评论(0) 推荐(0)
摘要:3d部分使用MeshRenderer来渲染,ugui的渲染均使用CanvasRenderer。 如何渲染出来呢?只需要把顶点,材质,贴图设置给CanvasRenderer,就能渲染出来了。 下面的代码,我们直接使用CanvasRenderer来进行渲染,等同于Graphic渲染部分的核心代码。 us 阅读全文
posted @ 2023-07-26 23:42 yanghui01 阅读(85) 评论(0) 推荐(0)
摘要:转换为二进制 a = struct.pack('cc', b"1", b"2") print(type(a)) print(a) print(type(b"1")) a = struct.pack('bb', 1, 127) # signed char, 范围[-128, 127], 用128会抛异 阅读全文
posted @ 2023-07-26 23:00 yanghui01 阅读(37) 评论(0) 推荐(0)
摘要:字符串和二进制的转换,需要用到编码(比如:utf-8, gbk),它起到的主要作用: 1) 字符转二进制时:根据字符,去编码表查询该字符的二进制值 2) 二进制转字符时:根据二进制值,去编码表查询该二进制对应的字符 # 字符转二进制,也叫编码 str_bytes = "123abc中文".encod 阅读全文
posted @ 2023-07-26 22:56 yanghui01 阅读(1175) 评论(0) 推荐(0)
摘要:常用操作 常见用法 arr1 = array.array("i", [1, 2]) # 元素的字节数 print(arr1.itemsize) # 4 print(len(arr1)) # 2 # 添加元素 arr1.append(3) arr1.append(4) print(len(arr1)) 阅读全文
posted @ 2023-07-26 22:51 yanghui01 阅读(101) 评论(0) 推荐(0)
摘要:效果 原理:就是将原有区域分割成围绕中心0的多个三角形 using UnityEngine; using UnityEngine.Sprites; using UnityEngine.UI; [RequireComponent(typeof(Image))] public class Polygon 阅读全文
posted @ 2023-07-25 23:16 yanghui01 阅读(84) 评论(0) 推荐(0)
摘要:常见用法 # 时区 print(time.timezone) # -28800 print(time.tzname) # ('中国标准时间', '中国夏令时') # 当前时间 utcSec = time.time() # 时间戳, 距离1970-01-01 00:00:00的秒数 print(typ 阅读全文
posted @ 2023-07-24 23:09 yanghui01 阅读(43) 评论(0) 推荐(0)
摘要:常用操作 字符文件本质上还是用二进制方式写出,只是他多了一步查找字符的二进制值的过程。比如:9用二进制写出就是0b1001,utf-8的'9‘写出就是要先在utf-8码表中找'9'对应的二进制0b111001,然后再写出。 写 if not os.path.exists("New Folder"): 阅读全文
posted @ 2023-07-24 22:25 yanghui01 阅读(42) 评论(0) 推荐(0)
摘要:常用操作 哪些是二进制文件? 图片,音频,视频等,这些都是二进制文件 写 f1 = open("test.bin", "wb") print(f1.name) # test.bin print(f1.closed) # False print(f1.mode) # wb print(f1.reada 阅读全文
posted @ 2023-07-24 22:24 yanghui01 阅读(164) 评论(0) 推荐(0)
摘要:常见术语及用法 路径 # 分隔符 print(os.pathsep) # ; print(os.altsep) # / print(os.extsep) # . # 拼接 print(os.path.join("a", "b", "c")) # a\b\c # 绝对路径 print(os.path. 阅读全文
posted @ 2023-07-23 21:23 yanghui01 阅读(52) 评论(0) 推荐(0)
摘要:a = 0b1101 b = 0b1010 print(a, b) # 13 10 # 与 print(bin(a & b)) # 0b1000 # 或 print(bin(a | b)) # 0b1111 # 异或 print(bin(a ^ b)) # 0b0111, 位不同的为1, 相同的为0 阅读全文
posted @ 2023-07-23 21:15 yanghui01 阅读(19) 评论(0) 推荐(0)
摘要:常见概念 类和对象 class MyClass: num = 0 s = "" def __init__(self): # 构造函数 pass def print_info(self): print("num is: %s, str is: %s" %(self.num, self.s)) pass 阅读全文
posted @ 2023-07-21 01:15 yanghui01 阅读(23) 评论(0) 推荐(0)
摘要:Python中没有专门的queue类,而是把list当作队列来使用。 队列是一种先进先出的数据结构,主要的操作:入队,出队 queue1 = [] queue1.append(1) queue1.append(2) queue1.append(3) print(type(queue1)) # <cl 阅读全文
posted @ 2023-07-21 00:34 yanghui01 阅读(26) 评论(0) 推荐(0)
摘要:Python中没有没专门的stack类,而是可以把list当作栈来用 栈是一种先进后出的数据结构,主要的操作只有:入栈,出栈 stack1 = [] # 入栈 stack1.append(1) stack1.append(2) stack1.append(3) print(type(stack1)) 阅读全文
posted @ 2023-07-21 00:34 yanghui01 阅读(21) 评论(0) 推荐(0)
摘要:常用操作 dict的key不能重复,不能为可变值;value可以重复 基本使用 dict1 = { "key1": 1, "key2": 2, "key3": 3, } print(type(dict1)) # <class 'dict'> print(type(dict1) == dict) # 阅读全文
posted @ 2023-07-21 00:33 yanghui01 阅读(17) 评论(0) 推荐(0)
摘要:常用操作 set的元素不能重复 set1 = {1, 2, 3} print(type(set1)) # <class 'set'> print(len(set1)) # 3 # 添加 set1.add(4) print(len(set1)) # 4 # 判断是否在集合中 print(1 in se 阅读全文
posted @ 2023-07-21 00:33 yanghui01 阅读(24) 评论(0) 推荐(0)
摘要:常用操作 列表的元素可以为空,也可以重复 基本使用 list1 = [1, 2, 3] print(type(list1)) # <class 'list'> print(type(list1) == list) # True print(isinstance(list1, list)) # Tru 阅读全文
posted @ 2023-07-21 00:22 yanghui01 阅读(21) 评论(0) 推荐(0)
摘要:常用操作 判断类型 print(type("abc")) # <class 'str'> print(type("abc") == str) # True print(isinstance("abc", str)) # True 遍历和长度 print(len("abc")) # 3 for c i 阅读全文
posted @ 2023-07-21 00:09 yanghui01 阅读(40) 评论(0) 推荐(0)
摘要:基础数据类型 a = 1 print(type(a)) b = 1.2 print(type(b)) c = True print(type(c)) a = c print(type(a)) e = "hello" print(type(e), id(e)) 2进制,8进制,16进制 a=0b101 阅读全文
posted @ 2023-07-20 00:45 yanghui01 阅读(31) 评论(0) 推荐(0)
摘要:Rect内部使用m_XMin, m_YMin, m_Width, m_Height存放数据,即:左下角+宽高 1) 设置xMin, xMax时,宽度m_Width会被修改 设置xMin时,认为是只有左侧在动, 右侧是不动的; 左侧往左则m_Width变大, 左侧往右则m_Width变小 设置xMax 阅读全文
posted @ 2023-07-19 00:46 yanghui01 阅读(49) 评论(0) 推荐(0)
摘要:主要涉及到的类 看到最多的就是EventSystem这个自动添加的GameObject 代码阅读要点 1) 事件系统做了什么? 在Update中不断的检测这一帧发生的输入事件,并根据输入事件解析出当前在进行的操作。 所以,所有的逻辑都是在EventSystem.Update中发生的。Standalo 阅读全文
posted @ 2023-07-13 00:27 yanghui01 阅读(302) 评论(0) 推荐(1)
摘要:主要的代码: public static readonly Vector2[] s_VertScratch = new Vector2[4]; public static readonly Vector2[] s_UVScratch = new Vector2[4]; private void Ge 阅读全文
posted @ 2023-07-05 01:40 yanghui01 阅读(282) 评论(0) 推荐(0)
摘要:function Test(num, nDigits) local multi = 10 ^ nDigits --10的n次方 local num1 = math.floor(num * multi) local ret = num1 / multi return ret end 百分比保留1位小数 阅读全文
posted @ 2023-07-02 23:21 yanghui01 阅读(24) 评论(0) 推荐(0)
摘要:#if UNITY_EDITOR using System; using System.IO; using UnityEditor; using UnityEngine; public static class SpriteTool { // OpenDirAfterExport const str 阅读全文
posted @ 2023-07-01 01:26 yanghui01 阅读(98) 评论(0) 推荐(0)