分散文件结构,添加了枚举类型的一个辅助类
This commit is contained in:
42
Runtime/MicroLibrary/MacroObject.cs
Normal file
42
Runtime/MicroLibrary/MacroObject.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
public static class MacroObject
|
||||
{
|
||||
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD>Ҫ<EFBFBD><D2AA>ȡһ<C8A1><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public static T GetComponentAnyway<T>(this GameObject obj)
|
||||
where T : Component
|
||||
{
|
||||
var component = obj.GetComponent<T>();
|
||||
if(component is null)
|
||||
component = obj.AddComponent<T>();
|
||||
return component;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ζ<EFBFBD>Ҫ<EFBFBD><D2AA>ȡһ<C8A1><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static T GetObjectAnyway<T>(this T obj)
|
||||
where T : new()
|
||||
{
|
||||
if(obj is null)
|
||||
obj = new T();
|
||||
return obj;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user