C#IndexOutOfRangeException:Array index is out of range怎么解决
C#IndexOutOfRangeException:Array index is out of range怎么解决
using UnityEngine;
using System.Collections;
public class script_10_03 :MonoBehaviour {
\x05Object[] texmube;
\x05int number=1;
\x05
\x05// Use this for initialization
\x05void Start () {
\x05texmube=Resources.LoadAll("Texture");
\x05}
\x05void OnGUI(){
\x05\x05DrawImageNumber(0,100,number,texmube);}
\x05void DrawImageNumber(int x,int y,int number,Object[] texmube)
\x05{char[] chars=number.ToString().ToCharArray();
\x05\x05Texture2D tex=(Texture2D)texmube[0];
\x05\x05int width=tex.width;
\x05\x05int height=tex.height;
\x05\x05foreach(char s in chars)
\x05\x05{int i=int.Parse(s.ToString());
\x05\x05\x05GUI.DrawTexture(new Rect(x,0,width,height),(Texture2D)texmube[i]);
\x05\x05\x05x+=width;
\x05\x05}}
\x05// Update is called once per frame
\x05void Update () {
\x05
\x05}
}
OnGUI()方法里面没有对于texmube是不是为空的判断或者是不是有100的长度.