22 lines
465 B
C#
22 lines
465 B
C#
using System;
|
|
using System.Reflection;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class LoadIndex : Attribute
|
|
{
|
|
private int Idx { get; }
|
|
|
|
public LoadIndex(int idx)
|
|
{
|
|
Idx = idx;
|
|
}
|
|
|
|
public static int GetLoadIdx<T>(T instance)
|
|
{
|
|
// 先通过反射拿到属性
|
|
var attribute = instance.GetType().GetCustomAttribute<LoadIndex>();
|
|
return attribute?.Idx ?? 5;
|
|
}
|
|
}
|
|
} |