miduo_client/Assets/Scripts/Extension/GameExtension.cs

26 lines
631 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace GameLogic
{
public static class GameExtension
{
public static T AddMissingComponent<T>(this GameObject gameObj) where T : Component
{
T t = gameObj.GetComponent<T>();
if (t == null) t = gameObj.AddComponent<T>();
return t;
}
}
public static class UnityEngineObjectExtention
{
public static bool IsNull(this UnityEngine.Object o) // 或者名字叫IsDestroyed等等
{
return o == null;
}
}
}