Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by ohrid87 · Aug 20, 2018 at 05:48 PM · databasegoogle

Reading Google Sheets with Unity

Help!


First of all: I am a complete beginner. And what do I do? I am trying to make a program for my sister so she could use it in her classroom

It's a simple program for students to make orders/see orders/see stock etc.


Came quite far, but I've been stuck for over a week now trying to figure out how to read data from Google Sheets.


What I am trying to do: Google Sheets has a column 'ID' which gets a random ID-number when I click send in Unity.

It works, but I want to display that number as soon as they hit Send.


I figured out how to SEND information to Google Sheets, but I am pulling my hair out trying to READ the information in the sheets.


Here's the code (which I'm certain isn't pretty):


 using System;
 using System.Collections;
 using UnityEngine;
 using UnityEngine.EventSystems;
 using UnityEngine.UI;
 
 public class SendToGoogle : MonoBehaviour
 {
 
     public GameObject naamVerkoper;
     public GameObject naamKlant;
     public GameObject adresKlant;
     public GameObject woonplaatsKlant;
     public GameObject productKeuze;
     public GameObject aantalProduct;
     public GameObject prijsProduct;
     public GameObject datum;
     public GameObject totaalPrijs;
     public GameObject postcodeKlant;
     public GameObject bestelnummer;
     public Text bestelnummerTekst;
    
     private string naamVerkoperS;
     private string naamKlantS;
     private string adresKlantS;
     private string woonplaatsKlantS;
     private string productKeuzeS;
     private string aantalProductS;
     private string prijsProductS;
     private string datumS;
     private string totaalPrijsS;
     private string postcodeKlantS;
     private string bestelnummerUitGoogle;
 
 
     public GameObject button1;
     public GameObject button2;
 
     public InputField mainInputField;
 
     EventSystem system;
 
     [SerializeField]
     private string BASE_URL = "https://docs.google.com/forms/d/e/1FAIpQLSfcO_SocAuZsrAGgi_nIj4451MmN5Q5sL7mpat2WKOaPdOYcw/formResponse";
     private object prettyPrint;
     
     void Start()
     {
         mainInputField.ActivateInputField();
         system = EventSystem.current;
                
     }
 
     public void Update()
     {
 
         if (Input.GetKeyDown(KeyCode.Tab))
         {
             Selectable next = system.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnDown();
 
             if (next != null)
             {
 
                 InputField inputfield = next.GetComponent<InputField>();
                 if (inputfield != null)
                     inputfield.OnPointerClick(new PointerEventData(system));
 
                 system.SetSelectedGameObject(next.gameObject, new BaseEventData(system));
             }
 
 
         }
     }
 
     IEnumerator Post(string naamVerkoper, string naamKlant, string adresKlant, string woonplaatsKlant, string productKeuze, string aantalProduct, string prijsProduct, string datum, string totaalPrijs, string postcodeKlant)
     {
         WWWForm form = new WWWForm();
         form.AddField("entry.499561005", naamVerkoper);
         form.AddField("entry.1868025165", naamKlant);
         form.AddField("entry.1552584854", adresKlant);
         form.AddField("entry.1829297357", woonplaatsKlant);
         form.AddField("entry.1690053122", productKeuze);
         form.AddField("entry.759770034", aantalProduct);
         form.AddField("entry.693687310", prijsProduct);
         form.AddField("entry.2056630187", datum);
         form.AddField("entry.106947741", totaalPrijs);
         form.AddField("entry.1985875803", postcodeKlant);
         byte[] rawData = form.data;
         WWW www = new WWW(BASE_URL, rawData);
         yield return www;
     }
 
     public void Send()
     {
         naamVerkoperS = naamVerkoper.GetComponent<InputField>().text;
         naamKlantS = naamKlant.GetComponent<InputField>().text;
         productKeuzeS = productKeuze.GetComponent<InputField>().text;
         adresKlantS = adresKlant.GetComponent<InputField>().text;
         woonplaatsKlantS = woonplaatsKlant.GetComponent<InputField>().text;
         aantalProductS = aantalProduct.GetComponent<InputField>().text;
         prijsProductS = prijsProduct.GetComponent<InputField>().text;
         datumS = datum.GetComponent<InputField>().text;
         totaalPrijsS = totaalPrijs.GetComponent<InputField>().text;
         postcodeKlantS = postcodeKlant.GetComponent<InputField>().text;
         StartCoroutine(Post(naamVerkoperS, naamKlantS, adresKlantS, woonplaatsKlantS, productKeuzeS, aantalProductS, prijsProductS, datumS, totaalPrijsS, postcodeKlantS));
                
     }
 
 
     public void enableButton()
     {
         bool buttonclicked = true;
         
         if (buttonclicked)
         {
             button1.SetActive(true);
             button2.SetActive(false);
             bestelnummer.SetActive(true);
             bestelnummerTekst.text = "Bestelnummer: " + bestelnummerUitGoogle;  
              
         }
         else
         {
             button1.SetActive(false);
             button2.SetActive(true);
             bestelnummer.SetActive(false);
         }
 
     }
 
  }
 



And the thing waaaay down at the bottom 'bestelnummerUitGoogle' (yes, I'm Dutch) should be the number generated in Google Sheets so it can be displayed in unity (which now only says Bestelnummer:)


Is it clear what the question is? I hope so...

(After that I need to search the database for a specific ID, but first I want this solved)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

154 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Firebase for Unity using service accounts doesn't work 2 Answers

How do I set a query value from firestore to a text field? 0 Answers

Firebase List Users 1 Answer

Google Firebase and Unity (C#): Unable to download png from bucket 0 Answers

Inventory that loads data from an XML 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges