using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UIManager : MonoBehaviour { List points; List lines; List constraints; public GameObject constraintDropdown; public GameObject constraintInput; public Transform pointsParent; public Transform linesParent; public Transform constraintParent; public GameObject button; public GameObject line; public GameObject constraint; string chosen1 = ""; string chosen2 = ""; public CanvasManager3D CM; enum UIState { none, createLine, linelength, lineEqual, lineNormal } UIState state = UIState.none; // Start is called before the first frame update void Start() { points = new List(); lines = new List(); constraints = new List(); } // Update is called once per frame void Update() { switch (state) { case UIState.none: break; case UIState.createLine: if(!chosen1.Equals("") && !chosen2.Equals("")) { createLine(); } break; case UIState.linelength: if (!chosen1.Equals("") && !constraintInput.GetComponent().text.Equals("")) { createConstraint(); } break; case UIState.lineEqual: if (!chosen1.Equals("") && !chosen2.Equals("")) { createConstraint(); } break; case UIState.lineNormal: if (!chosen1.Equals("") && !chosen2.Equals("")) { createConstraint(); } break; } } public void createPoint() { string n = CM.createPoint(); GameObject tmp = Instantiate(button); tmp.transform.SetParent(pointsParent); points.Add(tmp); tmp.transform.localPosition = new Vector3(100 + 70 * (points.Count - 1), 0, 0); tmp.GetComponentInChildren().text = n; tmp.GetComponent