--- id: unityatoms.editor title: UnityAtoms.Editor hide_title: true sidebar_label: UnityAtoms.Editor --- # Namespace - `UnityAtoms.Editor` ## `AtomDrawer` #### 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`. Only availble in `UNITY_2019_1_OR_NEWER`. --- ## `BoolBoolEventDrawer` Event x 2 property drawer of type `bool`. Inherits from `AtomDrawer`. Only availble in `UNITY_2019_1_OR_NEWER`. --- ## `BoolEventDrawer` Event property drawer of type `bool`. Inherits from `AtomDrawer`. Only availble in `UNITY_2019_1_OR_NEWER`. --- ## `BoolListDrawer` List property drawer of type `bool`. Inherits from `AtomDrawer`. Only availble in `UNITY_2019_1_OR_NEWER`. --- ## `BoolVariableDrawer` Variable property drawer of type `bool`. Inherits from `AtomDrawer`. Only availble in `UNITY_2019_1_OR_NEWER`. --- ## `AtomEventEditor` #### 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`. 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() { 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`). --- ## `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. ---