- 博客(15)
- 收藏
- 关注
原创 unity 关于BoxCollider2D的部分小结
unity版本: 2019.3.10f1两个相互碰撞的物体,其中一个SetActive为false,或者被Destroy()时,两方都会触发一次OnCollisionEnter2D()函数,包括在其中一方的OnCollisionStay2D()中销毁传入的collision时也一样,都会正常触发...
2020-05-18 14:46:13
1984
原创 Unity UGUI场景坐标转换成UI坐标
所用到的API: CameraHelper.MainCamera.WorldToScreenPoint(Vector3 position) RectTransformUtility.ScreenPointToLocalPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera cam, out Vector2 localPo...
2020-05-18 14:34:00
1115
原创 c#的问号(?)和双问号语法糖(??)的用法和在unity中使用需要注意的事项
public class CustomObject { public string CodeName;}CustomObject obj1;if(obj1!=null){ obj1.CodeName="12345";}//等价于obj1?.CodeName="12345";//==========================================...
2020-04-21 17:17:15
1747
原创 c# Mathf.PingPong函数用法
public static float PingPong(float t, float length);//参数t:一个逐渐增长的值,一般用Time.time,也可使用其他一直增长的值,例如循环//参数length :传入设定的上限该函数返回一个0~length之间的数字,不会大于length 不会小于0,该函数的返回值总是0~length,再从length~0,可以用来制作渐隐或者循环动...
2020-03-24 18:39:10
1509
原创 Unity使用二进制运算物体的layer
unity中 一共有32个layer位置 用一个int表示,int占32个字节,每层layer占int的一个字节,一个初始的int在二进制中是:00000000000000000000000000000000如果打开第一层layer :00000000000000000000000000000010打开第零层和第十层layer:00000000000000000000100000000...
2020-01-11 17:10:12
408
原创 TextMeshPro 制作图文混编时,图片的输入方式
需要软件:TexturePacker导出设置:导出格式:JSON(Array)保持JSON Array大小限制:POT(2的幂)取消允许旋转拉伸,边框填充,形状填充都为0把导入出的json文件和图片导入项目目录\Assets\Plugins\TextMesh Pro\Examples & Extras\Sprites文件夹中(这点不确定)打开在编辑器中Window-T...
2020-01-10 20:44:17
1289
原创 c#7.0新特性ref局部变量和返回ref变量
public static ref int GetLast(int[] a) { if (a == null || a.Length < 1) { throw new Exception("数组为空"); } int number = 18;...
2019-12-27 18:12:47
1145
原创 Unity 自定义UI时应使用UI事件接口实现不是EventTrigger
EventTrigger很方便,但是如果我们在scroll view下的滚动栏里添加子物体的时候,使用了EventTrigger,会导致scroll view的滚动和拖拽在鼠标移入按钮内时被屏蔽,如果使用接口则一切正常上代码: public EventTrigger Trigger; private void Start() { AddTriggersL...
2019-12-24 11:38:41
286
原创 Unity Rewired高级输入插件学习日记
//根据索引返回指定玩家控制器Player playerController;playerController=ReInput.players.GetPlayer(0);//根据控制器类型和Category(类别)返回符合条件的所有控制器mapplayerController.controllers.maps.GetMapsInCategory(ControllerType.Keybo...
2019-12-19 21:29:19
1810
原创 Unity EventSystem鼠标点击UI空白部分会导致currentSelectedGameObject置空的问题
需要更改UnityEventsySysem上的Standalone Input Module脚本的源码.搜索并注释以下代码,可以解决DeselectIfSelectionChanged(currentOverGo, pointerEvent);
2019-12-18 11:48:08
2880
1
原创 Unity 使用键盘实现键盘操纵UI按钮和ScrollView的滚动
unity版本2018.4unity自带的EventSyetem物体上的InputModule脚本会导致使用鼠标点击空白区域时,当前选择的物体会丢失,需要修改源码来解决主要的滚动区域由ScrollView制作public class BlogScript : MonoBehaviour{ /// <summary> /// 设计时在当前屏幕下显示的物体的行数 ...
2019-12-12 20:22:31
3612
原创 读取xlsx表格数据转换为json/字典
读取表格数据转换为json/字典需要的插件:Excel.dll,ICSharpCode.SharpZipLib.dll,Newtonsoft.json.dll读取出的数据类public class ExcelUtility{ /// <summary> /// 表格数据集合 /// </summary> private Data...
2019-12-09 17:38:47
641
原创 unity使用脚本动态替换动画 并添加帧事件
unity使用脚本动态替换动画 并添加帧事件using System.Collections;using System.Collections.Generic;using UnityEngine;[RequireComponent(typeof(Animator))][RequireComponent(typeof(SpriteRenderer))]public class Repl...
2019-11-18 17:29:16
2008
原创 Unity 读取excel表格数据转换为json文件
Unity 读取excel表格数据转换为json文件 使用插件:代码示例表格:使用插件:Litjson:用于json的解析Epplus:用于读取xlsx格式的表格代码using LitJson;using OfficeOpenXml;using System;using System.Collections;using System.Collections.Generic;us...
2019-11-04 13:56:34
1183
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人