public void DrawCircle(OrbView child) { var segments = 360 * 4; LineRenderer line; if (this.gameObject.TryGetComponent <LineRenderer>(out line) == false) { line = this.gameObject.AddComponent <LineRenderer>(); } if (line == null) { return; } line.useWorldSpace = false; line.startWidth = lineWidth; line.endWidth = lineWidth; line.positionCount = segments + 1; line.material = LineMaterial; var pointCount = segments + 1; // add extra point to make startpoint and endpoint the same to close the circle var points = new Vector3[pointCount]; for (int i = 0; i < pointCount; i++) { var rad = Mathf.Deg2Rad * (i * 360f / segments); points[i] = new Vector3(Mathf.Sin(rad) * child.Distance, -Mathf.Cos(rad) * child.Distance, 0); } line.SetPositions(points); }
// Start is called before the first frame update void Start() { cam = Camera.main; camView = cam.GetComponent <SystemCameraView>(); parent = transform.parent.GetComponentInParent <OrbView>(); body = transform.GetChild(0); }