using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace XericLibrary.Runtime.MacroLibrary
{
public static class MacroObject
{
#region 对象操作
///
/// 无论如何都要获取一个组件
///
///
///
public static T GetComponentAnyway(this GameObject obj)
where T : Component
{
var component = obj.GetComponent();
if(component is null)
component = obj.AddComponent();
return component;
}
///
/// 无论如何都要获取一个对象
///
///
///
///
public static T GetObjectAnyway(this T obj)
where T : new()
{
if(obj is null)
obj = new T();
return obj;
}
#endregion
}
}