Class ModuleWrapper
Abstract MonoBehaviour wrapper that enables module serialization and inspector editing. Since modules themselves are serialized classes that cannot be directly attached as components, this wrapper pattern allows modules to be added to GameObjects and configured in the Unity Inspector. Each module type has its own concrete wrapper implementation that stores and manages the module instance.
Inheritance
ModuleWrapper
Namespace: NWH.VehiclePhysics2.Modules
Assembly: NWH.VehiclePhysics2.dll
Syntax
[RequireComponent(typeof(VehicleController))]
[Serializable]
[DefaultExecutionOrder(200)]
public abstract class ModuleWrapper : MonoBehaviour
Remarks
To create a custom module:
- Create a class deriving from VehicleComponent (your module logic)
- Create a wrapper class deriving from ModuleWrapper
- Implement GetModule() and SetModule() methods
- Add the wrapper component to a VehicleController GameObject
Methods
GetModule()
Returns the module instance managed by this wrapper.
Declaration
public abstract VehicleComponent GetModule()
Returns
| Type | Description |
|---|---|
| VehicleComponent | The VehicleComponent module instance. |
SetModule(VehicleComponent)
Sets the module instance to be managed by this wrapper.
Declaration
public abstract void SetModule(VehicleComponent vehicleComponent)
Parameters
| Type | Name | Description |
|---|---|---|
| VehicleComponent | vehicleComponent | The VehicleComponent module to assign. |