Collection of attributes for allowing randomizable fields within the Unity Editor.
- Import the
RandomizableFields
namespace. - Add
[Randomizable(MIN, MAX)]
or[Randomizable(MAX)]
attributes toint
andfloat
fields. - Add
[RandomizableGuid]
to string-basedGUID
fields.
[Randomizable(0.0f, 1.0f)] [SerializeField]
private float _randomFloat;
[Randomizable(100)] [SerializeField]
private int _randomInt;
[RandomizableGuid] [SerializeField]
private string _randomGuid = Guid.NewGuid().ToString();
- The "MIN" value can be omitted, for numeric fields it'll default to
0
. - If you accidentally click the "R" button, just undo your changes and the previous value will appear.
- Randomizable vector fields
- Randomizable string fields
I use a lot of IMGUI Window
functions for rapid prototyping. The IMGUI system requires a window to have a unique ID. This attribute allowed me to easily set a new ID to a random value with one click. I'm just too lazy to remember the last ID I used, but not too lazy to write an entire attribute system. ;)