Hi to all.
I have a quick problem which I need to be solved.
Lately been looking into lots of C# tutorials, which helped a lot, but still there are some exceptions when using C# into Unity and regular using.
I initialize an array, which is called results, and set 5 elements to it. Now, what I want to do is initialize them in the script, and one more thing - if that is possible, they can hold a value of any int variable right?
Here’s the code
using UnityEngine;
using System.Collections;
public class Label : MonoBehaviour {
int lives = 5;
public int[] results = new int[] {15, 1645, 135, 567};
// Use this for initialization
void Start () {
Debug.Log(results[1]);
}
// Update is called once per frame
void Update () {
}
}
It works fine if I initialize the values inside the editor, but this time it’s not what I’m looking for.
Thanks.