|
|
|
|
|
|
public Texture2D[] m_Textures = new Texture2D[8]; |
|
|
|
|
|
|
|
public int m_GridWidth = 16; |
|
|
|
public int m_GridLayers = 1; |
|
|
|
public float m_Spacing = 0.6f; |
|
|
|
|
|
|
|
public static bool m_DifferentColors = true; |
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
m_Objects = new GameObject[m_GridWidth * m_GridWidth]; |
|
|
|
m_Objects = new GameObject[m_GridWidth * m_GridWidth * m_GridLayers]; |
|
|
|
for (int z = 0; z < m_GridWidth; z++) |
|
|
|
|
|
|
|
Random.InitState(31415926); |
|
|
|
|
|
|
|
for (int y = 0; y < m_GridLayers; y++) |
|
|
|
for (int x = 0; x < m_GridWidth; x++) |
|
|
|
for (int z = 0; z < m_GridWidth; z++) |
|
|
|
// int i = z * m_CubesRow + x;
|
|
|
|
for (int x = 0; x < m_GridWidth; x++) |
|
|
|
{ |
|
|
|
// int i = z * m_CubesRow + x;
|
|
|
|
float fX = (x - (m_GridWidth / 2)) * 2; |
|
|
|
float fY = Random.Range(-0.5f, 0.5f); |
|
|
|
float fZ = (z - (m_GridWidth / 2)) * 2; |
|
|
|
float fX = (x - (m_GridWidth / 2)) * 2; |
|
|
|
float fY = (y - (m_GridLayers / 2)) * 2 + Random.Range(-0.5f, 0.5f); |
|
|
|
float fZ = (z - (m_GridWidth / 2)) * 2; |
|
|
|
Vector3 vPos = new Vector3(fX * m_Spacing, fY, fZ * m_Spacing); |
|
|
|
vPos += m_CenterPoint.position; |
|
|
|
Vector3 vPos = new Vector3(fX * m_Spacing, fY, fZ * m_Spacing); |
|
|
|
vPos += m_CenterPoint.position; |
|
|
|
int r = Random.Range(0, 3); |
|
|
|
int r = Random.Range(0, 3 + 1); |
|
|
|
m_Objects[iIndex] = Instantiate(m_ObjectsPrefab[r], vPos, m_CenterPoint.rotation) as GameObject; |
|
|
|
m_Objects[iIndex] = Instantiate(m_ObjectsPrefab[r], vPos, m_CenterPoint.rotation) as GameObject; |
|
|
|
if (m_DifferentColors) |
|
|
|
{ |
|
|
|
Renderer renderer = m_Objects[iIndex].GetComponent<Renderer>(); |
|
|
|
Material mat = Instantiate(m_Material); |
|
|
|
Color oColor = new Color(Random.value, Random.value, Random.value, 1.0f); |
|
|
|
mat.SetColor("myColor", oColor); |
|
|
|
if (m_DifferentColors) |
|
|
|
{ |
|
|
|
Renderer renderer = m_Objects[iIndex].GetComponent<Renderer>(); |
|
|
|
Material mat = Instantiate(m_Material); |
|
|
|
Color oColor = new Color(Random.value, Random.value, Random.value, 1.0f); |
|
|
|
mat.SetColor("myColor", oColor); |
|
|
|
int t = Random.Range(0, 7); |
|
|
|
mat.SetTexture("_MainTex", m_Textures[t]); |
|
|
|
int t = Random.Range(0, 7 + 1); |
|
|
|
mat.SetTexture("_MainTex", m_Textures[t]); |
|
|
|
mat.InitUniformBuffers(); |
|
|
|
mat.InitUniformBuffers(); |
|
|
|
renderer.material = mat; |
|
|
|
renderer.material = mat; |
|
|
|
} |
|
|
|
iIndex++; |
|
|
|
iIndex++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|