How to declare typed array in UnityScript

I have a code like this.

public var tileButtonRects = new Array();
function  ShowTileButtons(){
  for(var i in [0,1,2]){
    for(var j in [0,1,2]){
      tileButtonRects[i+j*3] = new Rect(15+(i*28), 100+(j*26), 10, 15);
      GUI.DrawTexture(tileButtonRects[i+j*3], tiles['1s'+ ((i+1)+(j*3)).ToString()]);

And I get this error.

Assets/GameMaster.js(31,38): BCW0028:
WARNING: Implicit downcast from
‘Object’ to ‘UnityEngine.Rect’.

As far as I understand the error message says that I need to declare the Object as Rect.
But I couldn’t find out how to do it.

I’ve read this document, and tried var tileButtonRects = Rect[];, but it didn’t work.
Could you tell me how to declare a Array of Rect Object?


I get BCE0048: Type 'System.Type' does not support slicing. error, with this code.

#pragma strict

var tileButtonRects = Rect[9];

function Start () {
function Update () {

When defining a typed array (which you should ALWAYS use over the Array class), you need to define the length of the array. Arrays are fixed-length constructs. One they’re initialised, you cannot change their length (if you need to, then you should be using generic Lists).

Instead of using var tileButtonRects = new Rect[];, you need something along the lines of var tileButtonRects = new Rect[5];, for example, which would create an array of length 5.

EDIT: Have updated my answer. It looks like you need the new keyword in this case, from a quick bit of research.