add better redraw checks for EditorGUI, add build macro (CustomEditor needed), remove target frame rate

This commit is contained in:
Xevion
2020-05-27 22:59:24 -05:00
parent 303e846e0f
commit 55dec29413
4 changed files with 16 additions and 13 deletions
+3 -4
View File
@@ -29,9 +29,6 @@ public class Boid : MonoBehaviour {
// Updates the rotation of the object based on the Velocity
transform.eulerAngles = new Vector3(0, 0, Mathf.Rad2Deg * -Mathf.Atan2(_velocity.x, _velocity.y));
if(isFocused)
Draw(true);
// Skip Flock Calculations if wrapping in progress
if (_isWrappingX || _isWrappingY) {
UpdateCenteringVelocity();
@@ -72,10 +69,12 @@ public class Boid : MonoBehaviour {
Wrapping();
}
#if UNITY_EDITOR
private void OnDrawGizmos() {
// Show # of Boids in Neighborhood
Handles.Label(transform.position, $"{_latestNeighborhoodCount}");
}
#endif
public Vector3 DirectionFromAngle(float _angleInDeg, bool _global) {
if (_global == false) {
@@ -293,8 +292,8 @@ public class Boid : MonoBehaviour {
var pointCount = vertexCount + 1;
var points = new Vector3[pointCount + 2];
for (int i = 0; i < pointCount; i++) {
// Magic '180 - angle'
var rad = Mathf.Deg2Rad * (180 - Mathf.LerpAngle(from, to, i / (float) pointCount));
// var rad = Mathf.Deg2Rad * (i * 360f / _parent.circleVertexCount);
points[i + 1] = new Vector3(Mathf.Sin(rad) * radius, Mathf.Cos(rad) * radius, 0);
}
+9 -4
View File
@@ -6,6 +6,7 @@ using UnityEngine;
public class BoidControllerEditor : Editor {
public override void OnInspectorGUI() {
var controller = (BoidController) target;
bool redraw = false;
// Boid Count update
EditorGUI.BeginChangeCheck();
@@ -31,8 +32,7 @@ public class BoidControllerEditor : Editor {
controller.boidGroupRange = EditorGUILayout.Slider("Group Range", controller.boidGroupRange, 0.01f, 7.5f);
controller.boidSeparationRange = EditorGUILayout.Slider("Separation Range", controller.boidSeparationRange, 0.01f, 5.0f);
controller.boidFOV = EditorGUILayout.Slider("Boid FOV", controller.boidFOV, 1f, 360f);
if (EditorGUI.EndChangeCheck())
controller.focusedBoid.Draw(true);
redraw = redraw || EditorGUI.EndChangeCheck();
// Boid Bias Attributes
controller.alignmentBias = EditorGUILayout.Slider("Alignment Bias", controller.alignmentBias, 0.001f, 1.5f);
@@ -41,8 +41,7 @@ public class BoidControllerEditor : Editor {
controller.boundaryBias = EditorGUILayout.Slider("Boundary Bias", controller.boundaryBias, 0.01f, 1.5f);
controller.localFlocks = EditorGUILayout.Toggle("Use Groups?", controller.localFlocks);
controller.edgeWrapping = EditorGUILayout.Toggle("Enforce Wrapping?", controller.edgeWrapping);
controller.edgeWrapping = EditorGUILayout.Toggle("Enable Wrapping?", controller.edgeWrapping);
controller.enableAlignment = EditorGUILayout.Toggle("Enable Alignment?", controller.enableAlignment);
controller.enableCohesion = EditorGUILayout.Toggle("Enable Cohesion?", controller.enableCohesion);
controller.enableSeparation = EditorGUILayout.Toggle("Enable Separation?", controller.enableSeparation);
@@ -50,8 +49,14 @@ public class BoidControllerEditor : Editor {
controller.enableFOVChecks = EditorGUILayout.Toggle("Enable FOV?", controller.enableFOVChecks);
// Boid Rendering
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);
redraw = redraw || EditorGUI.EndChangeCheck();
// Inspector elements related to Boid Focusing have changed - redraw!
if (redraw)
controller.focusedBoid.Draw(true);
}
}
#endif
+1 -1
View File
@@ -76,7 +76,7 @@ public class UIController : MonoBehaviour {
private void Start() {
// Set Target Application Framerate
Application.targetFrameRate = 90;
// Application.targetFrameRate = 90;
// Basic variable setup
_currentUI = UIStance.Title;
@@ -34,7 +34,6 @@ GraphicsSettings:
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}