본문 바로가기

C#

type

type: 클래스의 데이터 타입에 대한 정보를 가져옴

 

Type type = slimeA.GetType();
FieldInfo[] fields = type.GetFields();

for(int i = -; i<fields.Length; i++)
{
	Debug.Log(fields[i].Name);
}

Debug.Log(type.GetField("hp").GetValue(slimeA)); // slimeA에서 hp 필드를 가져옴
type.GetField("hp").SetValue(slimeA, 80);

 

함수 호출

type.GetMethods("Attack").Invoke(slimeA, null); // slimeA에 있는 Attack이라는 함수 호출(보내는 매개변수 없음)

'C#' 카테고리의 다른 글

반복자, 캡슐화  (0) 2022.06.23
코루틴,  (0) 2022.06.23
Deep Copy  (0) 2022.06.22
Parameter / Arguments 차이  (0) 2022.06.22
리플렉션  (0) 2022.06.22