Project Constants

Weaver includes several systems which remove the need for magic strings and arbitrary numbers when working with Unity systems, allowing you to write safer and more reliable code.

  • Each of these systems generates a procedural script containing various constants and utilities which you can reference directly instead of using unsafe lookup methods.
  • The scripts will be automatically regenerated to account for any changes in the project whenever assets are saved such as when the user presses Ctrl + S to save the scene or when the project is built.
  • These systems each start disabled and can be enabled via their respective panels in the Weaver Window which can also be used to customise the generated scripts contents.
  • The procedural scripts are saved in the Assets/Procedural Assets folder by default. This is known as the Output Directory and can be changed in the Procedural Assets Panel.

These systems offer several advantages over the regular ways of interacting with Unity:

  • Once generated, these scripts will show up in Intellisense so you can utilise automatic code completion and other helpful features of your IDE when referencing values.
  • If you make a spelling mistake you immediately get a compile error instead of trying to hunt down the cause of a bug at runtime which might not even be picked up any time soon.
  • Constants are more efficient than regular usage because they are generated in the Unity Editor instead of needing to look up the desired value based on a string at runtime.
Animations Constants for all the states and parameters of all Animator Controllers in your project.
Layers Constants for all the physics layers in your project.
Navigation Areas Constants for all the nav-mesh areas in your project.
Scenes Constants for all the scenes in your build settings.
Shaders Constants for all the properties and keywords of chosen shaders.
Tags Constants for all the tags in your project.
Obsolete Members When a script is regenerated, it continues to include any old members that would otherwise be removed and marks them as [Obsolete] so references to them can be easily identified and resolved without creating immediate compile errors.