Class StateSettings
Configuration asset that defines component states and LOD (Level of Detail) settings for vehicle optimization. Controls which vehicle components are active at different performance levels and distances from the camera.
Namespace: NWH.VehiclePhysics2
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
[CreateAssetMenu(fileName = "NWH Vehicle Physics 2", menuName = "NWH/Vehicle Physics 2/State Settings", order = 1)]
public class StateSettings : ScriptableObject
Remarks
StateSettings provides a centralized configuration system for managing vehicle component states and performance optimization through LOD management. It allows you to create different performance profiles for various platforms and scenarios, enabling fine-tuned control over which systems are active.
Key features include: - Component enable/disable states for each LOD level - Distance-based LOD switching for automatic performance scaling - Per-component initialization and runtime state management - Shared settings between multiple vehicles for consistent behavior - Platform-specific optimization profiles
LOD levels typically range from 0 (highest detail) to higher numbers (lower detail). At LOD 0, all components might be active for maximum realism. At higher LODs, non-essential effects and sounds are disabled to maintain performance with multiple vehicles on screen. Create different StateSettings assets for different vehicle types or performance targets.
Fields
LODs
List of LOD (Level of Detail) configurations. LODs are typically ordered from 0 (highest detail/closest) to higher numbers (lower detail/farther). Each LOD defines a distance threshold at which the vehicle switches detail levels.
Declaration
public List<LOD> LODs
Field Value
| Type | Description |
|---|---|
| List<LOD> |
definitions
List of state definitions for all VehicleComponents. Each definition controls whether a component is enabled and at which LOD level it operates. Automatically populated with all available VehicleComponent types in the project.
Declaration
public List<StateDefinition> definitions
Field Value
| Type | Description |
|---|---|
| List<StateDefinition> |
Properties
LODCount
Gets the number of LOD levels defined in this StateSettings. The count is cached after first access for performance.
Declaration
public int LODCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
GetDefinition(string)
Retrieves the StateDefinition for a specific VehicleComponent type.
Declaration
public StateDefinition GetDefinition(string fullComponentTypeName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fullComponentTypeName | The fully qualified type name of the component (e.g., "NWH.VehiclePhysics2.Sound.SoundManager"). |
Returns
| Type | Description |
|---|---|
| StateDefinition | The StateDefinition for the specified component, or null if not found. |
Reload()
Refreshes the definitions list by scanning all assemblies for VehicleComponent types. Adds new definitions for any newly discovered components and removes definitions for components that no longer exist. Can be triggered manually in the editor via the Refresh button.
Declaration
public void Reload()
ValidateLODOrder()
Validates that LOD distances are in ascending order (lowest to highest). Logs a warning if the order is incorrect.
Declaration
public bool ValidateLODOrder()
Returns
| Type | Description |
|---|---|
| bool | True if LOD distances are correctly ordered, false otherwise. |