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
Script
property andGenerateScript
method. - Unlike the Building example, the asset type here is
MonoScript
which means that the generator method needs to take aStringBuilder
parameter instead of returning the asset type as shown in the Asset Generators table. - Since
MonoScript
is an editor-only type, the[ProceduralAsset]
attribute automatically hasEditorOnly
set to true. The script is generated and gets compiled into a build like any other script, but theBuildDetailsScriptBuilder.Script
property doesn't actually need to be assigned at runtime (and can't be becauseMonoScript
doesn't exist at runtime).
- In this case, that's the
- The
BuildDetailsScriptBuilder
class inherits fromSimpleScriptBuilder
to utilise its ability to automatically gather the reflectionFieldInfo
of the existing fields. This allows it to easily get the existingBuildNumber
and increment it when regenerating the script during a build.