- 博客(6)
- 收藏
- 关注
原创 ? ?? .?分别在C#中得意思
?表示判断是否为空比如我们常用得三元表达式var a = a?b:c a如果为空则取b 否则取c??表示空合并运算符(??)用于定义可空类型和引用类型的默认值。如果此运算符的左操作数不为null,则此运算符将返回左操作数,否则返回右操作数。例如:a ?? b 当a为null时则返回b,a不为null时则返回a本身。GameObject.FindObjectOfType() ?? new GameObject(“PostProcessVolumeBlur”).AddComponent();.?
2020-12-28 13:45:21 198
原创 判断字符串是否为空 API string.IsNullOrEmpty
测试结果Debug.Log(s == null);//trueDebug.Log(ss == null);//falseDebug.Log(sss == null);//falseDebug.Log(string.IsNullOrEmpty(s));//trueDebug.Log(string.IsNullOrEmpty(ss));//falseDebug.Log(string.IsNullOrEmpty(sss));//true测试总结: 如果判断字符串 是否为空null 只要字符串没有.
2020-12-25 11:19:49 631
原创 牛逼的插件可以用来播放gif webp图片
private WebpTest mWebpTest;private void Awake(){ mWebpTest = transform.gameObject.AddComponent<WebpTest>(); mWebpTest.image.Add(GameObject.Find("RawImage").GetComponent<RawImage>());}导入资源包 挂上WebpTest 脚本即可要资源包的联系v:GRAYLCH...
2020-12-24 11:26:14 621
原创 Unity 中打开文件窗口
using System.Runtime.InteropServices;using System;[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]public class FileDialogStruct{public int structSize = 0;public IntPtr dlgOwner = IntPtr.Zero;public IntPtr instance = IntPtr.Zero;public
2020-12-23 14:37:03 1046
原创 单例编写
static FloorHintMgr _instance;public static FloorHintMgr Instance { get { if (_instance == null) { _instance = GameObject.FindObjectOfType<FloorHintMgr>() ?? new GameObject("FloorHintMgr").AddComponent
2020-12-22 17:11:30 95
原创 Unity中随机数 写法
UnityEngine.Random.InitState(10);//带有种子的 10就是种子 每次随机结果都一样 Debug.Log(UnityEngine.Random.Range(10, 100000)); UnityEngine.Random.InitState();//如果不带种子 每次随机结果就不一样 Debug.Log(UnityEngine.Random.Range(10, 100000));C# 同理C#中的随机数System.Random ra...
2020-12-22 10:32:41 694
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人