AssetGenerator Class


[Editor-Only] Base class for systems which manage aspects of procedural asset generation that are unique to certain asset types: determining the asset path, finding and invoking the generator method, and saving the generated asset.
graph BT Type-->Base0["Object"] Type["AssetGenerator"] class Type type-node Derived0["PrefabGenerator"]-->Type click Derived0 "/weaver/api/Weaver.Editor.Procedural/PrefabGenerator" Derived1["TextGenerator"]-->Type click Derived1 "/weaver/api/Weaver.Editor.Procedural/TextGenerator" Derived2["TextureGenerator"]-->Type click Derived2 "/weaver/api/Weaver.Editor.Procedural/TextureGenerator" Derived3["AssetListGenerator"]-->Type click Derived3 "/weaver/api/Weaver.Editor.Procedural/AssetListGenerator"


public class AssetGenerator


Type Description
AssetGeneratorAttribute [Editor-Only] Specifies which asset type can be generated by the attributed class (which must inherit from Weaver.Editor.Procedural.AssetGenerator).


Name Value Summary
DefaultFileExtension string
GeneratorMethodParameterTypes Type[]
The parameter types of a generator method for this asset type. When overriding this property, consider using Weaver.ReflectionUtilities.OneType(System.Type) or Weaver.ReflectionUtilities.TwoTypes(System.Type,System.Type).
GeneratorMethodReturnType Type
The default return type for generator methods used by this generator.
HowToCancel string
Explains how to cancel the generation of an asset (for Weaver.Editor.Procedural.AssetGenerator.AppendFullDescription(System.Text.StringBuilder)).


Name Value Summary
AddItemsToMenu(GenericMenu, ProceduralAsset) void
Populates `menu` with various items for the context menu of `asset`.
AppendFullDescription(StringBuilder) void
Appends the full description of this Weaver.Editor.Procedural.AssetGenerator and how it is to be used.
Destroy(Object) void
Destroys the specified `obj`.
GetAssetPathAndDestroyOldSubAssets(ProceduralAsset) string
Gets the asset path of the existing asset and destroys all of its sub-assets.
GetGeneratorMethod(MemberInfo) MethodInfo
Attempts to find the generator method assofiated with `assetField`.
GetGeneratorMethod(MemberInfo, string) MethodInfo
Finds the generator method associated with a particular procedural asset.
GetMethod(MemberInfo, string, Type[]) MethodInfo
Finds the generator method associated with a particular procedural asset.
InvokeGeneratorMethod(ProceduralAsset) Object
Invokes `asset.GeneratorMethod` with the correct parameters for this Weaver.Editor.Procedural.AssetGenerator.
Save(Object, string, bool) void
Saves `obj` as an asset file at `assetPath`. If successful, the `obj` is destroyed and the reference is replaced with the newly saved asset.
SaveDefaultAsset(string) void
Creates and saves an empty default asset to save sub assets inside while the asset is still generating.
UseTempScene(ProceduralAsset) bool
Indicates whether a temporary scene should be opened while generating the specified `asset`. Default is false.
ValidateGeneratorReturnType(Type) bool
Checks if return type of a generator method is valid for this generator type.