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}
}
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}
}
其他人氣:312 ℃時間:2020-06-15 21:06:39
優(yōu)質(zhì)解答
OnGUI()方法里面沒有對于texmube是不是為空的判斷或者是不是有100的長度.
我來回答
類似推薦
- Parameter index out of range (1 > number of parameters, which is 0).
- //獲取頁面修改之前的信息(部分代碼)
- java.sql.SQLException:Parameter index out of range (1 > number of parameters,which is 0).
- 作文《我們》怎么寫?
- 合唱隊(duì)女生人數(shù)比男生人數(shù)的2倍多5比男生的3倍少16,男女生各多少人?
- 一條環(huán)形跑道長400米,甲練習(xí)騎自行車,平均每分鐘550米,乙練習(xí)跑步,平均每分鐘250米,兩人同時同地出發(fā).若兩人同向而行,則他們經(jīng)過多長時間首次相遇?
- 過直線外一點(diǎn)可以作無數(shù)條直線與已知直線平行.(_)
- 指數(shù)函數(shù)定義域,值域?
- 《別懂大二首(其一)》勉勵與自信的詩句是?
- 1.若n為正整數(shù),(n+11)²-n²的值總可以被k整除,則k等于( )
- 兩個正整數(shù)的積是540,它們最大公因數(shù)是6,求這兩個數(shù)
- 英語翻譯
猜你喜歡
- 1英語翻譯
- 2一個時鐘的分針長8厘米,它從上午8點(diǎn)走到12點(diǎn),分針的針尖共走了多少厘米?分針掃過的面積是多少?
- 3x+10-23.5=17 = =
- 4請問這道英語語法題
- 5冰水混合物是純凈物嗎?
- 61.My mother __a teacher.
- 7等腰三角形的底邊長20 cm,面積為100/33cm2,求它的各內(nèi)角.
- 8形容喜歡女生的詞語
- 9將30攝氏度100克硝酸鉀的飽和溶液蒸發(fā)掉10克水后,仍冷卻到30攝氏度,則蒸發(fā)前后溶液中保持不變的是
- 10a.2g氫氣b.2molNH3.c.9g水.d.1.806*10^24個硫酸分子,
- 11平行線分線段成比例逆定理是什么?有圖說明就更好了!
- 12落霞與孤鶩齊飛,秋水共長天一色的整詩誰知道