Hey, I'm trying to create a script that contains arrays of enemys and their info. How do I create an array in C# and access it from another C# file?
Any help would be appreciated!
Ive searched and they all seem to be in javascript :(
Hey, I'm trying to create a script that contains arrays of enemys and their info. How do I create an array in C# and access it from another C# file?
Any help would be appreciated!
Ive searched and they all seem to be in javascript :(
Creating a set-length array:
Define:
public Int[] arrayOfInts;
Set:
arrayOfInts = new Int[lengthOfArray];
arrayOfInts[0] = 10;
Dynamic arrays: Define:
using System.Collections.Generics;
public List<int> arrayOfInts;
Set:
arrayOfInts = new List<int>();
arrayOfInts.Add(10);
arrayOfInts[0] += 10;//This will result in 20, as the first element was defined as 10
Just figured I’d chime in here for a quick correction, since this was the first hit Google gave when I searched.
What Flynn says is absolutely correct except for one minuscule typo.
Instead of
using System.Collections.Generics;
You’ll want
using System.Collections.Generic;