![]() You can figure out how to put the URL together through Airtable's auto-generated API documentation for your table by clicking HELP on the top right:īack in your script, you can either hard-code your request string or make a lil method that automatically generates that string from a list of desired properties, which is what I'm doing on line 39 with the "GetColumns()" method: The Airtable API request URL for our table looks something like this: 1?maxRecords=100&fields=Name&fields=Seed Cost&fields=Base Price&fields=Days To Grow&fields=Days To Fruit&fields=Harvest Size So now we just need to write a lil coroutine which performs the HTTP request to receive the data. Here's what that looks like:Īnd here's what that looks like in the inspector once it's been pulled down: Airtable puts a couple of wrappers around the data you want to actually get at, so we need to recreate that same structure in C#. The next step is creating a structure for the Unity JSON utility to de-serialize into. For example, the data could be pulled down automatically from Airtable every time the game is run within the editor. ![]() Those #if UNITY_EDITOR and #endif phrases mean that any code between those two phrases won't be included in the build!Ī lil tip: Sometimes having editor-only behaviours that operate at runtime is kinda neat, because you can have them be triggered by events in game. The way I usually get around this is by making the tool a runtime tool, but using compiler directives to exclude the tool from builds, so that I can make use of editor-only operations without breaking anything or causing compiler errors. Unfortunately it's quite difficult to do a HTTP request within the Unity engine that isn't part of the runtime code, because it requires asynchronous behaviour (sending a request and waiting for a response), which is a bit difficult to do in the editor. So, you usually make the tool part of your engine, rather than part of your game. Often if you're making a tool in Unity, you don't want that code included in your runtime code. Here's how I did that (in case anyone is interested!): Getting things set up! I made a tool to let me import data from our Airtable and update game data in Unity. It's got an easy API to work with that lets you pull/add data from other apps.It's got multiple cell heights so you can put in pictures and actually see them.It's easier to look at than a traditional spreadsheet.The reason why we use Airtable is that it's got 3 things going for it: ![]() We started trying it out about a few months ago and ended up using it for a lot of Ooblets game data.Īn example of our use is the crop data (prices, grow speed, etc.): Everyone seems to be talking about Airtable these days! If you haven't heard, it's basically a spreadsheet thingy like Excel or Google Sheets, but prettier.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |