Unity 유니티 그림파일 순서대로 읽어오기, 반복문으로 버튼 생성
for(k=0;k<=5;k++)
{
iFile[k] = "file://"+ Application.dataPath +"/Source/Question/1/L1S1A"+(k+1)+".png";
tL[k]= new WWW(iFile[k]);
tD[k]= new Texture2D(64, 64);
tL[k].LoadImageIntoTexture(tD[k]);
bP[k]=(k+3)*100;
}
이전에 설명되었던 Apllication.dataPath를 활용했습니다.
그림파일에 숫자로 규칙성을 만들어주어 반복문으로 해결하게 했습니다.
(L1S1A1.png~L1S1A5.png까지 )
for(k=0;k<=5;k++)
{
if (GUI.Button (Rect (bP[k],550,100,50),tD[k]))
{
Userselect=k+1;
}
}
위 코드는 버튼을 생성할때 반복문을 사용했습니다.
댓글
댓글 쓰기