일반 자료형(int, char, short, string, System.Object 등)은 const를 사용해서 상수화 가능
그러나 클래스/구조체/배열 등과 같은 사용자 정의 형식은 const를 사용할 수 없음(readonly로 상수화 가능)
const 사용시 static이지만 readonly는 static이 아니므로 선언시 작성해주어야 함
const는 선언과 동시에 초기화 해야 하지만 readonly는 선언시/생성자 초기화할 수 있음
const는 컴파일 타임 상수/readonly는 런타임 상수로도 사용 가능
https://msdn.microsoft.com/ko-kr/library/acdd6hb7.aspx
https://msdn.microsoft.com/ko-kr/library/ms173119.aspx
'유니티' 카테고리의 다른 글
[5.4.2f1] Vector3.normalized / Vector3.magnitude (0) | 2016.10.17 |
---|---|
[5.4.0f3] Application.LoadLevel("SceneName") 시 경고 메세지 (0) | 2016.09.07 |
[5.3.4f1] loadlevel시 화면이 까맣게 변하는 현상 해결 (0) | 2016.05.07 |
transform.GetComponent<> 사용 시 주의사항 (0) | 2016.04.04 |
Input.Mouse 관련해서 (0) | 2016.03.27 |