How to set a text to a inputfield in the editor?

102631-unity1.png

how can I take the text from above and display that data in the input Factura?

Here is the Script of the Data Inserter:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DataInserter : MonoBehaviour
{

string CreateGanadoresURL = "http://localhost/trivia/ganadores.php";

public Text factura;

public string inputFactura;
public string inputRuc;
public string inputNombre;
// Use this for initialization
void Start () {
	
}

// Update is called once per frame
void Update ()
{
    if (Input.GetKeyDown(KeyCode.Space)) CreateGanadores(inputFactura, inputRuc, inputNombre);
}

public void CreateGanadores(string factura, string ruc, string nombre)
{
    WWWForm form = new WWWForm();
    form.AddField("facturaPost", factura);
    form.AddField("rucPost", ruc);
    form.AddField("nombrePost", nombre);

    WWW www = new WWW(CreateGanadoresURL, form);
}
}

and the Textfactura is from another Script, named Data Loader:

using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using System.IO;

public class DataLoader : MonoBehaviour
{
public Text id;
public string ID = "id:";

public Text factura;
public string NFA = "factura:";

public Text ruc;
public string NRU = "ruc:";

public Text nombre;
public string NOM = "nombre:";

public string[] items;

void Update()
{
    if (Input.GetKeyDown(KeyCode.B))
        StartCoroutine("Start");
}

IEnumerator Start()
{
    WWW coneccion = new WWW("http://localhost/trivia/getdatos.php");
    yield return (coneccion);
    if (Input.GetKey(KeyCode.B))
    {
        WWW getdatos = new WWW("http://localhost/trivia/getdatos.php");
        yield return getdatos;

        string getdatosString = getdatos.text;

        print(getdatosString);
        items = getdatosString.Split('@');
        print(GetDataValue(items[0], "id:"));
        id.text = "id: " + GetDataValue(items[0], "id:");

        print(getdatosString);
        items = getdatosString.Split('~');
        print(GetDataValue(items[0], "factura:"));
        factura.text = "factura: " + GetDataValue(items[0], "factura:");

        print(getdatosString);
        items = getdatosString.Split('`');
        print(GetDataValue(items[0], "ruc:"));
        ruc.text = "ruc: " + GetDataValue(items[0], "ruc:");

        print(getdatosString);
        items = getdatosString.Split('!');
        print(GetDataValue(items[0], "nombre:"));
        nombre.text = "nombre: " + GetDataValue(items[0], "nombre:");
    }

}

string GetDataValue(string data, string index)
{
    string value = data.Substring(data.IndexOf(index) +index.Length);
    if(value.Contains("~"))value = value.Remove(value.IndexOf("~"));
    return value;

} 

}

Any suggestion or help or a different approach would be nice!

Thanks in advance!

I think what you want is this line…

inputFactura = factura.text;

…but I don’t know where you want it because you didn’t say when you wanted the value copied.

If you want to see it in the editor, you might need to add the ExecuteInEditMode attribute to your MonoBehaviour.