using System;
using System.Collections.Generic;
using System.Text;
namespace UnityEngine
{
///
/// GameObject的扩展
///
public static class GameObjectExtension
{
///
/// 获取组件的操作,如果有则直接获取,没有,则添加
///
///
///
///
public static T RequireComponent(this GameObject go) where T:Component
{
var cm = go.GetComponent();
if (cm == null)
{
cm = go.AddComponent();
}
return cm;
}
}
}