Question by
Boniface99 · Jan 07, 2017 at 10:19 PM ·
c#scripting beginnerarrays
Noob question about very simple array script
Hi- I'm working on a basic C# scripting lesson.
Here is my script:
using UnityEngine;
using System.Collections;
public class newScript : MonoBehaviour {
int a = 5;
public int[] arr;
// Use this for initialization
void Start () {
foreach (int i in arr) {
Debug.Log(i);
}
// Update is called once per frame
void Update () {
}
}
I receive 3 errors from Monodevelop
Here is the lesson I received the instruction from link text
Any help I could receive would be greatly appreciated as I am really trying to make an effort to learn as much as I can. Thank you in advance for your help. Have a good day, Dale
capture.png
(48.9 kB)
Comment
Best Answer
Answer by KoenigX3 · Jan 07, 2017 at 10:55 PM
You have a very common problem: a missing curly bracket after the Debug.Log() function.
void Start () {
foreach (int i in arr) {
Debug.Log(i);
}
}
Everything else looks fine, just be sure to fill the array with data in the Inspector, as seen in the video.