Skip to content

WatchSchema

WatchSchema class is used by the Generator to declare and describe types for generation

Generate

protected WatchVariableDescriptor Generate(Type type)
Adds the specified type type to the generator. This method should be called from the OnGenerate() method. It returns an instance ofWatchVariableDescriptor, which can be utilized to specify which fields should be generated or excluded.

protected WatchVariableDescriptor Generate<T>()
This is the generic version of the Generate(Type) method.

Define

protected WatchVariableDescriptor Define(Type type, bool withInheritors = true)
Adds a type type definition to the schema. This method functions similarly to Generate but does not add the target type to the generator; it only stores the type description. This is useful for inherited classes, as all definitions from the base class are applied to derived classes. withInheritors parameter determines whether this definition applies to all inheritors of the type. If set to false, only the type itself will be affected. This method should be called from the OnDefine() method.

protected WatchVariableDescriptor Define<T>(bool withInheritors = true)
This is the generic version of the Define(Type, bool) method.

OnDefine

public virtual void OnDefine()
This method allows you to override or add new type definitions. By default, OnDefine() includes several predefined definitions. For instance, it contains a definition for MonoBehaviour to exclude all its members, and definitions for basic Unity types like Vector3, which only includes the fields x, y, and z. You can modify this behavior by overriding this method and adding a new Define for the target type.

OnGenerate

public virtual void OnGenerate()
In this method, you can declare your generated types. If a target type was previously described by Define or if multiple descriptors for the same type exist, a merging algorithm will be applied. Merging prioritizes the descriptor of an inherited class over the base class. Therefore, if a field is ignored in the base class descriptor but allowed in the derived class descriptor, it will be visible in the generated derived type while remaining hidden in the base class.