Unity-Google Sheets integration This repo created a seamless Unity-Google Sheets integration using a simple API for a Google Spreadsheet using Google Apps Script, allowing for basic CRUD (Create, Read, Update, Delete) operations through a web interface. This guide provides a step-by-step process to integrate Unity with Google Sheets, allowing Unity developers to send playtest data directly to a Google Sheet using Google Apps Script. This can be particularly useful for collecting playtester feedback, environment data, and more. Key Concepts Parameter Handling: The script uses the e.parameter object to access GET request parameters. Sheet Access: Dynamically selects sheets based on request parameters, with a fallback to the 'Master' sheet. Data Manipulation: Demonstrates adding and retrieving data, showcasing how to handle variable data fields. Error Handling: Basic error handling by returning specific messages for invalid actions or when data cannot be found. How to Creating the Custom Function in Google Sheets Open Your Google Sheet: In the Google Sheet where you're working, go to Extensions > Apps Script. Set up the columns for data you wish to collect (e.g., Email, Playtest Key, Status, NickName). Note the URL of your Google Sheet, you'll need it for your Unity script. Import Script: Import the PlaytestData.gs script. Modify the script as needed to fit your specific data collection requirements. Save the AppsScript. Deploy: In the Google Apps Script editor, click on Deploy > New deployment. Select Web app as the deployment type. Fill in the details, set Who has access to Anyone, and click Deploy. Copy the web app URL provided after deployment. Importing into Unity Dependency: Import Odin Serializer from github or Odin Inspector asset. (You can alternately populate your playtest Dictionary manually.) Import the two scripts in this repo into your unity project. Replace the placeholder URL in SHEETS_APP_URL with the URL of your Google Apps Script web app from the previous section. Attach the script to a GameObject in your Unity scene to start using it. Test it! Run your Unity project and perform actions that trigger the script to send data to Google Sheets. Check your Google Sheet to see if the data appears as expected. Protips Customize the Unity and Google Apps Script code as necessary to fit your project's specific needs. Ensure you follow Google's guidelines and limitations for Apps Script and web app deployments. Always follow applicable laws related to data collection from users, including playtesters. (责任编辑:) |