Tag & Layer Type Generator
Alkimee Games
$0.0
(no ratings)
Date |
Price |
---|---|
Date |
Price($) |
04/12(2021) |
0.0 |
11/05(2024) |
0.0 |
Jump AssetStore
The Tag / Layer Type Generator generates typed classes for the tags and layers in your project. It does this *automatically* and in the background. No manual button pushes required!Why use statically typed Tags or Layers?Using typed tags and layers in your project's code provides compile-time checking of the tag and layer values. Using the included Tag or Layer attributes on a string or int property respectively also allows you to adjust these values in the inspector. See examples below.Whats wrong with UnityEngine.LayerMask?Nothing! The generated types are designed to augment the usage of Unity's LayerMask struct. The LayerMask struct provides methods for converting a layer from a string into its corresponding ID (int) and vice versa. However, both approaches require you to use 'magic strings' in your code. Using typed values for both the layer id and the mask allows you to catch errors at compile time. The layer type also contains pre-computer masks for each layer, making it simple to create layer masks from the types.SetupThe Tag / Layer Type generator works out of the box with no dependencies other than Unity itself. Just install it and you're ready to go. It's pure CSharp, fully open-source, and the public API has complete XML documentation built right in, including the generated CSharp code. A settings asset is created in your project where you can customize the Namespace, Type Name, File Path and Assembly Definitions. This can all be managed via the Settings asset or via the Project Settings window.Generating TypesThe Tag / Layer Type generator subscribes to the Unity Editor's'projectChanged' event. When this event is raised, the generators check to see if any new tags or layers have been added or previous tags or layers have been updated. A new CSharp file is generated in either case. It's also possible to manually generate the files either via a button in the Project Settings windows or inspecting the TagLayerSettings asset.More InformationFurther information about how the tool works and what API's it exposes are available on the GitHub page.