zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Unity/Assets/Model/Core/ClassHelper.cs

24 lines
527 B
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using System;
using System.Collections.Generic;
namespace ET
{
public static class ClassHelper
{
public static T As<T>(this object obj) where T : class
{
if (obj == null)
{
Log.Warning($"obj == null");
return null;
}
T t = obj as T;
if (t == null)
{
Log.Error($"the cast of type :{obj.GetType()} to {typeof(T)} is invalid");
}
return t;
}
}
}