I know that what I have done can be achieved with a loop.
My question is, how can I generate a new textfield every single time I hit the “+” button?
And why does all the textfields update their current position to the variable top? An example is this one (it’s just for a test not the final code):
using UnityEngine;
using System.Collections;
public class Afisare : MonoBehaviour {
string[] maher;
int top = 10, i = 0;
bool ad = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
maher = new string[5];
if(GUI.Button(new Rect(10, 10, 20, 20), "+")){
ad = true;
}
if(ad){
maher *= GUI.TextField(new Rect(10, top, 200, 20), 2 + "", 25);*
-
top += 40;*
-
i++; *
-
}*
- }*
}