using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class LandeData : MonoBehaviour {
public Land[] lande;
// Use this for initialization
void Start ()
{
lande[0] = new Land("Danmark", 100, 100, 100, 0, 5.5f, 35);
lande[1] = new Land("Amerika", 80, 80, 80, 0, 250, 50);
}
[System.Serializable]
public class Land
{
public string navn;
public int moral;
public int håb;
public int helbred;
public int indflydelse;
public float indbyggere;
public int forurening;
public int relationDanmark;
public int relationAmerika;
public int relationRusland;
public int relationIran;
public int relationKina;
public int relationSaudArab;
public int relationEngland;
public int relationIsrael;
public Land(string nav, int mor, int hå, int helb, int indf, float indb, int foruren)
{
navn = nav;
moral = mor;
håb = hå;
helbred = helb;
indflydelse = indf;
indbyggere = indb;
forurening = foruren;
}
}
// Update is called once per frame
void Update ()
{
gameObject.GetComponent<Text>().text = (lande[0].navn + " " + lande[0].moral +" "+ lande[0].håb +" " + lande[0].indbyggere + " " + lande[0].forurening + "
“);
GetComponent().text = (GetComponent().text + lande[1].navn + " " + lande[1].moral +” “+ lande[1].håb +” " + lande[1].indbyggere + " " + lande[1].forurening + "
");
}}
I am trying to make this work:
But it comes with the error:
IndexOutOfRangeException: Array index is out of range.
(wrapper stelemref) object:stelemref (object,intptr,object)
LandeData.Start () (at Assets/aMyStuff/Organiser Jorden/Scripts/LandeData.cs:12)
How do I make the array accessible?