void OnDrawGizmosInternal() { var newGizmoHash = pickNextWaypointDist.GetHashCode() ^ slowdownDistance.GetHashCode() ^ endReachedDistance.GetHashCode(); if (newGizmoHash != gizmoHash && gizmoHash != 0) { lastChangedTime = Time.realtimeSinceStartup; } gizmoHash = newGizmoHash; float alpha = alwaysDrawGizmos ? 1 : Mathf.SmoothStep(1, 0, (Time.realtimeSinceStartup - lastChangedTime - 5f) / 0.5f) * (UnityEditor.Selection.gameObjects.Length == 1 ? 1 : 0); if (alpha > 0) { // Make sure the scene view is repainted while the gizmos are visible if (!alwaysDrawGizmos) { UnityEditor.SceneView.RepaintAll(); } Draw.Gizmos.Line(position, steeringTarget, GizmoColor * new Color(1, 1, 1, alpha)); Gizmos.matrix = Matrix4x4.TRS(position, transform.rotation * (rotationIn2D ? Quaternion.Euler(-90, 0, 0) : Quaternion.identity), Vector3.one); Draw.Gizmos.CircleXZ(Vector3.zero, pickNextWaypointDist, GizmoColor * new Color(1, 1, 1, alpha)); Draw.Gizmos.CircleXZ(Vector3.zero, slowdownDistance, Color.Lerp(GizmoColor, Color.red, 0.5f) * new Color(1, 1, 1, alpha)); Draw.Gizmos.CircleXZ(Vector3.zero, endReachedDistance, Color.Lerp(GizmoColor, Color.red, 0.8f) * new Color(1, 1, 1, alpha)); } }
private float CalculateBrightness() { // calculate brightness of lights var defaultBright = _detector.DetectedBrightness; // calculate any shade from blinking // TODO: see if is there any way to just measure the distance between top and bottom eyelid to make this more universal var blinkDimming = 1f; if (_autoBlinker?.currentWeight > 0.35) { blinkDimming = Math.SmoothStep(1, 0.25f, _autoBlinker.currentWeight); } else if (_eyesClosedLeftMorph?.morphValue > 0.35) { blinkDimming = Math.SmoothStep(1, 0.25f, _eyesClosedLeftMorph.morphValue); } return(defaultBright * blinkDimming); }