using System;
using UnityEngine;
public class TestVar : MonoBehaviour
{
void Start()
{
bool ad = false;
uint abc = 123;
Debug.Log(GetVarName<uint>(p => abc));
}
public static string GetVarName<T>(System.Linq.Expressions.Expression<Func<T, T>> exp)
{
return ((System.Linq.Expressions.MemberExpression)exp.Body).Member.Name;
}
}
打印指定变量名
--------------------------------------分割线----------------------------------------
因为当前需求,要对比较多的非指定类绘制风格化自定义属性面板,为了省事用字段名+循环绘制,突然记起来这破优快云,再补充下好了
输出全部变量名和属性名 (含基类)