NullReferenceException: オブジェクト参照がオブジェクト Tower.OnGUI () のインスタンスに設定されていません (Assets/Tower.cs:100)
関連する行は次のとおりです。
if(Main.Gold >= Towers.u[stage])
Towers の変数はそのように定義されていますが、間違っていますか?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Towers : MonoBehaviour {
public static float[] d;
public static float[] r;
public static float[] s;
public static float[] u;
// Use this for initialization
void Start () {
d = new float[10];
d[0] = 1f;
d[1] = 3f;
d[2] = 5f;
d[3] = 7f;
d[4] = 9f;
d[5] = 11f;
d[6] = 13f;
d[7] = 15f;
d[8] = 18f;
d[9] = 21f;
d[10] = 23f;
r = new float[10];
r[0] = 5f;
r[1] = 9f;
r[2] = 13f;
r[3] = 17f;
r[4] = 21f;
r[5] = 25f;
r[6] = 29f;
r[7] = 33f;
r[8] = 37f;
r[9] = 41f;
r[10] = 45f;
s = new float[10];
s[0] = 3f;
s[1] = 2.8f;
s[2] = 2.6f;
s[3] = 2.4f;
s[4] = 2.2f;
s[5] = 2f;
s[6] = 1.8f;
s[7] = 1.6f;
s[8] = 1.4f;
s[9] = 1.2f;
s[10] = 1f;
u = new float[10];
u[0] = 50f;
u[1] = 100f;
u[2] = 150f;
u[3] = 200f;
u[4] = 250f;
u[5] = 300f;
u[6] = 350f;
u[7] = 400f;
u[8] = 450f;
u[9] = 500f;
u[10] = 0f;
}
}
ありがとう!