Procedural Assets

Pro Only: Weaver Lite allows you to generate procedural assets in the Unity Editor, but the Asset Injection will not be available in a runtime build unless you purchase Weaver Pro. You can still use the generated assets as regular assets though.

It can often be useful to generate an asset procedurally in the Unity Editor instead of making it manually or generating it at runtime, such as:

  • If the generation process is computationally expensive.
  • If you need to use Editor-Only functionality.
  • If you want to be able to manually place instances of the generated asset in a scene and otherwise treat it like a regular asset.

All of the Project Constants scripts are generated using this feature.

To create a procedural asset, you first define it in a script then use the Weaver Window to generate it.

Defining a Procedural Asset To define a procedural asset, you simply make an Asset Injection field, then give it a [ProceduralAsset] attribute and add a static method called GenerateX, where X is the name of the field.
Generating a Procedural Asset Once you have defined a procedural asset (or made changes to an existing one), you need to generate it - either using the [G] button next to the asset in the Procedural Assets panel of the Weaver Window or by right clicking on the asset's overlay icon in the Project Window and using the Generate command.
Asset Generators Most generator methods are parameterless and can just return the generated asset, but some require other method signatures.
Procedural Meshes The Kybernetik.MeshBuilder class is very useful for easily and efficiently generating procedural meshes, both as Procedural Assets in the Unity Editor and dynamic meshes at runtime.
Procedural Scripts The Kybernetik.ProceduralScripting namespace contains various utilities which are useful for geneerating procedural scripts.
Dependencies When referencing one procedural asset from the generator method of another procedural asset you should always use ProceduralAsset.GrabDependency instead of accessing the injected field directly.