-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38d2eea
commit 2b0ce4f
Showing
25 changed files
with
2,270 additions
and
85 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
...Procedural Generation/Scripts/Editor.meta → .../Planet Procedural Generation/Editor.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
Assets/PCG/Planet Procedural Generation/Editor/PlanetEditor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
[CustomEditor(typeof(Planet))] | ||
public class PlanetEditor : Editor { | ||
|
||
Planet planet; | ||
Editor shapeEditor; | ||
Editor colourEditor; | ||
|
||
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.colourSettingsFoldout, ref colourEditor); | ||
} | ||
|
||
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(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void OnEnable() | ||
{ | ||
planet = (Planet)target; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ation/Scripts/Editor/PlanetEditor.cs.meta → ...al Generation/Editor/PlanetEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.