ItemGlassesAsset — Glasses Clothing Definition
Overview
ItemGlassesAsset is the most functionally complex clothing subclass. It defines wearable glasses/eyewear items in Unturned with a full vision system supporting headlamps, two tiers of night vision, and blindfold mechanics. It inherits from ItemGearAsset (hair/beard override), which inherits from ItemClothingAsset (armor, proof system), which inherits from ItemAsset.
Glasses occupy the EItemType.GLASSES slot. They are not eligible for armor damage reduction. Their primary gameplay value comes from the vision system: headlamps provide a player-attached spot light, Civilian NVG provides grayscale night vision, and Military NVG provides green-tinted night vision. The blindfold flag enables the blindfold gameplay mechanic.
Glasses override the cosmetic priority system: when night vision or blindfold is active, the real glasses take priority over cosmetic glasses to ensure the NVG green glow or blindfold visual is visible.
Source code location: Unturned/Bundles/ItemGlassesAsset.cs (127 lines), inheriting from ItemGearAsset.cs (88 lines), ItemClothingAsset.cs (304 lines), and ItemAsset.cs (base).
Inheritance Chain
ItemAsset
└─ ItemClothingAsset (abstract) — armor (not applied to GLASSES), proof, movement, visuals
└─ ItemGearAsset (abstract) — hair/beard override
└─ ItemGlassesAsset — vision system, blindfold, cosmetic priority overrideClass Definition
csharp
public class ItemGlassesAsset : ItemGearAsset
{
protected GameObject _glasses;
public GameObject glasses => _glasses;
private ELightingVision _vision;
public ELightingVision vision => _vision;
public Color nightvisionColor;
public float nightvisionFogIntensity;
public PlayerSpotLightConfig lightConfig { get; protected set; }
public bool isBlindfold { get; protected set; }
public bool isNightvisionAllowedInThirdPerson { get; protected set; }
public override byte[] getState(EItemOrigin origin) { ... }
public override void PopulateAsset(in PopulateAssetParameters p) { ... }
internal override void BuildCargoData(CargoBuilder builder) { ... }
protected override bool GetDefaultTakesPriorityOverCosmetic() { ... }
internal override GameObject ClothingPrefab => glasses;
}Vision System
ELightingVision Enum
The vision mode is selected by the Vision .dat key:
| .dat Value | Enum | Effect |
|---|---|---|
| (absent) | ELightingVision.NONE | No vision effect — standard glasses |
Headlamp | ELightingVision.HEADLAMP | Player-attached spotlight |
Civilian | ELightingVision.CIVILIAN | Grayscale night vision |
Military | ELightingVision.MILITARY | Green-tinted night vision |
Vision Parsing
csharp
if (p.data.ContainsKey("Vision"))
{
_vision = (ELightingVision) System.Enum.Parse(typeof(ELightingVision),
p.data.GetString("Vision"), true);
// ... mode-specific configuration
}
else
{
_vision = ELightingVision.NONE;
}The true parameter on Enum.Parse enables case-insensitive parsing. Both "headlamp" and "Headlamp" work.
Headlamp Mode
When Vision is Headlamp, a PlayerSpotLightConfig is constructed from the data dictionary:
csharp
if (vision == ELightingVision.HEADLAMP)
{
lightConfig = new PlayerSpotLightConfig(p.data);
}The PlayerSpotLightConfig class (defined elsewhere in the SDK) reads spot light parameters from the .dat dictionary: range, spot angle, intensity, color, cookie texture, etc. This allows modders to configure the headlamp's light behavior per-glasses-item.
Civilian Night Vision
csharp
else if (vision == ELightingVision.CIVILIAN)
{
nightvisionColor = p.data.LegacyParseColor32RGB("Nightvision_Color",
defaultValue: LevelLighting.NIGHTVISION_CIVILIAN);
nightvisionFogIntensity = p.data.ParseFloat("Nightvision_Fog_Intensity",
defaultValue: 0.5f);
nightvisionColor.g = nightvisionColor.r;
nightvisionColor.b = nightvisionColor.r;
}| Parameter | Detail |
|---|---|
| Default color | LevelLighting.NIGHTVISION_CIVILIAN (gray) |
| Color force | R=G=B enforced — forced to grayscale |
| Fog intensity default | 0.5 |
The color is forced to grayscale because the Civilian NVG post-processing filter is grayscale. Setting R, G, or B differently would have no visual effect — the post-processing strip color away.
Military Night Vision
csharp
else if (vision == ELightingVision.MILITARY)
{
nightvisionColor = p.data.LegacyParseColor32RGB("Nightvision_Color",
defaultValue: LevelLighting.NIGHTVISION_MILITARY);
nightvisionFogIntensity = p.data.ParseFloat("Nightvision_Fog_Intensity",
defaultValue: 0.25f);
}| Parameter | Detail |
|---|---|
| Default color | LevelLighting.NIGHTVISION_MILITARY (green) |
| Color | Full RGB — military NVG renders in color |
| Fog intensity default | 0.25 (less fog than civilian) |
Military NVG does not force grayscale, allowing colored night vision effects.
Nightvision in Third Person
csharp
isNightvisionAllowedInThirdPerson = p.data.ParseBool("Nightvision_Allowed_In_ThirdPerson");| .dat Key | Type | Default | Effect |
|---|---|---|---|
Nightvision_Allowed_In_ThirdPerson | bool | false | Enables NVG effect in third-person camera |
By default, night vision only works in first-person. Setting this to true allows NVG to function in third-person view as well.
Blindfold System
csharp
isBlindfold = p.data.ContainsKey("Blindfold");| .dat Key | Type | Default | Effect |
|---|---|---|---|
Blindfold | flag | — | Enables blindfold gameplay mechanic |
When isBlindfold is true:
- The player's screen is obscured (blindfold effect)
- The glasses item type is treated as a blindfold in the gameplay systems
- The blindfold can be toggled or removed via interaction
The blindfold is a gameplay mechanic, not purely cosmetic. It is used in certain game modes, roleplay servers, and puzzle scenarios where players need to voluntarily or involuntarily lose vision.
getState — Interact State Byte
Glasses with vision modes provide an interact state:
csharp
public override byte[] getState(EItemOrigin origin)
{
if (vision != ELightingVision.NONE)
{
return new byte[1] { 1 };
}
else
{
return new byte[0];
}
}| Vision | State array | Meaning |
|---|---|---|
NONE | new byte[0] (empty) | No interactable state — glasses are passive |
HEADLAMP, CIVILIAN, MILITARY | new byte[1] { 1 } | Interact state = active (enables toggle interaction) |
The 1-byte state with value 1 indicates the glasses are active (headlamp on, NVG active). This enables the toggle interaction: players can press the interact key to turn the headlamp or NVG on/off. The game's interaction system reads this byte to determine the current state and provides the toggle UI accordingly.
Cosmetic Priority Override
Glasses override the default cosmetic priority based on functional state:
csharp
protected override bool GetDefaultTakesPriorityOverCosmetic()
{
return vision != ELightingVision.NONE || isBlindfold;
}| Condition | Priority override | Reason |
|---|---|---|
| Vision mode active (Headlamp, NVG) | true | NVG green glow must be visible |
| Blindfold active | true | Blindfold visual must be visible |
| Standard glasses | false | Cosmetic can override |
This is the only clothing subclass that overrides GetDefaultTakesPriorityOverCosmetic. The override ensures that functionally important visual effects are never hidden by cosmetic glasses. For example, if a player equips military NVG and a cosmetic pair of party glasses, the NVG takes priority and its green glow is visible.
Glasses Prefab Loading
csharp
if (!Dedicator.IsDedicatedServer)
{
_glasses = loadRequiredAsset<GameObject>(p.bundle, "Glasses");
if (Assets.shouldValidateAssets)
{
AssetValidation.ValidateLayersEqual(this, _glasses, LayerMasks.ENEMY);
AssetValidation.ValidateClothComponents(this, _glasses);
}
}Standard clothing prefab loading pattern. The ClothingPrefab override returns the glasses GameObject:
csharp
internal override GameObject ClothingPrefab => glasses;Left-Handed Model Mirroring Note
The source code's shouldMirrorLeftHandedModel property has a specific comment about glasses:
Left-handed character skeleton is mirrored, so most item models are mirrored again to preserve
appearance. Unfortunately this does not work well for some items e.g. the particle system on
Elver/Dango glasses.Some glasses with asymmetric particle effects set Mirror_Left_Handed_Model false to prevent the particle system from rendering in the wrong orientation on left-handed characters.
Inherited Behavior: ItemClothingAsset
Armor — Not Applied to Glasses
Glasses are excluded from the armor system. The BuildDescription check only includes HAT, SHIRT, PANTS, and VEST.
Wear Audio
Glasses default to the sleeve rustle sound:
csharp
wearAudio = new AudioReference("core.masterbundle", "Sounds/Sleeve.mp3");PRO Behavior
PRO glasses follow standard PRO clothing rules: armor forced to 1.0, cosmetic preview override loaded.
PopulateAsset Call Chain
ItemAsset.PopulateAsset
└─ ItemClothingAsset.PopulateAsset — armor (stored, not applied), proof, movement, visuals
└─ ItemGearAsset.PopulateAsset — hair/beard flags, hair/beard override
└─ ItemGlassesAsset.PopulateAsset
├─ Load "Glasses" prefab (client only)
├─ Vision parsing
│ ├─ NONE: no vision config
│ ├─ HEADLAMP: PlayerSpotLightConfig
│ ├─ CIVILIAN: grayscale color + fog
│ └─ MILITARY: color + fog
├─ Nightvision_Allowed_In_ThirdPerson
└─ Blindfold flagBuildCargoData — Wiki Export
Glasses contribute to three Cargo tables:
Clothing table (from ItemClothingAsset)
Standard clothing columns.
Gear table (from ItemGearAsset)
GUID, Hair, Beard.
Glasses table (dedicated)
csharp
CargoDeclaration data = builder.GetOrAddDeclaration("Glasses");
data.Append("GUID", GUID);
data.Append("Vision", vision);
data.Append("Nightvision_Color", nightvisionColor);
data.Append("Nightvision_Fog_Intensity", nightvisionFogIntensity);
data.Append("Nightvision_Allowed_In_ThirdPerson", isNightvisionAllowedInThirdPerson);
data.Append("Blindfold", isBlindfold);| Column | Source |
|---|---|
GUID | PK, FK to Gear table |
Vision | _vision enum |
Nightvision_Color | nightvisionColor |
Nightvision_Fog_Intensity | nightvisionFogIntensity |
Nightvision_Allowed_In_ThirdPerson | isNightvisionAllowedInThirdPerson |
Blindfold | isBlindfold |
.dat File Reference — Glasses-Specific
| .dat Key | Type | Default | Category |
|---|---|---|---|
Vision | enum | NONE | Vision mode: Headlamp, Civilian, Military |
Nightvision_Color | Color32 | Gray (civilian) / Green (military) | NVG tint color |
Nightvision_Fog_Intensity | float | 0.5 (civilian) / 0.25 (military) | Fog density during NVG |
Nightvision_Allowed_In_ThirdPerson | bool | false | NVG in third-person |
Blindfold | flag | — | Blindfold mechanic |
Armor | float | 1.0 | Stored but NOT applied |
Proof_Water | flag | — | Water breathing |
Proof_Fire | flag | — | Fire immunity |
Proof_Radiation | flag | — | Radiation immunity |
Movement_Speed_Multiplier | float | 1.0 | Movement speed |
Hair_Visible | bool | true | Hair visibility |
Beard_Visible | bool | true | Beard visibility |
Headlamp Configuration — PlayerSpotLightConfig
When Vision Headlamp is set, a PlayerSpotLightConfig is constructed from the data dictionary. The exact fields available depend on the PlayerSpotLightConfig class, but typical .dat keys include:
Typical headlamp .dat keys (consumed by PlayerSpotLightConfig):
SpotLight_Range— Light range in metersSpotLight_Angle— Spot angle in degreesSpotLight_Intensity— Light intensitySpotLight_Color_R/G/B— Light colorSpotLight_Cookie— Optional light cookie texture
These are read inside the PlayerSpotLightConfig constructor, not in ItemGlassesAsset itself.
Modding Example — Basic Sunglasses .dat
ini
GUID a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
Type Glasses
Rarity Common
Size_X 1
Size_Y 1Creates standard sunglasses with no vision mode — purely cosmetic.
Modding Example — Military Night Vision Goggles .dat
ini
GUID f1e2d3c4b5a69788796a5b4c3d2e1f0a
Type Glasses
Rarity Epic
Size_X 2
Size_Y 2
Vision Military
Nightvision_Color 0 255 0 255
Nightvision_Fog_Intensity 0.15
Movement_Speed_Multiplier 0.95Creates military-grade NVG with:
- Green night vision (R=0, G=255, B=0)
- Low fog (0.15 — clearer than default 0.25)
- 5% movement penalty for the heavy goggles
- Toggle interaction enabled via
getState
Modding Example — Headlamp .dat
ini
GUID d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9
Type Glasses
Rarity Uncommon
Size_X 2
Size_Y 1
Vision Headlamp
SpotLight_Range 30
SpotLight_Angle 45
SpotLight_Intensity 2.5Creates a headlamp with:
- 30m range
- 45° spot angle
- 1.5× intensity boost
- Toggle interaction enabled
Modding Example — Blindfold .dat
ini
GUID aabbccdd11223344556677889900aabb
Type Glasses
Rarity Common
Size_X 1
Size_Y 1
BlindfoldCreates a blindfold item for roleplay/puzzle gameplay.
Common Issues
NVG not working in third-person: Set
Nightvision_Allowed_In_ThirdPerson true. By default, NVG only activates in first-person view.Civilian NVG color ignored: Civilian NVG forces R=G=B (grayscale). Setting different RGB values has no visual effect — the post-processing filter strips color.
Headlamp not toggling: The
getStatemethod returns the toggle state byte. If replacing glasses at runtime, ensure the state byte is correctly synchronized between client and server.Cosmetic glasses hiding functional glasses: If a player equips functional glasses (NVG/blindfold) and a cosmetic glasses item, the functional item's
GetDefaultTakesPriorityOverCosmeticreturnstrue, ensuring the NVG glow or blindfold visual is visible.Particle effects on left-handed characters: Some glasses with particle systems (Elver, Dango) need
Mirror_Left_Handed_Model false. Without this, the particle system renders in the wrong orientation on left-handed characters.Nightvision color not applying: Use
Nightvision_Colorwith RGB values. For Civilian NVG, the color is forced to grayscale. For Military NVG, the color is applied as-is.
Document history
| Version | Date | Author | Notes |
|---|---|---|---|
| 1.0 | 2026-07-28 | 57 Studios | Initial publication. Full glasses asset documentation including vision system, headlamp, NVG, blindfold, cosmetic priority, and modding examples. |
