Rename to Rebirth, move Editor scripts to Assets/Editor

This commit is contained in:
2024-12-16 02:42:15 -06:00
parent 36a66d945a
commit fbdf355ce4
8 changed files with 40 additions and 32 deletions

View File

@@ -0,0 +1,42 @@
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
[CustomEditor(typeof(Network))]
public class NetworkEditor : Editor
{
Network network;
void OnEnable()
{
network = target as Network;
}
// public override VisualElement CreateInspectorGUI()
// {
// VisualElement root = new();
// addPlanetButton = new Button(() => { network.AddPlanet(); }) { text = "Add Planet" };
// // var planetList = new TreeView() { style = { flexGrow = 1 } };
// // planetList.Bind()
// // planetList.makeItem = () => new Label();
// // planetList.bindItem = (element, i) => (element as Label).text = planetList.itemsSource[i].ToString();
// // root.Add(planetList);
// root.Add(addPlanetButton);
// return root;
public override void OnInspectorGUI()
{
if (GUILayout.Button("Add Planet"))
{
network.AddPlanet();
}
DrawDefaultInspector();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9d6453473dbe3314f8e47fd55431bbdb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dac449cc3e1349f47afb01b28c87254e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: