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
- Minimalistic and Quick
- No need to host or buy a server
- Unlimited configs
- 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.
- Download the latest release https://github.com/Vintall/Unity-Free-Online-Config/releases
- Double-click on .unitypackage or drag it onto editor
- Choose files to import. You will import all files by default
- Go to https://docs.google.com/spreadsheets. Make sure you're logged into your account
- Create a blank 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.
Automatic Config Creation
- 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.
Manual Config Creation
- 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.