Unity/C# 문법
[유니티] 무조건 외워야 할 문법!!
Skull Crusher
2021. 4. 25. 21:49
728x90
1. text(string)값을 정수로 변환
itemCountText의 text(string) 값을 정수로 변환함
string -> int : int.Parse("문자열");
int count = int.Parse(itemCountText.text);
2. 정수를 문자로 변환
int -> string : 정수형변수.ToString();
itemCountText.text = count.ToString();
3. 카운트값 1 증가
count = count + 1;
count += 1;
count++;
4. 프리팹을 게임오브젝트로 생성하는 메소드 : Instantiate()
-> Object.Instantiate(프리팹참조변수, 생성위치, 생성시회전);
Instantiate(itemPrefab, tempPosition, Quaternion.identity);
5. Timer 메소드를 지정
-> Invoke : 일정 시간 뒤에 지정한 메소드를 실행
-> InvokeRepeating : 일정 시간 간격으로 지정한 메소드를 실행