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(){
x05x05DrawImageNumber(0,100,number,texmube);}
x05void DrawImageNumber(int x,int y,int number,Object[] texmube)
x05{char[] chars=number.ToString().ToCharArray();
x05x05Texture2D tex=(Texture2D)texmube[0];
x05x05int width=tex.width;
x05x05int height=tex.height;
x05x05foreach(char s in chars)
x05x05{int i=int.Parse(s.ToString());
x05x05x05GUI.DrawTexture(new Rect(x,0,width,height),(Texture2D)texmube[i]);
x05x05x05x+=width;
x05x05}}
x05// Update is called once per frame
x05void Update () {
x05
x05}
}
答案
OnGUI()方法里面没有对于texmube是不是为空的判断或者是不是有100的长度.
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
最新试题
- 英语翻译
- 已知,如图,在三角形ABC中,BD,CD分别是角ABC,角ACE平分线,BD和CD相交于点D.求证角BDC=二分之一角A=90度
- 设数列{an}的前N项和为Sn,已知1/Sn+1/S2+1/S3+.+1/Sn=n/(n+1),求Sn
- 无 (10 12:51:43)
- A,B两地果园分别有苹果40吨和60吨如果总运输费为1090元时,那么从A果园运到C地的苹果为多少吨?
- 四字词语第一个字读第四声第二个字读第三声第三个字读第二声第四个字读第一声,要10个
- 把5个苹果分给2个小朋友怎么分?
- 疲倦不堪,小心翼翼,不求甚解,苦思冥想用这些词写一句话
- 请问1N的力是多重的物体的压力?1N=?KG
- 数学六年级创新课堂答案
热门考点