Skip to content
Gallery
Coda Sync for Unity
Share
Explore
Documentation

icon picker
The Table Importer

The Table Importer is the ScriptableObject that will handle table import.
image.png
You can create as many Table Importers as you need. Each Table Importer will sync the data from one Coda doc.

image.png

The Importer have 4 fields :
Requester : the requester you want to use for this import (see ).
Document URL : the url to the document you want to import tables from (simply copy and paste the URL it from your browser 😃)
Code Namespace : the namespace in which code will be generated. This is useful to avoid class name confusion between existing classes in your project
Log Responses : for debug purposes, it will display every responses from the API in the console

error
It might be obvious but you should be careful when naming your tables and columns, or choosing the namespace. For example using a column ‘name’ will generate a warning in Unity because it will hide inherited member 'Object.name'.
Another important notice is the use of dash (-) in the display column (which is the identifier of a table entry): this is not currently permitted. Please use an underscore instead (_)
And, entries that have an empty string in the display column will fail when syncing, because the name of the generated scriptable object file uses the info in this column and we can not generate a file with no name.

If the document URL is correct, you should see the Document Id field displaying.
If every thing is correct, you should see a list of every tables and views available in your document.
Now you can select which tables you want to import and click Import !
Et voilà !
image.png
time
Sometimes it may take a few seconds if you made a change on the Coda Doc before being available for the API. If you can’t see your changes on the generated Scriptable Objects, wait for a few seconds and retry.
⚠️ If a table has a lookup to another table - e.g. in our example datasets, characters have a weapon - and you do not import the related table, you will get an error because the generated Scriptable Object will have a reference to a class that has not been generated - in this example Weapons not being imported will cause the Characters to fail.
🤞in a future update we will prevent importing tables that have a dependency to another table.
setup.png
light
you can check the page to see how you can use table views to select only some columns of a table to sync.

Imported assets

Capture d’écran 2022-08-25 à 15.43.11.png
When tables are imported each table is treated as a Scriptable Object class and every row as an instance of this class thus created as Scriptable Objects in the project hierarchy.
The assets are imported in the folder containing the table importer object (here named Demo_TableImporter). You get 2 folders:
Ressources: contains all the generated Scriptable Objects separated in a folder per class (i.e. table)
Scripts: contains the Scriptable Object class and a Database class for each synchronized table
A Database Scriptable Object is also created in the ressources folder for each table, with a list of each instance. See to learn how to use it and access the data in your C# scripts.

🙋 Scriptable Objects are updated if they already exist, they are only created when they have been added to the table. Therefore, you can safely reference it in your other classes.
For safety, we do not delete Scriptable Objects when the corresponding entry has been deleted from the table. So you delete these files manually.

Update and save your data

error
Every time you update (sync) your data, you must save your Unity project (File>Save Project) so your Scriptable Objects are saved on disc.
🐛 There is also a Unity bug that prevents you from seeing the changes you have done with the update (as of version 2021.3.8). To see the changes in the inspector and force Unity to update, you have to fold and unfold again the folder containing the assets 😅
Fix.gif
The issue however does not happen if a scriptable object has been created during the update.

Field types

Imported objects property types depend on the tables column type you have setup in Coda.
Here is a list of supported types :
Table column type
Unity Type
1
Text
string
2
Number
float
3
Checkbox
bool
4
Select List
string
5
Lookup
Will reference element(s) of the looked up table; if the looked up table is not synced, it will be empty
6
Canvas
string (as a TextArea)
There are no rows in this table
megaphone
In a select or lookup column type, if multiple selection is activated (yes, you can have either a single or multiple selection for these kind of columns 👍), it will be created as an Array in Unity.

👉 Next:


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.