当前位置:网站首页>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 .
边栏推荐
- [pytorch] softmax function
- Class loading
- Can diffusion models be regarded as an autoencoder?
- SQL学习笔记(03)——数据约束关系
- laravel postman 提交表单出现419错误。2020年7月6日记。
- 2022.02.15_ Daily question leetcode six hundred and ninety
- JS prototype chain
- Construction of esp8266 FreeRTOS development environment
- 记一次redis超时
- [ESP nanny level tutorial] crazy completion chapter - Case: ws2812 light control system based on Alibaba cloud, applet and Arduino
猜你喜欢

Principles of Microcomputer - Introduction

Principles of Microcomputer - internal and external structure of microprocessor

2.4 激活函数

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

Understanding and implementation of AVL tree

Phishing identification app

nacos服务配置和持久化配置

Ranking list of domestic databases in February, 2022: oceanbase regained the "three consecutive increases", and gaussdb is expected to achieve the largest increase this month

2.4 activation function

【pytorch】nn. Crossentropyloss() and nn NLLLoss()
随机推荐
Design and manufacture of simple digital display electronic scale
js重写自己的函数
Exception handling of classes in C #
Dspic30f6014a LCD block display
JS rewrite their own functions
R language observation log (part24) -- initialization settings
[ESP nanny level tutorial] crazy completion chapter - Case: gy906 infrared temperature measurement access card swiping system based on the Internet of things
计网01-物理层
微信小程序 webview 禁止页面滚动,同时又不影响业务内overflow的滚动的实现方式
美团2022年机试
Wechat applet WebView prohibits page scrolling without affecting the implementation of overflow scrolling in the business
Daily practice of C language - day 80: currency change
Construction of esp8266 FreeRTOS development environment
【电赛训练】红外光通信装置 2013年电赛真题
Network counting 01 physical layer
OSPF - virtual link details (including configuration commands)
[pytorch learning] torch device
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DHT11 +nodejs local service + MySQL database
Latex插入的eps图片模糊解决方法
nacos简易实现负载均衡