void Start() { Vector3 separationDist = cubeSize + cubeSize * (separationPercent); cubes = new CubeMaker[cubesPerWidth, cubesPerDepth]; float x = startX; for (int i = 0; i < cubesPerWidth; i++) { float z = startZ; for (int j = 0; j < cubesPerDepth; j++) { GameObject cube = Instantiate(cubePrefab, this.transform); cube.transform.position = new Vector3(x, yPlane, z); CubeMaker cubeMaker = cube.GetComponent <CubeMaker>(); cubeMaker.size = cubeSize; cubes[i, j] = cubeMaker; z += separationDist.z; } x += separationDist.x; } }
public override void OnInspectorGUI() { DrawDefaultInspector(); CubeMaker instance = (CubeMaker)target; // Instatiate cubes if (GUILayout.Button("Create Cube")) { instance.Create(); } if (GUILayout.Button("Reset Size")) { instance.ResetSize(); } }
private void Initialize() { Release(); if (SystemInfo.supportsComputeShaders == false) { return; } CubeMaker.Generate(1f, out cube); argBuffer = new ComputeBuffer(ARG_BUFFER_SIZE, sizeof(uint), ComputeBufferType.IndirectArguments); initPartialBuffer(); initCullResultBuffer(); initPerlinNoise(Time.time); }
// Drawing handles void OnSceneGUI() { CubeMaker instance = (CubeMaker)target; instance.DrawResizeHandles(); }
//Generating the walls of the maze using the cube primitve //Each cube is being scaled and positioned according to where it is supposed to be on the plane //Moreover, each cube also contains a box collider so that the player will not go through the walls of the maze void mazeWalls() { for (int i = 0; i < 15; i++) { GameObject wall = new GameObject(); wall.transform.position = Vector3.zero; wall.transform.SetParent(wallMaze.transform); wall.name = "Wall " + (i + 1); wall.tag = "Wall"; wall.AddComponent <BoxCollider>(); wall.AddComponent <CubeMaker>(); listOfWalls.Add(wall); CubeMaker cubeMaker = listOfWalls[i].GetComponent <CubeMaker>(); cubeMaker.PrimitiveColour = new Color32(82, 140, 160, 255); } listOfWalls[0].GetComponent <CubeMaker>().Size = new Vector3(0.5f, 1.5f, 15.5f); listOfWalls[0].transform.position = new Vector3(0.5f, 1.5f, 15); listOfWalls[1].GetComponent <CubeMaker>().Size = new Vector3(15f, 1.5f, 0.5f); listOfWalls[1].transform.position = new Vector3(15f, 1.5f, 30); listOfWalls[2].GetComponent <CubeMaker>().Size = new Vector3(0.5f, 1.5f, 15.5f); listOfWalls[2].transform.position = new Vector3(30, 1.5f, 15); listOfWalls[3].GetComponent <CubeMaker>().Size = new Vector3(15, 1.5f, 0.5f); listOfWalls[3].transform.position = new Vector3(15, 1.5f, 0); listOfWalls[4].GetComponent <CubeMaker>().Size = new Vector3(0.5f, 1.5f, 2.5f); listOfWalls[4].transform.position = new Vector3(15, 1.5f, 2); listOfWalls[5].GetComponent <CubeMaker>().Size = new Vector3(0.5f, 1.5f, 6); listOfWalls[5].transform.position = new Vector3(25, 1.5f, 5.5f); listOfWalls[6].GetComponent <CubeMaker>().Size = new Vector3(0.5f, 1.5f, 2.5f); listOfWalls[6].transform.position = new Vector3(5, 1.5f, 8); listOfWalls[7].GetComponent <CubeMaker>().Size = new Vector3(10, 1.5f, 0.5f); listOfWalls[7].transform.position = new Vector3(10, 1.5f, 10); listOfWalls[8].GetComponent <CubeMaker>().Size = new Vector3(0.5f, 1.5f, 4); listOfWalls[8].transform.position = new Vector3(20, 1.5f, 13.5f); listOfWalls[9].GetComponent <CubeMaker>().Size = new Vector3(0.5f, 1.5f, 2); listOfWalls[9].transform.position = new Vector3(10, 1.5f, 12); listOfWalls[10].GetComponent <CubeMaker>().Size = new Vector3(5, 1.5f, 0.5f); listOfWalls[10].transform.position = new Vector3(5, 1.5f, 20); listOfWalls[11].GetComponent <CubeMaker>().Size = new Vector3(0.5f, 1.5f, 2.5f); listOfWalls[11].transform.position = new Vector3(5, 1.5f, 22); listOfWalls[12].GetComponent <CubeMaker>().Size = new Vector3(0.5f, 1.5f, 5); listOfWalls[12].transform.position = new Vector3(15, 1.5f, 25); listOfWalls[13].GetComponent <CubeMaker>().Size = new Vector3(5, 1.5f, 1); listOfWalls[13].transform.position = new Vector3(25, 1.5f, 24); listOfWalls[14].GetComponent <CubeMaker>().Size = new Vector3(0.5f, 1.5f, 2.5f); listOfWalls[14].transform.position = new Vector3(25, 1.5f, 22); for (int i = 0; i < 15; i++) { listOfWalls[i].GetComponent <BoxCollider>().size = (listOfWalls[i].GetComponent <CubeMaker>().Size) * 2; } }