Unity-Free-Online-Config

A simple unity online config based on google spreadsheets.

MIT License

Stars
3
Committers
1

Vintall's Unity Free Online Config

VUFOC is a simple external config's loader, for places, where you need to change a few variables but can't / don't want to make another build. You can download you config in one press of a button from inspector or download on startup. Create as many configs as you like

Features

  • Minimalistic and Quick
  • No need to host or buy a server
  • Unlimited configs

How to install

Install via GIT URL

  • Copy link to package https://github.com/Vintall/Unity-Free-Online-Config.git#master
  • In unity go to Window -> Package Manager
  • In the top left corner click + -> Add package from git URL...
  • Paste the link to your spreadsheet in field and click Add.

Install via Unity Package

Quick start

Create and publish Google spreadsheet

  • Go to File -> Share -> Publish to web
  • In "Publish to the web" pop-up in the left column choose a specific sheet that you want to use as your database. Later on you can make as many as you want.
  • In the right column pick Tab-separated values (.tsv)
  • In "Published content & settings" you have several fields.
    • First of all, choose entire document in first field.
    • You most likely want to have enabled "Automatically republish when changes are made". Otherwise you will need to republish it manually every time.
    • Press Start publishing to generate link to your sheet.
  • Copy the link to your sheet.

Connect to spreadsheet in Unity

  • Go to VUFOC -> Create New Config
  • In the following window you have two required fields
    • Config Name, which is used in class names. Be sure to fill it according to C# class naming restrictions
    • List of fields, which is used for VO creation.

*Optionally, you can embed both name and url info file field. If you choose otherwise, you will need to fill it manually in ScriptableObject inspector.

  • Create two scripts: ExampleDatabase.cs and ExampleVo.cs
  • ExampleVo extend class ASpreadsheetVo. This is one line of data from your database.
[Serializable]
public class ExampleVo : ASpreadsheetVo
{
    public string ExampleString;
    public int ExampleInt;
    public float ExampleFloat;
    public double ExampleDouble;
}
  • ExampleDatabase is a class, that holds database name, url and list of ExampleVo's. Every database have a ScriptableObject, as base class. So, for every database we need to specity attribute [CreateAssetMenu]. You can read more about ScriptableObjects in official unity documentation https://docs.unity3d.com/Manual/class-ScriptableObject.html.
[CreateAssetMenu(fileName = "ExampleDatabase", menuName = "Databases/ExampleDatabase")]
public class ExampleDatabase : ASpreadsheetConfig<ExampleVo>
{
    [SerializeField] private string databaseName;
    [SerializeField] private string databaseDataUrl;
    
    public override string DatabaseName => databaseName;
    public override string DatabaseDataUrl => databaseDataUrl;
    protected override ASpreadsheetVo TemplateVo => new ExampleVo();
}
  • In editor right click onto project window -> Create -> Configs -> ExampleConfig. That will create a ScriptableObject of your config
  • Go to your spreadsheet and fill up some data. Columns shoud be corresponding in format an order. In our case ExampleVo has the folowing fields: "string", "int", "float", "double". So, the column will be read as "A":"string", "B":"int", "C":"float", "D":"double".
  • Go back to editor. And place config name (optional) and url. Then click Download
  • Data from spreadsheet should appear in SpreadsheetEntries list.