public bool LabelIsVisibleToCamera(TrailLabel label, Plane[] planes) { Bounds bounds = label.labelObject.GetComponent <MeshRenderer> ().bounds; Bounds minBounds = new Bounds(); Bounds maxBounds = new Bounds(); minBounds.center = bounds.min - new Vector3(labelEdgeLimit, labelEdgeLimit, labelEdgeLimit); maxBounds.center = bounds.max + new Vector3(labelEdgeLimit, labelEdgeLimit, labelEdgeLimit); if (GeometryUtility.TestPlanesAABB(planes, minBounds) && GeometryUtility.TestPlanesAABB(planes, maxBounds) && NoNearbyBounds(bounds)) { return(true); } return(false); }
IEnumerator FadeInGradually(TrailLabel label) { label.state = LabelState.fadingIn; MeshRenderer labelRenderer = label.labelObject.GetComponent <MeshRenderer> (); labelRenderer.enabled = true; float opacity = 0; Color fadeColor = labelRenderer.material.color; while (opacity < 1) { opacity += Time.deltaTime * 16; fadeColor.a = opacity; labelRenderer.material.color = fadeColor; yield return(null); } label.state = LabelState.visible; }
IEnumerator FadeOutGradually(TrailLabel label) { label.state = LabelState.fadingOut; MeshRenderer labelRenderer = label.labelObject.GetComponent <MeshRenderer> (); labelRenderer.enabled = true; float opacity = 1; Color fadeColor = labelRenderer.material.color; while (opacity > 0) { opacity -= Time.deltaTime * 8; fadeColor.a = opacity; labelRenderer.material.color = fadeColor; yield return(null); } label.state = LabelState.outOfSight; }