当前位置:网站首页>Unity tips for reducing the amount of code -- empty protection extension
Unity tips for reducing the amount of code -- empty protection extension
2022-07-01 09:28:00 【Thynn_】
In the process of writing code , There are many places that need air protection , Here's a tip to reduce the amount of code written , Here's the code
namespace UnityEngine.UI
{
public static class UIExtension
{
public static void SetActive(this GameObject go, bool bActive)
{
if(go == null)
{
// You can add null prompt logic here
return;
}
go.SetActive(bActive);
}
public static void SetActive(this Transform trans,bool bActive)
{
if(trans == null)
{
// You can add null prompt logic here
return;
}
trans.gameObject.SetActive(bActive);
}
}
}This code is for GameObject Of SetActive Method is empty protected , At the same time Transform Expanded , Other components can also be developed in a similar way .
边栏推荐
- 3D printing Arduino four axis aircraft
- Imitation of Baidu search results top navigation bar effect
- ES6 decoupling top-level objects from windows
- Microcomputer principle - bus and its formation
- Differences between JS valueof and toString
- 【pytorch学习】torch.device
- delete和delete[]引发的问题
- MySQL optimization
- 短路运算符惰性求值
- 队列的实现和应用
猜你喜欢

NoSQL数据库的安装和使用
![delete和delete[]引发的问题](/img/d9/a1c3e5ce51ef1be366a973aa42d1f0.png)
delete和delete[]引发的问题

MapReduce programming basics

Learning practice: comprehensive application of cycle and branch structure (II)

2.3 【kaggle数据集 - dog breed 举例】数据预处理、重写Dataset、DataLoader读取数据

集成积木报表报错 org.apache.catalina.core.StandardContext.filterStart 启动过滤器异常

2.2 【pytorch】torchvision. transforms

Principle and application of single chip microcomputer timer, serial communication and interrupt system

Daily practice of C language - day 80: currency change

SQL学习笔记(01)——数据库基本知识
随机推荐
SQL学习笔记(01)——数据库基本知识
Log4j log framework
nacos簡易實現負載均衡
【无标题】
Bird recognition app
js valueOf 与 toString 区别
【ESP 保姆级教程 预告】疯狂Node.js服务器篇 ——案例:ESP8266 + DHT11 +NodeJs本地服务+ MySQL数据库
2.3 【pytorch】数据预处理 torchvision.datasets.ImageFolder
Rich text interpolation
Niuke monthly race 22- collect pieces of paper
3D打印Arduino 四轴飞行器
[ESP nanny level tutorial] crazy completion chapter - Case: gy906 infrared temperature measurement access card swiping system based on the Internet of things
UE small knowledge point controller possess pawn process
[pytorch] 2.4 convolution function nn conv2d
MySQL optimization
短路运算符惰性求值
树结构---二叉树2非递归遍历
MapReduce编程基础
Reproduced Xray - cve-2017-7921 (unauthorized access by Hikvision)
How Kolo enables NFT music industry