所以,这个错误(标题)不断出现,我不知道为什么。它可能很简单,但我看不到它。这是代码,我将标记错误所指的内容。
using UnityEngine;
using System.Collections;
public class ScoreCalculator : MonoBehaviour {
public int[8] finalScore = new int[8]; // it's the first "]" here
public void IncreaseMyScore (int increaseAmount, int forLevel) {
finalScore[forLevel] += increaseAmount;
}
public void IncreaseByOne (int forLevel) {
IncreaseMyScore(1, forLevel);
}
public void IncreaseByTwo (int forLevel) {
IncreaseMyScore(2, forLevel);
}
public void IncreaseByThree (int forLevel) {
IncreaseMyScore(3, forLevel);
}
public void IncreaseByFour (int forLevel) {
IncreaseMyScore(4, forLevel);
}
public void SaveMyScores () {
for (int i = 0; i < 8; i++)
PlayerPrefs.SetFloat("FinalScore"+i,finalScore[i]);
}
}
代码中没有中断,只是为了显示错误所指的内容。再次感谢!
答案 0 :(得分:2)
数组类型没有大小。 int[]
是一种类型; int[8]
没有意义。
删除号码。