字典翻译 问答 其它 C#IndexOutOfRangeException:Arrayindexisoutofrange怎么解决usingUnityEngine;usingSystem.Collections;publicclassscript_10_03:MonoBehaviour{x05Object[]texmube;x05intnumber=1;x05x05//Usethisforinitializationx05voidStart(){x05
问题标题:
C#IndexOutOfRangeException:Arrayindexisoutofrange怎么解决usingUnityEngine;usingSystem.Collections;publicclassscript_10_03:MonoBehaviour{x05Object[]texmube;x05intnumber=1;x05x05//Usethisforinitializationx05voidStart(){x05
问题描述:

C#IndexOutOfRangeException:Arrayindexisoutofrange怎么解决

usingUnityEngine;

usingSystem.Collections;

publicclassscript_10_03:MonoBehaviour{

x05Object[]texmube;

x05intnumber=1;

x05

x05//Usethisforinitialization

x05voidStart(){

x05texmube=Resources.LoadAll("Texture");

x05}

x05voidOnGUI(){

x05x05DrawImageNumber(0,100,number,texmube);}

x05voidDrawImageNumber(intx,inty,intnumber,Object[]texmube)

x05{char[]chars=number.ToString().ToCharArray();

x05x05Texture2Dtex=(Texture2D)texmube[0];

x05x05intwidth=tex.width;

x05x05intheight=tex.height;

x05x05foreach(charsinchars)

x05x05{inti=int.Parse(s.ToString());

x05x05x05GUI.DrawTexture(newRect(x,0,width,height),(Texture2D)texmube[i]);

x05x05x05x+=width;

x05x05}}

x05//Updateiscalledonceperframe

x05voidUpdate(){

x05

x05}

}

韩国新回答:
  OnGUI()方法里面没有对于texmube是不是为空的判断或者是不是有100的长度.
点击显示
其它推荐
热门其它推荐
  • 其它