Skip to content

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 override

Class 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 ValueEnumEffect
(absent)ELightingVision.NONENo vision effect — standard glasses
HeadlampELightingVision.HEADLAMPPlayer-attached spotlight
CivilianELightingVision.CIVILIANGrayscale night vision
MilitaryELightingVision.MILITARYGreen-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;
}
ParameterDetail
Default colorLevelLighting.NIGHTVISION_CIVILIAN (gray)
Color forceR=G=B enforced — forced to grayscale
Fog intensity default0.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);
}
ParameterDetail
Default colorLevelLighting.NIGHTVISION_MILITARY (green)
ColorFull RGB — military NVG renders in color
Fog intensity default0.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 KeyTypeDefaultEffect
Nightvision_Allowed_In_ThirdPersonboolfalseEnables 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 KeyTypeDefaultEffect
BlindfoldflagEnables 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];
    }
}
VisionState arrayMeaning
NONEnew byte[0] (empty)No interactable state — glasses are passive
HEADLAMP, CIVILIAN, MILITARYnew 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;
}
ConditionPriority overrideReason
Vision mode active (Headlamp, NVG)trueNVG green glow must be visible
Blindfold activetrueBlindfold visual must be visible
Standard glassesfalseCosmetic 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 flag

BuildCargoData — 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);
ColumnSource
GUIDPK, FK to Gear table
Vision_vision enum
Nightvision_ColornightvisionColor
Nightvision_Fog_IntensitynightvisionFogIntensity
Nightvision_Allowed_In_ThirdPersonisNightvisionAllowedInThirdPerson
BlindfoldisBlindfold

.dat File Reference — Glasses-Specific

.dat KeyTypeDefaultCategory
VisionenumNONEVision mode: Headlamp, Civilian, Military
Nightvision_ColorColor32Gray (civilian) / Green (military)NVG tint color
Nightvision_Fog_Intensityfloat0.5 (civilian) / 0.25 (military)Fog density during NVG
Nightvision_Allowed_In_ThirdPersonboolfalseNVG in third-person
BlindfoldflagBlindfold mechanic
Armorfloat1.0Stored but NOT applied
Proof_WaterflagWater breathing
Proof_FireflagFire immunity
Proof_RadiationflagRadiation immunity
Movement_Speed_Multiplierfloat1.0Movement speed
Hair_VisiblebooltrueHair visibility
Beard_VisiblebooltrueBeard 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 meters
  • SpotLight_Angle — Spot angle in degrees
  • SpotLight_Intensity — Light intensity
  • SpotLight_Color_R/G/B — Light color
  • SpotLight_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 1

Creates 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.95

Creates 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.5

Creates 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
Blindfold

Creates a blindfold item for roleplay/puzzle gameplay.


Common Issues

  1. NVG not working in third-person: Set Nightvision_Allowed_In_ThirdPerson true. By default, NVG only activates in first-person view.

  2. 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.

  3. Headlamp not toggling: The getState method returns the toggle state byte. If replacing glasses at runtime, ensure the state byte is correctly synchronized between client and server.

  4. Cosmetic glasses hiding functional glasses: If a player equips functional glasses (NVG/blindfold) and a cosmetic glasses item, the functional item's GetDefaultTakesPriorityOverCosmetic returns true, ensuring the NVG glow or blindfold visual is visible.

  5. 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.

  6. Nightvision color not applying: Use Nightvision_Color with RGB values. For Civilian NVG, the color is forced to grayscale. For Military NVG, the color is applied as-is.

Document history

VersionDateAuthorNotes
1.02026-07-2857 StudiosInitial publication. Full glasses asset documentation including vision system, headlamp, NVG, blindfold, cosmetic priority, and modding examples.