随笔分类 - C#
C#
摘要:很简单,使用 Guid 即可 private void CreateActivationKey() { var activationKey = Guid.NewGuid().ToString(); Debug.Log(activationKey); } 可以生成这种数据,可以截取一部分使用,重复的激
阅读全文
摘要:https://travis.media/how-to-run-csharp-in-vscode/ 如何在 VSCode 中运行 C# 1.安装.NET 首先,安装 .NET 。你可以在这里做到这一点: https://dotnet.microsoft.com/download 然后通过在终端窗口中
阅读全文
摘要:1.第一步安装MongoDB https://blog.csdn.net/weixin_45404208/article/details/114437260 2.安装可视化数据库软件 Robo 3T (免费但是不再更新) Studio3t (功能完善,但是收费,建议学习版) 3.操作数据库 http
阅读全文
摘要:非设置父节点,核心代码只需要3行 using System.Collections.Generic; using UnityEngine; public class Platform : MonoBehaviour { List<Player> players = new List<Player>(
阅读全文
摘要:using System.Collections; using System.Collections.Generic; using UnityEngine; public class LineCircleIntersect : MonoBehaviour { public Transform a;
阅读全文
摘要:using System;using System.Collections;public class EventSystem { public delegate void ListenerDelegate(); public delegate void ListenerDelegate<T>(T t
阅读全文
摘要:Unity Text 里面有个 Best Fit选项,这个当超过一行文字后就会自动缩小,不是超过整个文本框才自动缩小 使用以下组件可取代Text using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; //
阅读全文
摘要:1.if else 不要超过3个分支 2.switch case 禁用 3.枚举,慎用,如果增加枚举其他地方不修改可使用,否则不能使用 4.if括号内的条件判断,不要超过2个 为什么不要超过2个,超过2个就是3个,5个,10个,上次还见到过一个20个的 这种优化,使用委托即可完成优化,类该拆分的拆分
阅读全文
摘要:抄的Unity的源码 HandleUtility.DistancePointLine 是UnityEditor代码,源码如下,这样就可以在Runtime中运行 注意性能开销! /// <summary> /// 计算点到线段的最短距离 /// </summary> /// <param name="
阅读全文
摘要:bool ContainsPoint(List<Vector2> polyPoints, Vector2 p) { var j = polyPoints.Count - 1; var inside = false; for (int i = 0; i < polyPoints.Count; j =
阅读全文
摘要:客户端 using System; using System.Collections; using System.Collections.Generic; using System.Net; using System.Text; using System.Threading; using Newto
阅读全文
摘要:github链接 https://github.com/XINCGer/UnityToolchainsTrick UnityToolchainsTrick 提供一些UnityEditor工具链开发的常用小技巧与示例(Provides some common tips and examples for
阅读全文
摘要:此种排序将按照字典键值ASCII码进行排序 //字典键值排序 var sortDic = dic.OrderBy(x => x.Key).ToDictionary(x=>x.Key,x=>x.Value);
阅读全文
摘要:如果是编辑器不使用运行时的话,直接使用UnityEditor下的API即可 FileUtil.CopyFileOrDirectory 如果是运行时 /// <summary> /// 文件夹拷贝 /// </summary> /// <param name="sourcePath">源路径</par
阅读全文
摘要:直接上代码,注意 脚本需要放在Editor文件夹下 可按组合键,进行截图 ctrl + shift + y using System.IO; using System.Threading.Tasks; using UnityEditor; using UnityEditorInternal; usi
阅读全文
摘要:随机数种子,一直让随机数出现的规律变得相同的技术 这种技术常用于roughlike游戏中,使用相同种子的玩家开始一场游戏时,里面随机生成的要素将会变得相同 这使得种子会在玩家之间传播 【图:以撒的结合】 【图:杀戮尖塔】 上面2者,都使用了一个 字母加数字 的随机字符串作为游戏的种子 而使用字符串作
阅读全文
摘要:一个类即可 using System.Collections; using System.Collections.Generic; using UnityEngine; public class ImageLine : MonoBehaviour { //线条宽度 public float line
阅读全文
摘要:异步任务队列,十分好用 using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; /// <summary> /// 异步任务队列 ///
阅读全文
摘要:直接来,1个脚本 using System.Collections; using System.Collections.Generic; using System.Diagnostics; using UnityEditor; using Debug = UnityEngine.Debug; pub
阅读全文
摘要:实例代码:获取 [] 里面的内容 Lua版本 print(' ') for s in string.gmatch('pp[1g1]ppp[1jj2]pp[1413]ppp', '%[(%w+)%]') do print(s) end print(' ') C#版本 string str=@"[11]
阅读全文