mirror of
https://github.com/Xevion/Boids.git
synced 2025-12-10 08:06:35 -06:00
use LookAtDirect for no lag SceneView updates, draw dotted line between latest detected neighbors, velocity display in inspector GUI, ready arc vertex inspector GUI CustomEditor
This commit is contained in:
@@ -54,7 +54,9 @@ public class BoidControllerEditor : UnityEditor.Editor {
|
||||
EditorGUI.BeginChangeCheck();
|
||||
controller.circleVertexCount =
|
||||
EditorGUILayout.IntSlider("Circle Vertex Count", controller.circleVertexCount, 4, 360);
|
||||
controller.circleWidth = EditorGUILayout.Slider("Circle Line Width", controller.circleWidth, 0.01f, 1f);
|
||||
// controller.arcVertexCount =
|
||||
// EditorGUILayout.IntSlider("Arc Vertex Count", controller.arcVertexCount, -1, 360);
|
||||
controller.circleWidth = EditorGUILayout.Slider("Circle Line Width", controller.circleWidth, 0.01f, 1f);
|
||||
redraw = redraw || EditorGUI.EndChangeCheck();
|
||||
|
||||
// Inspector elements related to Boid Focusing have changed - redraw!
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
// [CustomEditor(typeof(Boid))]
|
||||
// public class BoidEditor : UnityEditor.Editor {
|
||||
// public override void OnInspectorGUI() {
|
||||
// base.OnInspectorGUI();
|
||||
// }
|
||||
// }
|
||||
[CustomEditor(typeof(Boid))]
|
||||
public class BoidEditor : UnityEditor.Editor {
|
||||
public override void OnInspectorGUI() {
|
||||
base.OnInspectorGUI();
|
||||
|
||||
Boid boid = (Boid) target;
|
||||
GUILayout.Label($"Boid heading at ({boid._velocity.x}, {boid._velocity.y})");
|
||||
}
|
||||
}
|
||||
|
||||
public class BoidGizmoDrawer {
|
||||
[DrawGizmo(GizmoType.NonSelected | GizmoType.Selected)]
|
||||
static void DrawGizmo(Boid boid, GizmoType gizmoType) {
|
||||
// Simply draw the # of Boids within the perceived flock
|
||||
Handles.Label(boid.transform.position, $"{boid.transform.name}/{boid.latestNeighborhoodCount}");
|
||||
|
||||
Handles.Label(boid.transform.position, $"{boid.latestNeighborhoodCount}");
|
||||
if(boid._isFocused)
|
||||
foreach(Boid flockmate in boid.latestNeighborhood)
|
||||
Handles.DrawDottedLine(boid.transform.position, flockmate.transform.position, 1f);
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class BoidController : MonoBehaviour {
|
||||
// Focus on the boid in scene view when one is focused
|
||||
#if UNITY_EDITOR
|
||||
if(focusedBoid != null)
|
||||
SceneView.lastActiveSceneView.LookAt(focusedBoid.transform.position, Quaternion.identity);
|
||||
SceneView.lastActiveSceneView.LookAtDirect(focusedBoid.transform.position, Quaternion.identity);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user