This example is a single script located at Assets/Plugins/Weaver/Procedural Assets/BuildDetailsScriptBuilder.cs. It implements an automated build numbering system which can be useful on its own, but also demonstrates how you can create your own Procedural Scripts.
- The bare minimum required for a Procedural Asset is a field or property marked with an Asset Injection attribute and an appropriate generator method.
- In this case, that's the
Scriptproperty andGenerateScriptmethod. - Unlike the Building example, the asset type here is
MonoScriptwhich means that the generator method needs to take aStringBuilderparameter instead of returning the asset type as shown in the Asset Generators table. - Since
MonoScriptis an editor-only type, the[ProceduralAsset]attribute automatically hasEditorOnlyset to true. The script is generated and gets compiled into a build like any other script, but theBuildDetailsScriptBuilder.Scriptproperty doesn't actually need to be assigned at runtime (and can't be becauseMonoScriptdoesn't exist at runtime).
- In this case, that's the
- The
BuildDetailsScriptBuilderclass inherits fromSimpleScriptBuilderto utilise its ability to automatically gather the reflectionFieldInfoof the existing fields. This allows it to easily get the existingBuildNumberand increment it when regenerating the script during a build.