Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEditor;
- using UnityEngine;
- [CustomEditor(typeof(Planet))]
- public class PlanetEditor : Editor
- {
- Planet planet;
- public override void OnInspectorGUI()
- {
- if (DrawDefaultInspector())
- {
- if (planet.autoUpdate)
- {
- planet.BuildPlanet();
- }
- }
- if (GUILayout.Button("Build"))
- {
- planet.BuildPlanet();
- }
- DrawSettingsEditor(planet.shapeSettings, planet.OnShapeSettingsUpdate);
- DrawSettingsEditor(planet.colorSettings, planet.OnColorSettingsUpdate);
- }
- public void DrawSettingsEditor(Object settings, System.Action onSettingsUpdate)
- {
- Editor editor = CreateEditor(settings);
- editor.OnInspectorGUI();
- using (var check = new EditorGUI.ChangeCheckScope())
- {
- if (check.changed)
- {
- onSettingsUpdate();
- }
- }
- }
- public void OnEnable()
- {
- planet = (Planet) target;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement