mirror of
https://github.com/Xevion/Rebirth.git
synced 2025-12-11 06:08:22 -06:00
Rename to Rebirth, move Editor scripts to Assets/Editor
This commit is contained in:
55
Assets/Editor/PlanetEditor.cs
Normal file
55
Assets/Editor/PlanetEditor.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
[CustomEditor(typeof(Planet))]
|
||||
public class PlanetEditor : Editor
|
||||
{
|
||||
Planet planet;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
planet = target as Planet;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
|
||||
if (GUILayout.Button("Delete Planet"))
|
||||
{
|
||||
DestroyImmediate(planet.gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
var changed = false;
|
||||
|
||||
// Check if size changed
|
||||
var newSize = EditorGUILayout.Slider("Size", planet.Size, 1f, 300f);
|
||||
if (newSize != planet.Size)
|
||||
{
|
||||
planet.Size = newSize;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// Check if bulbs changed
|
||||
var newBulbs = EditorGUILayout.IntSlider("Bulbs", planet.Bulbs, 0, 5);
|
||||
if (newBulbs != planet.Bulbs)
|
||||
{
|
||||
planet.Bulbs = newBulbs;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// Check if edge width changed
|
||||
var newEdgeWidth = EditorGUILayout.Slider("Edge Width", planet.edgeWidth, 0.001f, 0.2f);
|
||||
if (newEdgeWidth != planet.edgeWidth)
|
||||
{
|
||||
planet.edgeWidth = newEdgeWidth;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed) planet.Render();
|
||||
|
||||
DrawDefaultInspector();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user