검색결과 리스트
글
문자열값으로 변수 또는 함수 불러오는법
유니티 C#
2017. 8. 29. 13:49
문자열로 변수 불러오기
public int A = 10;
Debug.Log(this.GetType().GetField("A").GetValue(this));
출처: https://stackoverflow.com/questions/11122241/accessing-a-variable-using-a-string-containing-the-variables-name
문자열로 함수 부르기
public string A = "Test";
public void Test()
{
Debug.Log("Test");
}
this.GetType().GetMethod(A).Invoke(this, null);
출처: https://stackoverflow.com/questions/540066/calling-a-function-from-a-string-in-c-sharp