개발 Tip/Unity3D
[펌] [NGUI] 스코어의 남은 자릿수를 0으로 채우기
LeeChen
2013. 10. 8. 10:45
반응형
Source Code
// UILabel의 게임오브젝트 public GameObject Score; // 기존의 UILabel의Text속성에9자릿수의0과 1을입력한 숫자를 가져옴(최초 셋팅은000000001) string score = this.Score.GetComponent().text; // 전 프레임에 스코어를 Int형으로 변환하고 +1을 한다 int totalScore = System.Convert.ToInt32(score) + 1; // 숫자를 문자형으로 변환 score = totalScore.ToString(); // 남은숫자 이외에는 0으로 채움 this.Score.GetComponent().text = score.PadLeft(9, '0');
출처 : http://unitystudy.net/bbs/board.php?bo_table=tip&wr_id=71
반응형