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.
  • Each of these systems has its own panel in the Weaver Window which can be used to customise its contents.
  • The procedural scripts are saved in the Assets/Procedural Assets folder by default. This is known as the Working 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 states and parameters of all Animator Controllers in your project.
Layers Constants for the physics layers in your project.
Navigation Areas Constants for the nav-mesh areas in your project.
Scenes Constants for the scenes in your build settings.
Shaders Constants for the properties and keywords of chosen shaders.
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.