如何将公共文本的数据用于公共字符串输入字段? [英] How can I use the data of a public text to a public string inputfield?

查看:101
本文介绍了如何将公共文本的数据用于公共字符串输入字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对数据库中的数据进行了抽奖,我为玩家创建了两个表,为获胜者创建了一个表。 我希望从公共文本中获取数据并使用该数据存储获胜者的信息,使用公共字符串输入字段



任何建议或帮助或不同的方法都会很好!



提前致谢!



< b>我尝试了什么:



I Have a Raffle with Data from a Database, I create two tables one for the players and one for the winners. I want to get the data from the Public Text and use that data to store the info of the winner, using a Public string inputfield.

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

Thanks in advance!

What I have tried:

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 ()
    {
        inputFactura = factura.Text;//this is the 19
    }
    
    // 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 error is:

Quote:

Assets / Scripts / DataInserter.cs(19,32):错误CS1061:类型`UnityEngine.UI.Text'不包含`Text'的定义,也没有扩展方法`Text'可以找到`UnityEngine.UI.Text'类型。您是否缺少程序集引用?

Assets/Scripts/DataInserter.cs(19,32): error CS1061: Type `UnityEngine.UI.Text' does not contain a definition for `Text' and no extension method `Text' of type `UnityEngine.UI.Text' could be found. Are you missing an assembly reference?

推荐答案

我刚刚在Grame_Grant的帮助下解决了!我在输入字段中输入了一个T = txtInput.text



这是最终的脚本:



I just solved with the help of Grame_Grant! I had a T insted of t in the inputfield = txtInput.text

this is the final script:

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 Text ruc;
    public Text nombre;

    public string inputFactura;
    public string inputRuc;
    public string inputNombre;
    // Use this for initialization
    void Start ()
    {
        
    }
	
	// Update is called once per frame
	void Update ()
    {
        inputFactura = factura.text;
        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);
    }
}





Grame_Grant很多,谢谢你!



Grame_Grant many many thanks to you!


这篇关于如何将公共文本的数据用于公共字符串输入字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆