Planet Maker Tool
3D Tool made with Unity Engine

In this project I use code to make a producual generated planet.with many options in the inventory that can help me change few aspect of the planet I desire like size , shape of the continents on the planet , color gradiants for each hight level of the planet, etc.
Screenshots of the project
Why this project was made and what's the final goal









A Little Demo of the project
SCRIPTS
EDITOR SCRIPTS
Editor Scripting can help you customize and extend the Unity editor to make it easier to use on your projects. In this project I did just that by creating new C# script that extend from UnityEditor Library and that can change the inspector view inside the editor.
Planet Editor script
Change Inspector with OnInspectorGUI
public override void OnInspectorGUI()
{
using (var check = new EditorGUI.ChangeCheckScope())
{
base.OnInspectorGUI();
if (check.changed)
{
planet.GeneratePlanet();
}
}
if (GUILayout.Button("Generate Planet"))
{
planet.GeneratePlanet();
}
DrawSettingsEditor(planet.shapeSettings , planet.OnShapeSettingsUpdated ,
ref planet.shapeSettingsFoldout , ref shapeEditor);
DrawSettingsEditor(planet.colourSettings , planet.OnColourSettingsUpdated ,
ref planet.colorSettingsFoldout, ref colourEditor);
}
DRAWING SETTING EDITOR UNDER PLANET INPECTOR
void DrawSettingsEditor(Object settings , System.Action onSettingsUpdated , ref bool foldout ,
ref Editor editor)
{
if (settings != null)
{
foldout = EditorGUILayout.InspectorTitlebar(foldout, settings);
using (var check = new EditorGUI.ChangeCheckScope())
{
if (foldout)
{
CreateCachedEditor(settings, null, ref editor);
editor.OnInspectorGUI();
if (check.changed)
{
if (onSettingsUpdated != null)
{
onSettingsUpdated();
}
}
}
}
}
}
Mesh Editor script
Class Creation
[CustomEditor (typeof (TerrainGenerator))]
public class MeshEditor : Editor {
TerrainGenerator terrainGenerator;
OnInspectorGUI
public override void OnInspectorGUI () {
DrawDefaultInspector ();
//Create Button that regenerate the meshes
if (GUILayout.Button ("Generate Mesh")) {
terrainGenerator.GenerateHeightMap ();
terrainGenerator.ContructMesh();
}
string numIterationsString = terrainGenerator.numErosionIterations.ToString();
if (terrainGenerator.numErosionIterations >= 1000) {
numIterationsString = (terrainGenerator.numErosionIterations/1000) + "k";
}
if (GUILayout.Button ("Erode (" + numIterationsString + " iterations)")) {
var sw = new System.Diagnostics.Stopwatch ();
sw.Start();
terrainGenerator.GenerateHeightMap();
int heightMapTimer = (int)sw.ElapsedMilliseconds;
sw.Reset();
sw.Start();
terrainGenerator.Erode ();
int erosionTimer = (int)sw.ElapsedMilliseconds;
sw.Reset();
sw.Start();
terrainGenerator.ContructMesh();
int meshTimer = (int)sw.ElapsedMilliseconds;
if (terrainGenerator.printTimers) {
Debug.Log($"{terrainGenerator.mapSize}x{terrainGenerator.mapSize} heightmap generated in {heightMapTimer}ms");
Debug.Log ($"{numIterationsString} erosion iterations completed in {erosionTimer}ms");
Debug.Log ($"Mesh constructed in {meshTimer}ms");
}
}
}