Class ModuleWrapper
Abstract MonoBehaviour wrapper for module serialization and Unity Inspector editing. Modules are serialized classes that cannot be attached directly to GameObjects. Each module type has a concrete wrapper that attaches to a GameObject and 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(); the serialized module field must be named "module" - the shared inspector resolves it by that name
- 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. |