Ok, so this question might sound very stupid, since I have no idea what I’m talking about.
Let’s say I’m making a 2D minecraft game. I have a 2D array (Cell[x,y]) representing each block the world.
Now lets say I have a script with this code :
using UnityEngine;
using System.Collections;
public struct Earth
{
public bool Solid;
public static void SetUV(int FirstVertice)
{
MeshControl.newUVs[FirstVertice] = new Vector2(0000/1024F,1016/1024F);
MeshControl.newUVs[FirstVertice+1] = new Vector2(0000/1024F,1024/1024F);
MeshControl.newUVs[FirstVertice+2] = new Vector2(0007/1024F,1024/1024F);
MeshControl.newUVs[FirstVertice+3] = new Vector2(0007/1024F,1016/1024F);
}
}
public struct Empty
{
public bool Solid;
public static void SetUV(int FirstVertice)
{
MeshControl.newUVs[FirstVertice] = new Vector2(1,1);
MeshControl.newUVs[FirstVertice+1] = new Vector2(1,1);
MeshControl.newUVs[FirstVertice+2] = new Vector2(1,1);
MeshControl.newUVs[FirstVertice+3] = new Vector2(1,1);
}
}
How could make my array point to structs ? For exemple Cell[100,234] would be Empty and Cell[25,36] would be Earth ? And then could i do something like Cell[x,y].SetUV(Bob) to call the struct’s at cell[x,y] function ?
On a side note, it won’t let me set the variable solid. How can I make it true for the first one and false for the second ?