Hi everyone,

I’m trying to rewrite my script I made in JavaScript to C#.

I have some difficulty doing some things:

How can I do the following in C# :

**Wait for a function to completely finish:**

```
function MyFunction01()
{
...
...
return true;
}
function MyFunction02()
{
yield MyFunction01();
Debug.Log("Finished");
}
```

**Pass a function as parameters:**

```
function getNewID()
{
var newID = ...;
...
return newID;
}
function myFunction(x : int, y : int, z : int)
{
...
}
myFunction(getNewID(),getNewID(),getNewID())
```

**And here the last thing, but not least, very strang, giving me a null reference when trying to acces the Tile variable, it seams that in C# I can’t use the Tile Variable between the if/ else if:**

JavaScript (Working)

```
function myFunction()
{
var WallTiles : Object[] = Resources.LoadAll("Dungeon/Walls");
for(var y=0;y<generator.ysize;y++)
{
for(var x=0;x<generator.xsize;x++)
{
var TheCell : int = generator.getCell(x,y);
if(TheCell == 1)
{
var typeOfTile : Array = generator.getDirectionArray(x,y);
if(typeOfTile[0] == 0) Tile = Instantiate(WallTiles[Random.Range(0,WallTiles.Length)],Vector3(x*tileSize,0,-y*tileSize),Quaternion.identity); //WALl
else if(typeOfTile[0] == 1) Tile = Instantiate(CornerTiles[Random.Range(0,CornerTiles.Length)],Vector3(x*tileSize,0,-y*tileSize),Quaternion.identity); //CORNER
else if(typeOfTile[0] == 2) Tile = Instantiate(DoubleCornerTiles[Random.Range(0,DoubleCornerTiles.Length)],Vector3(x*tileSize,0,-y*tileSize),Quaternion.identity); //DOUBLE CORNER
Tile.transform.parent = dungeonParent.transform;
Tile.transform.Rotate(Vector3(0,90 * typeOfTile[1],0));
//Create Objects
if(typeOfTile[0] == 0) PopulateObject(Tile, x , y);
}
}
}
}
C#
private void myFunction()
{
Object[] WallTiles = Resources.LoadAll("Dungeon/Floors");
for(int y=0;y<generator.ysize;y++)
{
for(int x=0;x<generator.xsize;x++)
{
int TheCell = generator.getCell(x,y);
GameObject Tile;
//Create Walls
if(TheCell == 1)
{
int[] typeOfTile = generator.getDirectionArray(x,y);
if(typeOfTile[0] == 0) Tile = Instantiate(WallTiles[Random.Range(0,WallTiles.Length)],new Vector3(x*tileSize,0,-y*tileSize),Quaternion.identity) as GameObject; //WALl
else if(typeOfTile[0] == 1) Tile = Instantiate(CornerTiles[Random.Range(0,CornerTiles.Length)],new Vector3(x*tileSize,0,-y*tileSize),Quaternion.identity) as GameObject ; //CORNER
else if(typeOfTile[0] == 2) Tile = Instantiate(DoubleCornerTiles[Random.Range(0,DoubleCornerTiles.Length)],new Vector3(x*tileSize,0,-y*tileSize),Quaternion.identity) as GameObject ; //DOUBLE CORNER
Tile.transform.parent = dungeonParent.transform;
Tile.transform.Rotate(new Vector3(0,90 * typeOfTile[1],0));
if(typeOfTile[0] == 0) PopulateObject(Tile as GameObject, x , y)
}
}
}
}
```

Thank you very much if you take the time to answer me, I’m kind of stuck right now to continue my game :s