I’m an Unity noob, and I just started today.
I have a cube (3x3x3) with some simple texture.
I know from XNA that, if you try to draw this cube 10,000 times, you’ll need to implement hardware instancing (with shaders etc).
While in Unity, I tried doing like this:
for (int x = 0; x < 100; x++)
{
for (int z = 0; z < 100; z++)
{
var instance = (GameObject) Instantiate(Resources.Load("Cube", typeof(GameObject)));
instance.renderer.material.mainTexture = (Texture2D) Resources.Load("CubeTexture", typeof(Texture2D));
//cube = instance;
instance.renderer.transform.position = new Vector3(x*2, 0, z*2);
instance.renderer.transform.localScale = new Vector3(100, 100, 100);
instance.renderer.transform.RotateAround(Vector3.right, -90*Mathf.Deg2Rad);
}
}
To my surprise it worked pretty well with no performance loss.
I KNOW this isn’t the best way to do it, so my question to you guys is, what would be the best way to do what I am doing now with the code above.
Thanks :3