private void Update() { if (_isDone) { return; } if (_currentTarget == null || _currentTarget.IsDone) { if (_currentTarget != null) { Destroy(_currentTarget.gameObject); } FindNextTarget(); return; } var planes = GeometryUtility.CalculateFrustumPlanes(Camera.main); var rt = _currentTarget.GetComponent <RectTransform>(); var bounds = GetBoundsForRect(rt); var isVisible = GeometryUtility.TestPlanesAABB(planes, bounds); MainLocator.SetVisible(!isVisible); MainLocator.UpdateStringUnknownCount = string.Format("Current confidence {0}", _lastConfidence); MainLocator.UpdateLocator(_currentTarget.gameObject, -1); }
private void Update() { if (_isDone) { return; } var planes = GeometryUtility.CalculateFrustumPlanes(Camera.main); var headPos = Camera.main.transform.position; var isVisible = false; GameObject toTarget = null; float targetDistance = float.MaxValue; var targetsRemaining = 0; foreach (var target in _targets) { if (target.IsDone) { continue; } targetsRemaining++; var go = target.gameObject; var rt = go.GetComponent <RectTransform>(); var bounds = GetBoundsForRect(rt); var visible = GeometryUtility.TestPlanesAABB(planes, bounds); if (visible) { isVisible = true; break; } var dist = (go.transform.position - MainLocator.transform.position).magnitude; if (dist < targetDistance) { toTarget = go; targetDistance = dist; } } if (targetsRemaining == 0) { _isDone = true; return; } MainLocator.SetVisible(!isVisible); MainLocator.UpdateLocator(toTarget, targetsRemaining); }