unity-atoms/docs/api/unityatoms.editor.md

472 lines
12 KiB
Markdown
Raw Normal View History

2019-10-14 20:08:41 -04:00
---
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`.
---
2019-10-15 13:19:44 -04:00
## `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).
---
2019-10-15 16:23:46 -04:00
## `BoolConstantDrawer`
Constant property drawer of type `bool`. Inherits from `AtomDrawer<BoolConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:27:22 -04:00
## `Collider2DConstantDrawer`
Constant property drawer of type `Collider2D`. Inherits from `AtomDrawer<Collider2DConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:26:14 -04:00
## `ColliderConstantDrawer`
Constant property drawer of type `Collider`. Inherits from `AtomDrawer<ColliderConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:24:44 -04:00
## `ColorConstantDrawer`
Constant property drawer of type `Color`. Inherits from `AtomDrawer<ColorConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:29:05 -04:00
## `FloatConstantDrawer`
Constant property drawer of type `float`. Inherits from `AtomDrawer<FloatConstant>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:23:46 -04:00
## `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`.
---
2019-10-15 16:27:22 -04:00
## `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`.
---
2019-10-15 16:26:14 -04:00
## `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`.
---
2019-10-15 16:24:44 -04:00
## `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`.
---
2019-10-15 16:29:05 -04:00
## `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`.
---
2019-10-15 16:23:46 -04:00
## `BoolListDrawer`
List property drawer of type `bool`. Inherits from `AtomDrawer<BoolList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:27:22 -04:00
## `Collider2DListDrawer`
List property drawer of type `Collider2D`. Inherits from `AtomDrawer<Collider2DList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:26:14 -04:00
## `ColliderListDrawer`
List property drawer of type `Collider`. Inherits from `AtomDrawer<ColliderList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:24:44 -04:00
## `ColorListDrawer`
List property drawer of type `Color`. Inherits from `AtomDrawer<ColorList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:29:05 -04:00
## `FloatListDrawer`
List property drawer of type `float`. Inherits from `AtomDrawer<FloatList>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:23:46 -04:00
## `BoolVariableDrawer`
Variable property drawer of type `bool`. Inherits from `AtomDrawer<BoolVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:27:22 -04:00
## `Collider2DVariableDrawer`
Variable property drawer of type `Collider2D`. Inherits from `AtomDrawer<Collider2DVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:26:14 -04:00
## `ColliderVariableDrawer`
Variable property drawer of type `Collider`. Inherits from `AtomDrawer<ColliderVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:24:44 -04:00
## `ColorVariableDrawer`
Variable property drawer of type `Color`. Inherits from `AtomDrawer<ColorVariable>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:29:05 -04:00
## `FloatVariableDrawer`
Variable property drawer of type `float`. Inherits from `AtomDrawer<FloatVariable>`. 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.
---
2019-10-15 16:23:46 -04:00
## `BoolEventEditor`
Event property drawer of type `bool`. Inherits from `AtomEventEditor<bool, BoolEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:27:22 -04:00
## `Collider2DEventEditor`
Event property drawer of type `Collider2D`. Inherits from `AtomEventEditor<Collider2D, Collider2DEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:26:14 -04:00
## `ColliderEventEditor`
Event property drawer of type `Collider`. Inherits from `AtomEventEditor<Collider, ColliderEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:24:44 -04:00
## `ColorEventEditor`
Event property drawer of type `Color`. Inherits from `AtomEventEditor<Color, ColorEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 16:29:05 -04:00
## `FloatEventEditor`
Event property drawer of type `float`. Inherits from `AtomEventEditor<float, FloatEvent>`. Only availble in `UNITY_2019_1_OR_NEWER`.
---
2019-10-15 13:19:44 -04:00
## `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`).
---
2019-10-15 13:19:44 -04:00
## `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.
---
2019-10-14 20:08:41 -04:00
## `EditorIconPostProcessor`
2019-10-15 13:19:44 -04: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.
### 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.
2019-10-14 20:08:41 -04:00
---