Returning a single dimension from a multidimensional array

So, as per the title, how do I do this?

I have a 2D array which is created like this:

private var allShips:Ship[,];

And when I try to return a single dimension of the array, like so (where ShipType is an enum that represents an int):

function getAllShips(shipType:ShipType) : Ship[] {
		return allShips[shipType];
	}

I get the error

BCE0022: Cannot convert ‘Ship’ to ‘Ship’.

When I try to just return allShips[0] I still get the same problem. Is what I’m trying to do possible in unityscript? I just want to return an array reference for iteration.

Thanks in advance

1 Answer

1

Nevermind, not sure if this is actually possible, which is a shame. I’ve ported the important bits of my code into C# which will make my problem go away :slight_smile: