feat: fetch all nodes
This commit is contained in:
parent
62f2ec81c1
commit
0481d65630
1 changed files with 23 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
|
@ -17,6 +18,8 @@ public class GameManager : MonoBehaviour
|
|||
|
||||
public static GameManager Instance { get; private set; }
|
||||
|
||||
public bool regenerateOnChange = false;
|
||||
|
||||
[HideInInspector] public float maxConnectionLength = 6;
|
||||
[HideInInspector] public int nodeCount = 100;
|
||||
[HideInInspector] public int hoverRadiusCon = 50;
|
||||
|
|
@ -163,16 +166,18 @@ public class GameManagerEditor : Editor
|
|||
GameManager gm = (GameManager)target;
|
||||
|
||||
GUILayout.Label("Generation Parameters", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
gm.nodeCount = EditorGUILayout.IntSlider("Node Count", gm.nodeCount, 0, 200);
|
||||
gm.maxConnectionLength = EditorGUILayout.Slider("Max Connection Length", gm.maxConnectionLength, 0, 100);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
if (EditorGUI.EndChangeCheck() && gm.regenerateOnChange)
|
||||
{
|
||||
gm.GenerateAlongSphere();
|
||||
gm.GenerateConnections();
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
|
||||
|
||||
GUILayout.Space(10);
|
||||
GUILayout.Label("Connection Gizmos", EditorStyles.boldLabel);
|
||||
|
||||
|
|
@ -204,6 +209,22 @@ public class GameManagerEditor : Editor
|
|||
}
|
||||
|
||||
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()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue