unity-atoms/docs/api/unityatoms.editor.md
AdamRamberg 299dc195e2 - Added a top menu bar option to regenerate all existing Atoms. Nifty when developing the library.
- Added the option to use a Constant in Atom References. Related to #58
2019-10-16 18:02:08 +02:00

676 lines
17 KiB
Markdown

---
id: unityatoms.editor
title: UnityAtoms.Editor
hide_title: true
sidebar_label: UnityAtoms.Editor
---
# Namespace - `UnityAtoms.Editor`
## `AtomDrawer<T>`
#### Type Parameters
- `T` - The type of Atom the property drawer should apply to.
The base Unity Atoms property drawer. Makes it possible to create and add a new Atom via Unity's inspector. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `AtomReferenceDrawer`
A custom property drawer for References. Makes it possible to choose between a Variable and a constant value (not a Atom Contant, but a regular value).
---
## `BoolConstantDrawer`
Constant property drawer of type `bool`. Inherits from `AtomDrawer<BoolConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Collider2DConstantDrawer`
Constant property drawer of type `Collider2D`. Inherits from `AtomDrawer<Collider2DConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColliderConstantDrawer`
Constant property drawer of type `Collider`. Inherits from `AtomDrawer<ColliderConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColorConstantDrawer`
Constant property drawer of type `Color`. Inherits from `AtomDrawer<ColorConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `FloatConstantDrawer`
Constant property drawer of type `float`. Inherits from `AtomDrawer<FloatConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `GameObjectConstantDrawer`
Constant property drawer of type `GameObject`. Inherits from `AtomDrawer<GameObjectConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `IntConstantDrawer`
Constant property drawer of type `int`. Inherits from `AtomDrawer<IntConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `StringConstantDrawer`
Constant property drawer of type `string`. Inherits from `AtomDrawer<StringConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector2ConstantDrawer`
Constant property drawer of type `Vector2`. Inherits from `AtomDrawer<Vector2Constant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector3ConstantDrawer`
Constant property drawer of type `Vector3`. Inherits from `AtomDrawer<Vector3Constant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `BoolBoolEventDrawer`
Event x 2 property drawer of type `bool`. Inherits from `AtomDrawer<BoolBoolEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `BoolEventDrawer`
Event property drawer of type `bool`. Inherits from `AtomDrawer<BoolEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Collider2DCollider2DEventDrawer`
Event x 2 property drawer of type `Collider2D`. Inherits from `AtomDrawer<Collider2DCollider2DEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Collider2DEventDrawer`
Event property drawer of type `Collider2D`. Inherits from `AtomDrawer<Collider2DEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColliderColliderEventDrawer`
Event x 2 property drawer of type `Collider`. Inherits from `AtomDrawer<ColliderColliderEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColliderEventDrawer`
Event property drawer of type `Collider`. Inherits from `AtomDrawer<ColliderEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColorColorEventDrawer`
Event x 2 property drawer of type `Color`. Inherits from `AtomDrawer<ColorColorEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColorEventDrawer`
Event property drawer of type `Color`. Inherits from `AtomDrawer<ColorEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `FloatEventDrawer`
Event property drawer of type `float`. Inherits from `AtomDrawer<FloatEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `FloatFloatEventDrawer`
Event x 2 property drawer of type `float`. Inherits from `AtomDrawer<FloatFloatEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `GameObjectEventDrawer`
Event property drawer of type `GameObject`. Inherits from `AtomDrawer<GameObjectEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `GameObjectGameObjectEventDrawer`
Event x 2 property drawer of type `GameObject`. Inherits from `AtomDrawer<GameObjectGameObjectEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `IntEventDrawer`
Event property drawer of type `int`. Inherits from `AtomDrawer<IntEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `IntIntEventDrawer`
Event x 2 property drawer of type `int`. Inherits from `AtomDrawer<IntIntEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `StringEventDrawer`
Event property drawer of type `string`. Inherits from `AtomDrawer<StringEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `StringStringEventDrawer`
Event x 2 property drawer of type `string`. Inherits from `AtomDrawer<StringStringEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector2EventDrawer`
Event property drawer of type `Vector2`. Inherits from `AtomDrawer<Vector2Event>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector2Vector2EventDrawer`
Event x 2 property drawer of type `Vector2`. Inherits from `AtomDrawer<Vector2Vector2Event>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector3EventDrawer`
Event property drawer of type `Vector3`. Inherits from `AtomDrawer<Vector3Event>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector3Vector3EventDrawer`
Event x 2 property drawer of type `Vector3`. Inherits from `AtomDrawer<Vector3Vector3Event>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `VoidEventDrawer`
Event property drawer of type `Void`. Inherits from `AtomDrawer<VoidEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `BoolListDrawer`
List property drawer of type `bool`. Inherits from `AtomDrawer<BoolList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Collider2DListDrawer`
List property drawer of type `Collider2D`. Inherits from `AtomDrawer<Collider2DList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColliderListDrawer`
List property drawer of type `Collider`. Inherits from `AtomDrawer<ColliderList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColorListDrawer`
List property drawer of type `Color`. Inherits from `AtomDrawer<ColorList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `FloatListDrawer`
List property drawer of type `float`. Inherits from `AtomDrawer<FloatList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `GameObjectListDrawer`
List property drawer of type `GameObject`. Inherits from `AtomDrawer<GameObjectList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `IntListDrawer`
List property drawer of type `int`. Inherits from `AtomDrawer<IntList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `StringListDrawer`
List property drawer of type `string`. Inherits from `AtomDrawer<StringList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector2ListDrawer`
List property drawer of type `Vector2`. Inherits from `AtomDrawer<Vector2List>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector3ListDrawer`
List property drawer of type `Vector3`. Inherits from `AtomDrawer<Vector3List>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `BoolVariableDrawer`
Variable property drawer of type `bool`. Inherits from `AtomDrawer<BoolVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Collider2DVariableDrawer`
Variable property drawer of type `Collider2D`. Inherits from `AtomDrawer<Collider2DVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColliderVariableDrawer`
Variable property drawer of type `Collider`. Inherits from `AtomDrawer<ColliderVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColorVariableDrawer`
Variable property drawer of type `Color`. Inherits from `AtomDrawer<ColorVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `FloatVariableDrawer`
Variable property drawer of type `float`. Inherits from `AtomDrawer<FloatVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `GameObjectVariableDrawer`
Variable property drawer of type `GameObject`. Inherits from `AtomDrawer<GameObjectVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `IntVariableDrawer`
Variable property drawer of type `int`. Inherits from `AtomDrawer<IntVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `StringVariableDrawer`
Variable property drawer of type `string`. Inherits from `AtomDrawer<StringVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector2VariableDrawer`
Variable property drawer of type `Vector2`. Inherits from `AtomDrawer<Vector2Variable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector3VariableDrawer`
Variable property drawer of type `Vector3`. Inherits from `AtomDrawer<Vector3Variable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `AtomEventEditor<T,E>`
#### Type Parameters
- `T` - undefined
- `E` - undefined
Custom editor for Events. Adds the possiblity to raise an Event from Unity's Inspector.
---
## `BoolEventEditor`
Event property drawer of type `bool`. Inherits from `AtomEventEditor<bool, BoolEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Collider2DEventEditor`
Event property drawer of type `Collider2D`. Inherits from `AtomEventEditor<Collider2D, Collider2DEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColliderEventEditor`
Event property drawer of type `Collider`. Inherits from `AtomEventEditor<Collider, ColliderEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `ColorEventEditor`
Event property drawer of type `Color`. Inherits from `AtomEventEditor<Color, ColorEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `FloatEventEditor`
Event property drawer of type `float`. Inherits from `AtomEventEditor<float, FloatEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `GameObjectEventEditor`
Event property drawer of type `GameObject`. Inherits from `AtomEventEditor<GameObject, GameObjectEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `IntEventEditor`
Event property drawer of type `int`. Inherits from `AtomEventEditor<int, IntEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `StringEventEditor`
Event property drawer of type `string`. Inherits from `AtomEventEditor<string, StringEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector2EventEditor`
Event property drawer of type `Vector2`. Inherits from `AtomEventEditor<Vector2, Vector2Event>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `Vector3EventEditor`
Event property drawer of type `Vector3`. Inherits from `AtomEventEditor<Vector3, Vector3Event>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `VoidEventEditor`
Event property drawer of type `Void`. Inherits from `AtomEventEditor<Void, VoidEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
## `AtomType`
Internal module class that holds that regarding an Atom type.
---
## `AtomTypes`
Internal static class holding predefined static `AtomType`s.
---
## `Generator`
Generator that generates new Atom types based on the input data. Used by the `GeneratorEditor`. Only availble in `UNITY_2019_1_OR_NEWER`.
### Methods
#### `Generate(System.String,System.String,System.Boolean,System.Collections.Generic.List{UnityAtoms.Editor.AtomType},System.String,System.String)`
Generate new Atoms based on the input data.
##### Parameters
- `type` - The type of Atom to generate.abstract Eg. double, byte, MyStruct, MyClass.
- `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.
##### 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
```
---
#### `RemoveDuplicateNamespaces(System.String)`
Removes duplicate namespaces, given content from a template.
##### Parameters
- `content` - The content template to remove namespace from.
##### Returns
A copy of `content`, but without duplicate namespaces.
---
#### `ResolveFileName(System.Collections.Generic.Dictionary{System.String,System.String},System.String,System.Int32,System.String,System.String,System.Int32)`
Resolve file name based on input data.
##### Parameters
- `templateVariables` - Template variables.
- `templateName` - Template name.
- `lastIndexOfDoubleUnderscore` - Last index of double underscore.
- `capitalizedType` - Capitalized type.
- `capitalizedAtomType` - Capitalized Atom type (string).
- `typeOccurrences` - Number of occurrences of the type.
##### Returns
The filename to use.
---
#### `ResolveDirPath(System.String,System.String,System.String,System.String)`
Resolves the directory path based on the input data.
##### Parameters
- `baseWritePath` - The base write path (relative to the Assets folder).
- `capitalizedAtomType` - Capitalized Atom type (string).
- `templateName` - Template name.
- `atomType` - Atom type.
##### Returns
The directory to use.
---
#### `Capitalize(System.String)`
Capitalize the provided string.
##### Parameters
- `s` - The string to capitalize.
##### Returns
A capitalized version of the string provided.
---
#### `ShouldSkipTemplate(System.Collections.Generic.List{UnityAtoms.Editor.AtomType},System.String,System.Int32)`
Given the input data, should generation of this template be skipped.
##### Parameters
- `atomTypesToGenerate` - List of Atom types to generate.
- `capitalizedAtomType` - Capitalized Atom type (string).
- `typeOccurrences` - Number of occurrences of the type.
##### Returns
If we should skip the template or not.
---
## `GeneratorEditor`
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`.
### Methods
#### `Init`
Create the editor window.
---
#### `AddAtomTypeToGenerate(UnityAtoms.Editor.AtomType)`
Add provided `AtomType` to the list of Atom types to be generated.
##### Parameters
- `atomType` - The `AtomType` to be added.
---
#### `RemoveAtomTypeToGenerate(UnityAtoms.Editor.AtomType)`
Remove provided `AtomType` from the list of Atom types to be generated.
##### Parameters
- `atomType` - The `AtomType` to be removed.
---
#### `SetWarningText(UnityAtoms.Editor.AtomType,System.Collections.Generic.List{UnityAtoms.Editor.AtomType})`
Set and display warning text in the editor.
##### Parameters
- `atomType` - `AtomType` to generate the warning for.
- `dependencies` - The `AtomType`s that this `AtomType` is depending on.
---
#### `OnEnable`
Called when editor is enabled.
---
#### `CreateDivider`
Helper method to create a divider.
##### Returns
The divider (`VisualElement`) created.
---
#### `CreateAtomTypeToGenerateToggleRow(UnityAtoms.Editor.AtomType)`
Helper to create toogle row for a specific `AtomType`.
##### Parameters
- `atomType` - The provided `AtomType`.
##### Returns
A new toggle row (`VisualElement`).
---
## `RegenereateAllAtoms`
Internal utility class to regenerate all Atoms. Reachable via top menu bar and `Tools/Unity Atoms/Regenerate All Atoms`.
### Methods
#### `Regenereate`
Create the editor window.
---
## `Templating`
Internal class used for templating when generating new Atoms using the `Generator`.
### Methods
#### `ResolveConditionals(System.String,System.Collections.Generic.List{System.String})`
Resolve conditionals from the provided tempalte.
##### Parameters
- `template` - Template to resolve the conditionals from.
- `trueConditions` - A list of conditionals that are `true`.
##### Returns
A new template string resolved and based on the provided `template`.
---
#### `ResolveVariables(System.Collections.Generic.Dictionary{System.String,System.String},System.String)`
Resolve variables in the provided string.
##### Parameters
- `templateVariables` - Dictionay mapping template variables and their resolutions.
- `toResolve` - The string to resolve.
##### Returns
A new template string resolved and based on the provided `toResolve` string.
---
## `EditorIconPostProcessor`
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.
### Methods
#### `OnPostprocessAllAssets(System.String[],System.String[],System.String[],System.String[])`
Called when new assets are imported, deleted or moved.
##### Parameters
- `importedAssets` - Imported assets.
- `deletedAssets` - Deleted assets.
- `movedAssets` - Moved assets.
- `movedFromAssetPaths` - Moved from asset paths.
---