2 using System.Collections;
4 using UnityEngine.EventSystems;
9 public Image textBackground;
11 public InputField myInputField;
12 public BoxCollider myBoxCollider;
14 private float padding = 0.0f;
17 public void setLabelText(
string newLabel) {
18 myText.text = newLabel;
19 myInputField.text = newLabel;
23 public String getLabelText() {
28 public void annotationLabelClicked() {
29 myInputField.gameObject.SetActive (
true);
30 myInputField.ActivateInputField ();
31 myInputField.Select ();
32 myInputField.MoveTextEnd (
true);
33 textBackground.color =
new Color (textBackground.color.r, textBackground.color.b, textBackground.color.b, 0.0f);
34 myText.color =
new Color (myText.color.r, myText.color.b, myText.color.b, 0.0f);
38 public void ValueChanged () {
39 myText.text = myInputField.text;
44 public void EditingFinished () {
45 this.GetComponentInParent<
Annotation> ().saveLabelChanges ();
46 myInputField.gameObject.SetActive (
false);
47 textBackground.color =
new Color (textBackground.color.r, textBackground.color.b, textBackground.color.b, 1.0f);
48 myText.color =
new Color (myText.color.r, myText.color.b, myText.color.b, 1.0f);
51 private void resizeLabel() {
53 padding = textBackground.gameObject.GetComponent<VerticalLayoutGroup> ().padding.top
54 + textBackground.gameObject.GetComponent<VerticalLayoutGroup> ().padding.bottom;
58 Canvas.ForceUpdateCanvases();
59 float newHeight = myText.preferredHeight + padding;
60 Vector2 resize =
new Vector2 (this.gameObject.GetComponent<RectTransform> ().rect.width, newHeight);
62 this.gameObject.GetComponent<RectTransform>().sizeDelta = resize;
63 myBoxCollider.size =
new Vector3(myBoxCollider.size.x, newHeight, myBoxCollider.size.z);
64 myInputField.gameObject.GetComponent<RectTransform> ().sizeDelta = resize;