Data and Events framework for Unity. π₯β‘
Whiskey is a framework for managing data and events within Unity. It leans heavily on ScriptableObject, and is inspired by Ryan Hipple's Unite 2017 Talk. Whiskey lets game designers own and edit data definitions while programmers continue to evolve code - Whiskey brings the two together with references, to reduce merge conflicts.
Goals:
- Create, Edit, and Visualize data within the Editor, not code.
- Encourage decoupling, by using asset references rather than singletons.
- Quickly swap between data constants and references without rewriting code.
Features:
- Boxed data, stored as assets on disk using ScriptableObject.
- Weighted loot tables, for easy to manage probability based loot drops.
- Events, stored as assets on disk using ScriptableObject.
- Event Listeners, for binding to Events using MonoBehaviours.
- References, for consuming data in code indirectly.
This package supports openupm - you can install it using the following command:
openupm add com.faster-games.whiskey
Or by adding directly to your manifest.json
:
Note: You may also use specific versions by appending
#{version}
where version is a Release tag - e.g.#v1.2.0
.
dependencies: {
...
"com.faster-games.whiskey": "git+https://github.com/faster-games/whiskey.git"
}
Or by using Package Manager to "Add a package from Git URL", using the following url:
https://github.com/faster-games/whiskey.git
Manual π | Scripting API π
Disclaimer: By nature, Whiskey isn't easy to demonstrate. As such, this may not be as "quick" as you'd expect! π
- Right click in the Project Window select:
Create, Whiskey, Boxes, Int
- Name the created data instance
- Select the data instance
- Edit the data in the Inspector Window
- Right click in the Project Window select:
Create, C# Script
- Name the created script
IntTestBehaviour
- Edit the script, adding the following:
using FasterGames.Whiskey.Boxes;
using UnityEngine;
public class IntTestBehaviour : MonoBehaviour
{
public Ref<int> intRef;
private void Start()
{
Debug.Log(intRef.Value);
}
}
- Right click in the Hierarchy Window select:
Create Empty
- Name the created object
- Select the object in the Hierarchy Window, then in the Inspector Window select
Add Component
and search forIntTestBehaviour
, selecting the first result (which should be the script you created above) - Note the
Int Ref
field is displayed, by default it is aDirect
reference. A direct reference is effectively a hard coded value. - Select the
Direct
dropdown, and change it toBoxed
. Note the field changes, allowing you to drag and drop an object reference, and showing an additional dropdown field. - Ensure the additional dropdown field is set to
BoxedInt
, which will allow the editor to more accurately assist you in selecting the object. - Click the object reference field, and select the data instance you created above.
- You have now made your first data reference using Whiskey. Run the code, and note that the value stored in your data instance is logged by the
IntTestBehaviour
script onStart
.
πππ Thanks for bearing with us! There's a lot of features in Whiskey, this quickstart only demonstrates one. To learn more, see The manual.
If this project saved you some time, and you'd like to see it continue to be invested in, consider buying me a coffee. β I do this full-time, and every little bit helps! π