public override void OnInspectorGUI() { ProceduralCubeBody body = (ProceduralCubeBody)target; if (DrawDefaultInspector()) { if (body.parentBody.biome.terrainGenData.autoUpdate) { body.Prepare(); body.Generate(); body.Finish(); } } if (GUILayout.Button("Generate")) { body.Prepare(); body.Generate(); body.Finish(); } }
public void Generate() { Random.seed = seed; for (int i = 0; i < maxAsteroids; i++) { Vector3 randomPos = Random.insideUnitSphere * maxRadius; if (randomPos.magnitude > exclusionRadius) { GameObject asteroid = Instantiate(asteroidPrefab); asteroid.transform.parent = transform; asteroid.transform.position = randomPos; asteroid.transform.rotation = Random.rotation; CelestialBody asteroidBody = asteroid.GetComponent <CelestialBody>(); ProceduralCubeBody proceduralBody = asteroidBody.GetComponent <ProceduralCubeBody>(); proceduralBody.Prepare(); proceduralBody.Generate(); proceduralBody.Finish(); } } }