107 lines
3.6 KiB
Markdown
Raw Normal View History

2019-10-04 01:37:30 +02:00
---
id: generator
title: Generator
hide_title: true
sidebar_label: Generator
---
2019-10-03 23:05:26 +02:00
# Generator
2019-10-07 21:37:04 +02:00
The Generator is a powerful tool that allows you to generate your own Atoms fast and easy via an Unity editor window. It liberates you from writing otherwise tedious boilerplate code and lets you instead focus on what is important. The Generator can be found by clicking on _Tools / Unity Atoms / Generator_ in the top menu bar:
![generator_top-bar-menu](assets/generator_top-bar-menu.png)
The Generator looks like this:
![generator_window](assets/generator_window.png)
## Options
### Relative write path
The path where the generated Atoms will be written to. The path is relative to your project's root folder (Assets).
### Type name
This is the name of the type that you want to generate. Lets say you want to create your own struct and generate Atoms for it:
```cs
public struct MyStruct
{
public int Number;
}
```
You would then type `MyStruct` as the type name.
### Is type Equatable?
Is the type provided in the above field implementing [`IEquatable`](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1?view=netframework-4.8)? You need to add the following to `MyStruct` to make it implement `IEquatable`:
```cs
using System;
public struct MyStruct : IEquatable<MyStruct>
{
public int Number;
public bool Equals(MyStruct other)
{
return this.Number == other.Number;
}
public override bool Equals(object obj)
{
return Equals((MyStruct)obj);
}
public override int GetHashCode()
{
return Number.GetHashCode();
}
}
```
2020-02-23 02:22:39 +01:00
If your type does not implement [`IEquatable`](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1?view=netframework-4.8) you will need to manually implement the `ValueEquals` method in the generated `AtomVariable`.
2019-10-07 21:37:04 +02:00
### Type namespace
Enter the namespace of the type that you have provided. If for example `MyStruct` was under the namespace `MyNamespace`:
```cs
namespace MyNamespace
{
public struct MyStruct : IEquatable<MyStruct>
{
// ...
}
}
```
You would then enter `MyNamespace`as the type namespace.
### Sub Unity Atoms namespace
By default the Atoms that gets generated will be under the namespace `UnityAtoms`. If you for example like it to be under `UnityAtoms.MyNamespace` you would then enter `MyNamespace` in this field.
### Type(s) to generate
This is a list of Atom types that you want to generate. Simply select the Atoms that you want to generate. Some Atoms depends on other Atoms. If you unselect an Atom that other Atoms depends on, then the Generator will unselect those depending Atoms. Below you find the dependency graph:
Added Variable Instancer, Event Reference, Atom Collection and Atom List (old Atom List renamed to Atom Value List) (#110) AtomVariableInstancer - Added AtomVariableInstancer as an option to AtomReference. - Added AtomVariableInstancer to generator. - Added editor icon for AtomVariableInstancer. AtomEventReference - Added an AtomEventReference class (and AtomEventX2Reference). It’s similar to an AtomReference, but for Events. Let’s you pick between an Event, Variable (will select the Changed event) and a VariableInstancer (see above). - Added AtomEventReference and AtomEventX2Reference to generator. - Added a drawer for AtomEventReference. - Listeners are now using AtomEventReference instead of AtomEvent. - Refactoring of VoidHooks since Listeners are now using AtomEventReference. AtomCollection - Created an AtomCollection - a collection of Atoms associated with key strings (AtomReferences). - Added new editor icon for collections. - Created a SerializableDictionary class, which AtomCollection is using. - Custom property drawer for SerializableDictionary. - SerializableDictionary supports nested structures meaning that a AtomCollection can have a KVP that is pointing to another AtomCollection. - AtomCollections have 3 events: Added, Removed, Cleared. - Added an option to sync an InstanceVariable to collection - adding it to the collection when created (using gameObject’s instance id as key) and removing it from the collection when destroyed. AtomList - Renamed old AtomList to AtomValueList - Added AtomList, like Collection, but a list - Added new icon for AtomList - Created a AtomBaseVariableList class, which AtomList is using. - Custom property drawer for AtomBaseVariableList. - AtomLists have 3 events: Added, Removed, Cleared. - Added an option to sync an InstanceVariable to list - adding it to the list when created and removing it from the list when destroyed.
2020-02-23 02:39:43 +01:00
- Value List - depends on Event
- Listener - depends on Action, Variable, Event, Event x 2, Function x 2, Variable Instancer, Event Reference and Unity Event
- Listener x 2 - depends on Action x 2, Variable, Event, Event x 2, Function x 2, Variable Instancer, Event x 2 Reference and Unity Event x 2
- Reference - depends on Constant, Variable, Event, Event x 2, Function x 2 and Variable Instancer
- Set Variable Value - depends on Event, Event x 2, Function x 2, Variable, Constant, Reference, Variable Instancer
- Variable - depends on Event, Event x 2 and Function x 2
Added Variable Instancer, Event Reference, Atom Collection and Atom List (old Atom List renamed to Atom Value List) (#110) AtomVariableInstancer - Added AtomVariableInstancer as an option to AtomReference. - Added AtomVariableInstancer to generator. - Added editor icon for AtomVariableInstancer. AtomEventReference - Added an AtomEventReference class (and AtomEventX2Reference). It’s similar to an AtomReference, but for Events. Let’s you pick between an Event, Variable (will select the Changed event) and a VariableInstancer (see above). - Added AtomEventReference and AtomEventX2Reference to generator. - Added a drawer for AtomEventReference. - Listeners are now using AtomEventReference instead of AtomEvent. - Refactoring of VoidHooks since Listeners are now using AtomEventReference. AtomCollection - Created an AtomCollection - a collection of Atoms associated with key strings (AtomReferences). - Added new editor icon for collections. - Created a SerializableDictionary class, which AtomCollection is using. - Custom property drawer for SerializableDictionary. - SerializableDictionary supports nested structures meaning that a AtomCollection can have a KVP that is pointing to another AtomCollection. - AtomCollections have 3 events: Added, Removed, Cleared. - Added an option to sync an InstanceVariable to collection - adding it to the collection when created (using gameObject’s instance id as key) and removing it from the collection when destroyed. AtomList - Renamed old AtomList to AtomValueList - Added AtomList, like Collection, but a list - Added new icon for AtomList - Created a AtomBaseVariableList class, which AtomList is using. - Custom property drawer for AtomBaseVariableList. - AtomLists have 3 events: Added, Removed, Cleared. - Added an option to sync an InstanceVariable to list - adding it to the list when created and removing it from the list when destroyed.
2020-02-23 02:39:43 +01:00
- Variable Instancer - depsends on Variable, Event, Event x 2, Function x 2
- Event Reference - depends on Variable, Event, Event x 2, Function x 2, Variable Instancer
- Event x 2 Reference - depends on Variable, Event, Event x 2, Function x 2, Variable Instancer
2019-10-07 21:37:04 +02:00
### Close & Generate
The close button will close the window, while the generate button will generate your Atoms.