private void Start() { peso = setupArrow("Peso", FORCES_SCALE_FACTOR); arrastre = setupArrow("Arrastre", FORCES_SCALE_FACTOR); empuje = setupArrow("Empuje", FORCES_SCALE_FACTOR); velocidad = setupArrow("V", VELOCITY_SCALE_FACTOR); }
ArrowScaler setupArrow(string name, float scaleFactor) { ArrowScaler a = transform.Find(name).gameObject.GetComponent <ArrowScaler>(); a.setScaleFactor(scaleFactor); return(a); }
// Creates an arrow specifying the euler angles. public void addArrow(float roll, float pitch, float yaw, float length, string text) { GameObject new_arrow = Instantiate(arrow, new Vector3(0, 0, 0), Quaternion.identity); new_arrow.name = "new_arrow " + (count++); new_arrow.transform.localEulerAngles = new Vector3(roll, pitch, yaw); new_arrow.transform.SetParent(this.transform, false); ArrowScaler new_arrow_scaler = new_arrow.GetComponent <ArrowScaler>(); // Set the length. The arrow will be resized when "Start" is called. new_arrow_scaler.length = length; new_arrow_scaler.text = text; // TODO: this should not be necessary. Check new_arrow.SetActive(true); }