2019-10-15 02:08:41 +02:00
---
id: unityatoms.editor
title: UnityAtoms.Editor
hide_title: true
sidebar_label: UnityAtoms.Editor
---
# Namespace - `UnityAtoms.Editor`
2020-01-23 23:42:09 +01:00
## `EditorIconPostProcessor`
2019-10-15 21:08:49 +02:00
2020-01-23 23:42:09 +01:00
Postprocessor that processes all scripts using the EditorIcon attribute and assigns the matching icon guid (matching the icon query name) to the script's meta. It's a very simple solution (and very hacky), but works really great.
2019-10-15 21:08:49 +02:00
2020-01-23 23:42:09 +01:00
### Methods
2019-10-15 21:08:49 +02:00
2020-01-23 23:42:09 +01:00
#### `OnPostprocessAllAssets(System.String[],System.String[],System.String[],System.String[])`
2019-10-15 21:08:49 +02:00
2020-01-23 23:42:09 +01:00
Called when new assets are imported, deleted or moved.
2019-10-15 21:08:49 +02:00
2020-01-23 23:42:09 +01:00
##### Parameters
2019-10-15 19:19:44 +02:00
2020-01-23 23:42:09 +01:00
- `importedAssets` - Imported assets.
- `deletedAssets` - Deleted assets.
- `movedAssets` - Moved assets.
- `movedFromAssetPaths` - Moved from asset paths.
2019-10-15 19:19:44 +02:00
---
2020-01-23 23:42:09 +01:00
## `RegenereateAllAtoms`
2019-10-15 22:24:44 +02:00
2020-01-23 23:42:09 +01:00
Internal utility class to regenerate all Atoms. Reachable via top menu bar and `Tools/Unity Atoms/Regenerate All Atoms` .
2019-10-15 22:24:44 +02:00
2020-01-23 23:42:09 +01:00
### Methods
2019-10-15 22:24:44 +02:00
2020-01-23 23:42:09 +01:00
#### `Regenereate`
2019-10-15 22:29:05 +02:00
2020-01-23 23:42:09 +01:00
Create the editor window.
2019-10-15 22:29:05 +02:00
---
2020-01-23 23:42:09 +01:00
## `Templating`
2019-10-15 22:30:18 +02:00
2020-01-23 23:42:09 +01:00
Internal class used for templating when generating new Atoms using the `Generator` .
2019-10-15 22:30:18 +02:00
2020-01-23 23:42:09 +01:00
### Methods
2019-10-15 22:30:18 +02:00
2020-01-23 23:42:09 +01:00
#### `ResolveConditionals(System.String,System.Collections.Generic.List{System.String})`
2019-10-15 22:32:06 +02:00
2020-01-23 23:42:09 +01:00
Resolve conditionals from the provided tempalte.
2019-10-15 22:32:06 +02:00
2020-01-23 23:42:09 +01:00
##### Parameters
2019-10-15 22:32:06 +02:00
2020-01-23 23:42:09 +01:00
- `template` - Template to resolve the conditionals from.
- `trueConditions` - A list of conditionals that are `true` .
2019-10-15 22:33:06 +02:00
2020-01-23 23:42:09 +01:00
##### Returns
A new template string resolved and based on the provided `template` .
2019-10-15 22:33:06 +02:00
---
2020-01-23 23:42:09 +01:00
#### `ResolveVariables(System.Collections.Generic.Dictionary{System.String,System.String},System.String)`
2019-10-15 22:34:08 +02:00
2020-01-23 23:42:09 +01:00
Resolve variables in the provided string.
2019-10-15 22:34:08 +02:00
2020-01-23 23:42:09 +01:00
##### Parameters
2019-10-15 22:34:08 +02:00
2020-01-23 23:42:09 +01:00
- `templateVariables` - Dictionay mapping template variables and their resolutions.
- `toResolve` - The string to resolve.
2019-10-15 22:34:48 +02:00
2020-01-23 23:42:09 +01:00
##### Returns
A new template string resolved and based on the provided `toResolve` string.
2019-10-15 22:34:48 +02:00
---
2020-01-23 23:42:09 +01:00
## `GeneratorEditor`
2019-10-15 22:23:46 +02:00
2020-01-23 23:42:09 +01:00
Editor class for the `Generator` . Use it via the top window bar at _Tools / Unity Atoms / Generator_ . Only availble in `UNITY_2019_1_OR_NEWER` .
2019-10-15 22:23:46 +02:00
2020-01-23 23:42:09 +01:00
### Methods
2019-10-15 22:23:46 +02:00
2020-01-23 23:42:09 +01:00
#### `Init`
2019-10-15 22:23:46 +02:00
2020-01-23 23:42:09 +01:00
Create the editor window.
2019-10-15 22:23:46 +02:00
---
2020-01-23 23:42:09 +01:00
#### `AddAtomTypeToGenerate(UnityAtoms.Editor.AtomType)`
2019-10-15 22:27:22 +02:00
2020-01-23 23:42:09 +01:00
Add provided `AtomType` to the list of Atom types to be generated.
2019-10-15 22:27:22 +02:00
2020-01-23 23:42:09 +01:00
##### Parameters
2019-10-15 22:27:22 +02:00
2020-01-23 23:42:09 +01:00
- `atomType` - The `AtomType` to be added.
2019-10-15 22:27:22 +02:00
---
2020-01-23 23:42:09 +01:00
#### `RemoveAtomTypeToGenerate(UnityAtoms.Editor.AtomType)`
2019-10-15 22:26:14 +02:00
2020-01-23 23:42:09 +01:00
Remove provided `AtomType` from the list of Atom types to be generated.
2019-10-15 22:26:14 +02:00
2020-01-23 23:42:09 +01:00
##### Parameters
2019-10-15 22:26:14 +02:00
2020-01-23 23:42:09 +01:00
- `atomType` - The `AtomType` to be removed.
2019-10-15 22:26:14 +02:00
---
2020-01-23 23:42:09 +01:00
#### `SetWarningText(UnityAtoms.Editor.AtomType,System.Collections.Generic.List{UnityAtoms.Editor.AtomType})`
2019-10-15 22:24:44 +02:00
2020-01-23 23:42:09 +01:00
Set and display warning text in the editor.
2019-10-15 22:24:44 +02:00
2020-01-23 23:42:09 +01:00
##### Parameters
2019-10-15 22:24:44 +02:00
2020-01-23 23:42:09 +01:00
- `atomType` - `AtomType` to generate the warning for.
2020-03-02 20:12:38 +01:00
- `disabledDeps` - List of disabled deps.
2019-10-15 22:24:44 +02:00
---
2020-01-23 23:42:09 +01:00
#### `OnEnable`
2019-10-15 22:29:05 +02:00
2020-01-23 23:42:09 +01:00
Called when editor is enabled.
2019-10-15 22:29:05 +02:00
---
2020-01-23 23:42:09 +01:00
#### `CreateDivider`
2019-10-15 22:29:05 +02:00
2020-01-23 23:42:09 +01:00
Helper method to create a divider.
2019-10-15 22:29:05 +02:00
2020-01-23 23:42:09 +01:00
##### Returns
2019-10-15 22:30:18 +02:00
2020-01-23 23:42:09 +01:00
The divider (`VisualElement` ) created.
2019-10-15 22:30:18 +02:00
---
2020-01-23 23:42:09 +01:00
#### `CreateAtomTypeToGenerateToggleRow(UnityAtoms.Editor.AtomType)`
2019-10-15 22:30:18 +02:00
2020-01-23 23:42:09 +01:00
Helper to create toogle row for a specific `AtomType` .
2019-10-15 22:30:18 +02:00
2020-01-23 23:42:09 +01:00
##### Parameters
2019-10-15 22:30:18 +02:00
2020-01-23 23:42:09 +01:00
- `atomType` - The provided `AtomType` .
2019-10-15 22:32:06 +02:00
2020-01-23 23:42:09 +01:00
##### Returns
A new toggle row (`VisualElement` ).
2019-10-15 22:32:06 +02:00
---
2020-03-02 20:12:38 +01:00
## `AtomReceipe`
Internal module class that holds that regarding an Atom type.
---
2020-01-23 23:42:09 +01:00
## `AtomType`
2019-10-15 22:32:06 +02:00
2020-01-23 23:42:09 +01:00
Internal module class that holds that regarding an Atom type.
2019-10-15 22:32:06 +02:00
---
2020-01-23 23:42:09 +01:00
## `Generator`
2019-10-15 22:33:06 +02:00
2020-01-23 23:42:09 +01:00
Generator that generates new Atom types based on the input data. Used by the `GeneratorEditor` . Only availble in `UNITY_2019_1_OR_NEWER` .
2019-10-15 22:33:06 +02:00
2020-01-23 23:42:09 +01:00
### Methods
2019-10-15 22:33:06 +02:00
2020-03-02 20:12:38 +01:00
#### `Generate(UnityAtoms.Editor.AtomReceipe,System.String,System.String[],System.Collections.Generic.List{System.String},System.Collections.Generic.Dictionary{System.String,System.String})`
2019-10-15 22:33:06 +02:00
2020-01-23 23:42:09 +01:00
Generate new Atoms based on the input data.
2019-10-15 22:33:06 +02:00
2020-01-23 23:42:09 +01:00
##### Parameters
2019-10-15 22:33:06 +02:00
2020-03-02 20:12:38 +01:00
- `valueType` - The type of Atom to generate.abstract Eg. double, byte, MyStruct, MyClass.
2020-01-23 23:42:09 +01:00
- `baseWritePath` - Base write path (relative to the Asset folder) where the Atoms are going to be written to.
- `isEquatable` - Is the `type` provided implementing `IEquatable` ?
- `atomTypesToGenerate` - A list of `AtomType` s to be generated.
- `typeNamespace` - If the `type` provided is defined under a namespace, provide that namespace here.
- `subUnityAtomsNamespace` - 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.
2019-10-15 22:34:08 +02:00
2020-01-23 23:42:09 +01:00
##### Examples
```cs
namespace MyNamespace
{
public struct MyStruct
{
public string Text;
public int Number;
}
}
var generator = new Generator();
generator.Generate("MyStruct", "", false, new List< AtomType > () { AtomTypes.ACTION }, "MyNamespace", ""); // Generates an Atom Action of type MyStruct
```
2019-10-15 22:34:08 +02:00
---
2020-01-23 23:42:09 +01:00
#### `RemoveDuplicateNamespaces(System.String)`
2019-10-15 22:34:08 +02:00
2020-01-23 23:42:09 +01:00
Removes duplicate namespaces, given content from a template.
2019-10-15 22:34:08 +02:00
2020-01-23 23:42:09 +01:00
##### Parameters
2019-10-15 22:34:08 +02:00
2020-03-02 20:12:38 +01:00
- `template` - The content template to remove namespace from.
2019-10-15 22:34:48 +02:00
2020-01-23 23:42:09 +01:00
##### Returns
A copy of `content` , but without duplicate namespaces.
2019-10-15 22:34:48 +02:00
---
2020-01-23 23:42:09 +01:00
## `AtomTypes`
2019-10-15 22:32:06 +02:00
2020-01-23 23:42:09 +01:00
Internal static class holding predefined static `AtomType` s.
2019-10-15 22:32:06 +02:00
2020-03-21 23:03:14 +01:00
### Variables
#### `ALL_ATOM_TYPES`
Containes all common atom types that are usually generated for a type.
---
#### `DEPENDENCY_GRAPH`
Graph explaining all the dependencies between Atoms.
2019-10-15 22:32:06 +02:00
---
2020-02-24 00:59:35 +01:00
## `AtomEventReferenceDrawer`
2020-03-21 23:03:14 +01:00
A custom property drawer for Event References. Makes it possible to choose between an Event, Event Instancer, Variable or a Variable Instancer.
2020-02-24 00:59:35 +01:00
---
2020-01-23 23:42:09 +01:00
## `AtomDrawer<T>`
2019-10-15 22:33:06 +02:00
2020-01-23 23:42:09 +01:00
#### Type Parameters
2019-10-15 22:33:06 +02:00
2020-01-23 23:42:09 +01:00
- `T` - The type of Atom the property drawer should apply to.
2019-10-15 22:34:08 +02:00
2020-06-20 00:49:40 +02:00
The base Unity Atoms property drawer. Makes it possible to create and add a new Atom via Unity's inspector. Only availble in `UNITY_2018_3_OR_NEWER` .
2019-10-15 22:34:08 +02:00
---
2020-01-23 23:42:09 +01:00
## `AtomReferenceDrawer`
2019-10-15 22:34:48 +02:00
2020-03-21 23:03:14 +01:00
A custom property drawer for References. Makes it possible to choose between a Value, Variable, Constant or a Variable Instancer.
---
## `AtomBaseReferenceDrawer`
A custom property drawer for References (Events and regular). Makes it possible to reference a resources (Variable or Event) through multiple options.
2019-10-15 22:34:48 +02:00
---
2020-03-02 20:12:38 +01:00
## `ReadOnlyDrawer`
2019-10-15 22:30:18 +02:00
2020-03-02 20:12:38 +01:00
Make property read only by using the abbtribute `[ReadOnly]` . Solution taken from: https://answers.unity.com/questions/489942/how-to-make-a-readonly-property-in-inspector.html
2019-10-15 22:30:18 +02:00
---
2020-03-21 23:03:14 +01:00
## `AtomListAttributeDrawer`
A custom property drawer for properties using the `AtomList` attribute.
---
2020-03-02 20:12:38 +01:00
## `AtomVariableEditor`2`
2020-02-24 00:59:35 +01:00
Custom editor for Variables. Provides a better user workflow and indicates when which variables can be edited
---
## `AtomEventEditor<T,E>`
#### Type Parameters
- `T` - The type of this event..
- `E` - Event of type T.
Custom editor for Events. Adds the possiblity to raise an Event from Unity's Inspector.
---