feat: fetch all nodes

This commit is contained in:
LordDemonix 2025-09-16 19:49:18 +02:00
parent 62f2ec81c1
commit 0481d65630

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Dynamic; using System.Dynamic;
using System.Linq;
using Unity.VisualScripting; using Unity.VisualScripting;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@ -17,6 +18,8 @@ public class GameManager : MonoBehaviour
public static GameManager Instance { get; private set; } public static GameManager Instance { get; private set; }
public bool regenerateOnChange = false;
[HideInInspector] public float maxConnectionLength = 6; [HideInInspector] public float maxConnectionLength = 6;
[HideInInspector] public int nodeCount = 100; [HideInInspector] public int nodeCount = 100;
[HideInInspector] public int hoverRadiusCon = 50; [HideInInspector] public int hoverRadiusCon = 50;
@ -163,15 +166,17 @@ public class GameManagerEditor : Editor
GameManager gm = (GameManager)target; GameManager gm = (GameManager)target;
GUILayout.Label("Generation Parameters", EditorStyles.boldLabel); GUILayout.Label("Generation Parameters", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
gm.nodeCount = EditorGUILayout.IntSlider("Node Count", gm.nodeCount, 0, 200); gm.nodeCount = EditorGUILayout.IntSlider("Node Count", gm.nodeCount, 0, 200);
gm.maxConnectionLength = EditorGUILayout.Slider("Max Connection Length", gm.maxConnectionLength, 0, 100); gm.maxConnectionLength = EditorGUILayout.Slider("Max Connection Length", gm.maxConnectionLength, 0, 100);
if (EditorGUI.EndChangeCheck()) if (EditorGUI.EndChangeCheck() && gm.regenerateOnChange)
{ {
gm.GenerateAlongSphere(); gm.GenerateAlongSphere();
gm.GenerateConnections(); gm.GenerateConnections();
SceneView.RepaintAll(); SceneView.RepaintAll();
} }
GUILayout.Space(10); GUILayout.Space(10);
GUILayout.Label("Connection Gizmos", EditorStyles.boldLabel); GUILayout.Label("Connection Gizmos", EditorStyles.boldLabel);
@ -203,7 +208,23 @@ public class GameManagerEditor : Editor
SceneView.RepaintAll(); SceneView.RepaintAll();
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (GUILayout.Button("Fetch all Nodes"))
{
Node[] allNodes = gm.NodeParent.GetComponentsInChildren<Node>();
Debug.Log("Added " + (allNodes.Length - gm.nodeCount) + " new nodes");
gm.nodes = allNodes.ToList();
gm.nodeCount = allNodes.Length;
}
GUILayout.EndHorizontal();
} }
private void OnSceneGUI() private void OnSceneGUI()