mirror of
https://github.com/Xevion/Boids.git
synced 2025-12-13 14:11:00 -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();
|
EditorGUI.BeginChangeCheck();
|
||||||
controller.circleVertexCount =
|
controller.circleVertexCount =
|
||||||
EditorGUILayout.IntSlider("Circle Vertex Count", controller.circleVertexCount, 4, 360);
|
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();
|
redraw = redraw || EditorGUI.EndChangeCheck();
|
||||||
|
|
||||||
// Inspector elements related to Boid Focusing have changed - redraw!
|
// Inspector elements related to Boid Focusing have changed - redraw!
|
||||||
|
|||||||
@@ -1,18 +1,24 @@
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
// [CustomEditor(typeof(Boid))]
|
[CustomEditor(typeof(Boid))]
|
||||||
// public class BoidEditor : UnityEditor.Editor {
|
public class BoidEditor : UnityEditor.Editor {
|
||||||
// public override void OnInspectorGUI() {
|
public override void OnInspectorGUI() {
|
||||||
// base.OnInspectorGUI();
|
base.OnInspectorGUI();
|
||||||
// }
|
|
||||||
// }
|
Boid boid = (Boid) target;
|
||||||
|
GUILayout.Label($"Boid heading at ({boid._velocity.x}, {boid._velocity.y})");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class BoidGizmoDrawer {
|
public class BoidGizmoDrawer {
|
||||||
[DrawGizmo(GizmoType.NonSelected | GizmoType.Selected)]
|
[DrawGizmo(GizmoType.NonSelected | GizmoType.Selected)]
|
||||||
static void DrawGizmo(Boid boid, GizmoType gizmoType) {
|
static void DrawGizmo(Boid boid, GizmoType gizmoType) {
|
||||||
// Simply draw the # of Boids within the perceived flock
|
// 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
|
// Focus on the boid in scene view when one is focused
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if(focusedBoid != null)
|
if(focusedBoid != null)
|
||||||
SceneView.lastActiveSceneView.LookAt(focusedBoid.transform.position, Quaternion.identity);
|
SceneView.lastActiveSceneView.LookAtDirect(focusedBoid.transform.position, Quaternion.identity);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user