In this part when I’m changing the xradius slider it’s also changing the yradius slider at the same time and same value. But I can’t change the yradius when trying to change it’s slider. I want to be able either change the xradius or yradius when the flag is true. Both will change to the same values but I want to be able to change also the yradius so it will change the xradius.
if (changeBothRadius) { yradius = xradius; xradius = yradius; }
I tried to add the xradius = yradius;
but it’s not working only when changing the xraiuds it’s working.
using UnityEngine; using System.Collections; using System.Collections.Generic; [RequireComponent(typeof(LineRenderer))] public class DrawCircle : MonoBehaviour { [Range(0, 50)] public int segments = 50; [Range(1, 50)] public float xradius = 5; [Range(1, 50)] public float yradius = 5; public bool changeBothRadius = false; [Range(0.1f, 2)] public float lineThickness = 0.1f; public bool minimumRadius = false; private LineRenderer line; private List<float> radiusList = new List<float>(); void Start() { line = gameObject.GetComponent<LineRenderer>(); line.positionCount = segments + 1; line.useWorldSpace = false; CreatePoints(); } void Update() { line.startWidth = lineThickness; line.endWidth = lineThickness; CreatePoints(); } void CreatePoints() { if (changeBothRadius) { yradius = xradius; xradius = yradius; } float x; float z; float angle = 20; for (int i = 0; i < (segments + 1); i++) { x = Mathf.Sin(Mathf.Deg2Rad * angle) * xradius; z = Mathf.Cos(Mathf.Deg2Rad * angle) * yradius; line.SetPosition(i, new Vector3(x, 0, z)); angle += (360f / segments + 1); } } }