Search Unity

Matching 3D / VR keyboard input to Google Spreadsheet Send Request

Discussion in 'AR/VR (XR) Discussion' started by A_Piask, Mar 30, 2019.

  1. A_Piask

    A_Piask

    Joined:
    Mar 22, 2019
    Posts:
    3
    Hi all,

    I am a true beginner when it comes to coding in c#. I am struggling to connect a numerical simple keyboard with a text field which is a part of send request. My issue is, that the keyboard script can alter a "placeholder" component of the "button" component, but does NOT alter the "text" component, which ultimately is the one that is being sent to the google form. It works for the placeholder, it doesn't work for the text.

    Any ideas? (images and scripts below).

    Thanks in advance ^^
    Adam

    1.PNG

    This is the simple keyboard script I found on YT:

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

    public class keyboard : MonoBehaviour
    {
    string word = null;
    int wordIndex = 0;
    string alpha;
    public Text myName = null;

    private void AlphabetFunction(string alphabet)
    {
    wordIndex++;
    word = word + alphabet;
    myName.text = word;
    }
    }


    This is Google send request script, also found on YT:

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

    public class SendToGoogle : MonoBehaviour
    {
    public GameObject ans;
    public GameObject age;

    private string ANS;
    private string AGE;

    [SerializeField]
    private string BASE_URL = "https://docs.google.com/forms/d/e/1...Zcen9THIO1mXKbM25Y_9v5oRcSP3TDVQ/formResponse";

    IEnumerator Post(string ans, string age)
    {
    WWWForm form = new WWWForm();
    form.AddField("entry.2157157", ans);
    form.AddField("entry.11423072", age);
    byte[] rawData = form.data;
    WWW www = new WWW(BASE_URL, rawData);
    yield return www;


    }



    public void Send()
    {
    ANS = ans.GetComponent<InputField>().text;
    AGE = age.GetComponent<InputField>().text;

    StartCoroutine(Post(ANS, AGE));


    }

    }
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    The script, as written, modifies a Text. Not an InputField. So delete your InputField and put a Text in its place.

    (Or, modify the script so that it refers to an InputField rather than a Text.)
     
    A_Piask likes this.
  3. A_Piask

    A_Piask

    Joined:
    Mar 22, 2019
    Posts:
    3
    Hi Joe,

    Could you help me with modifying the script so that it takes an Input Field rather than Text?

    Is it this line? myName.text = word; to myName.InputField = word ?

    Thanks,

    Adam
     
  4. A_Piask

    A_Piask

    Joined:
    Mar 22, 2019
    Posts:
    3
    Never mind! I figured it! Thank you so much for your help Joe!!
     
    JoeStrout likes this.