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:
Xevion
2020-06-05 17:59:05 -05:00
parent f6dd8f6c2a
commit d3f213717f
3 changed files with 17 additions and 9 deletions

View File

@@ -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!

View File

@@ -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);
} }
} }

View File

@@ -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
} }