当前位置:网站首页>Lookup encapsulation of unity monobehavior component
Lookup encapsulation of unity monobehavior component
2022-06-22 07:35:00 【Liam666】
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
public class SimMonoBehaviour : MonoBehaviour
{
protected T findComponent<T>(Transform parent, string path) where T : Component
{
if (parent == null)
return null;
Transform transform = parent.Find(path);
if (transform == null)
return null;
T component = transform.GetComponent<T>();
return component;
}
protected T addComponent<T>(Transform parent) where T : Component
{
return addComponent<T>(parent, "");
}
protected T addComponent<T>(GameObject obj) where T : Component
{
return addComponent<T>(obj.transform, "");
}
protected T addComponent<T>(string path) where T : Component
{
return addComponent<T>(this.transform, path);
}
protected T addComponent<T>(Transform parent, string path) where T : Component
{
if (parent == null)
return null;
Transform transform = parent.Find(path);
if (transform == null)
return null;
T component = transform.GetComponent<T>();
if (component == null)
component = transform.gameObject.AddComponent<T>();
return component;
}
protected T findComponent<T>(string path) where T : Component
{
return findComponent<T>(this.transform, path);
}
protected Button findButton(Transform parent, string path, UnityAction action)
{
Button button = findComponent<Button>(parent, path);
if(button != null && action != null)
{
button.onClick.AddListener(action);
}
return button;
}
protected Button findButton(string path, UnityAction action)
{
return findButton(this.transform, path, action);
}
protected virtual void Awake()
{
}
protected virtual void OnEnable()
{
}
protected virtual void Start()
{
}
protected virtual void FixedUpdate()
{
}
protected virtual void Update()
{
}
protected virtual void LateUpdate()
{
}
protected virtual void OnDisable()
{
}
protected virtual void OnDestroy()
{
}
}
边栏推荐
- 3、 Stylesheet component
- Crmeb open source version, a free mall worth trying
- MTK platform execution disable_ Interrupt signals masked during IRQ will be enabled when I execute enable_ Continue triggering after IRQ
- Taobao assistant can not be used. How to export the baby in the warehouse to backup the data package
- JS gets all child nodes under a div natively
- How to view cookies in Chrome browser
- 网站的排名对于网站很重要
- 丰田bZ4X取消上市发布会,就算低温充电问题不存在,产品力如何?
- Backup the method of uploading babies in Taobao stores to multiple stores
- Bad slam resolution
猜你喜欢

Detailed explanation of capturing the whole store treasure and uploading it to multiple stores
![[standard version 4.3] marketing activities (group bargaining second kill) error reporting under orders](/img/44/2e7789a97fa43d196ef770e8b3c4d4.jpg)
[standard version 4.3] marketing activities (group bargaining second kill) error reporting under orders

Backup the method of uploading babies in Taobao stores to multiple stores

Crmeb mall order shipping function

Crmeb mall distribution function

The pit on the school recruitment Road

What if the finder fails to respond continuously? Finder unresponsive solution tutorial

Rviz ROS wiki official website tutorial learning notes (1) - User Guide

Greek alphabet - system / service name commonly used in development - Collection

Crmeb open source version, a free mall worth trying
随机推荐
Summary of methods for calculating the number of solutions of indefinite equations
Can Taobao batch copy babies synchronize the original baby inventory
Reasons and solutions for Taobao's baby's prompt "sales attribute is required and parameter format is wrong"
Multi camera data collection based on Kinect azure (III)
What are the functions of Taobao batch copy tool?
Remote Desktop Manager
目标检测系列——开山之作RCNN原理详解
Chromedriver all versions download
5、 Image component
C语言实现的简易考试系统
JS implementation of random generation of 16 bit key -- Basic accumulation
Matlab用深度学习循环神经网络RNN长短期记忆LSTM进行波形时间序列数据预测
Real MySQL interview questions (20) -- video data analysis practice
Open version - inventory description
White paper on Web page quality of Baidu search engine guides website construction and optimization
Lean production | lean management
okcc呼叫中心的权限管理
How to upload Taobao tmall products with one click
How to improve Baidu's weight
Vue failed to connect to MySQL database