Game.Prefabs.MeshLayer
Assembly: Assembly-CSharp (game code)
Namespace: Game.Prefabs
Type: public enum (flags)
Base: System.Enum (underlying type: System.UInt16)
Summary:
MeshLayer is a flagged enum used to classify mesh rendering layers for prefabs (mesh objects) in the game. Each value is a bit flag (stored as a ushort) that can be combined to represent one or more rendering layers. The enum includes aliases (First and Last) to indicate the valid range of defined layer bits. Typical uses include controlling rendering order, grouping for batching, visibility checks, and masking operations in rendering or prefab code.
Fields
-
Default = 1
Represents the default mesh layer. Alias also defined asFirst
. Value: 0x0001. -
Moving = 2
Used for moving objects/meshes (e.g., vehicles or animated parts). Value: 0x0002. -
Tunnel = 4
Layer used for tunnels or tunnel-specific geometry. Value: 0x0004. -
Pipeline = 8
Pipeline layer used for pipe meshes. Value: 0x0008. -
SubPipeline = 0x10
Sub-pipeline layer (next-level pipeline grouping). Value: 0x0010 (decimal 16). -
Waterway = 0x20
Waterway layer for water-related meshes. Value: 0x0020 (decimal 32). -
Outline = 0x40
Outline layer commonly used for selection/highlight outlines. Value: 0x0040 (decimal 64). -
Marker = 0x80
Marker layer for special markers or gizmos. Value: 0x0080 (decimal 128). Alias also defined asLast
. -
First = 1
Alias for the first (lowest) defined layer bit =Default
. Useful when iterating or validating a range. -
Last = 0x80
Alias for the last (highest) defined layer bit =Marker
. Useful when iterating or validating a range.
Properties
- This enum type does not declare properties. Use bitwise operations or Enum utility methods when interacting with values.
Constructors
- Enums have no explicit constructors in source. Values are created implicitly; you can cast from the underlying type (ushort) or parse from strings:
- Casting example:
MeshLayer l = (MeshLayer)0x10;
- Parsing example:
MeshLayer l = (MeshLayer)Enum.Parse(typeof(MeshLayer), "Pipeline");
Methods
- No instance methods are declared on the enum type. Use standard Enum static helpers and bitwise operators:
- Enum methods: Enum.GetValues, Enum.GetNames, Enum.Parse, Enum.TryParse, Enum.HasFlag (instance)
- Bitwise checks:
(value & MeshLayer.Moving) != 0
(recommended for performance over Enum.HasFlag)
Usage Example
// Combine flags
MeshLayer layers = MeshLayer.Default | MeshLayer.Outline;
// Check membership (fast bitwise form)
bool hasOutline = (layers & MeshLayer.Outline) != 0;
// Using HasFlag (slower boxed call but readable)
bool isDefault = layers.HasFlag(MeshLayer.Default);
// Iterating through defined flags
foreach (MeshLayer flag in Enum.GetValues(typeof(MeshLayer)))
{
if (flag == MeshLayer.First || flag == MeshLayer.Last) continue; // skip range aliases if desired
if ((layers & flag) != 0)
{
// handle flag
}
}
// Convert to underlying numeric value
ushort raw = (ushort)layers;
// Parsing from string
if (Enum.TryParse<MeshLayer>("Pipeline,Waterway", out MeshLayer parsed))
{
// parsed is Pipeline | Waterway
}
Additional notes: - Because the enum is marked with [Flags], multiple values can be combined and ToString() will produce comma-separated names for combined flags. - Prefer explicit bitwise checks for performance-critical code instead of Enum.HasFlag. - Use the First/Last aliases if you need to programmatically detect or iterate the range of defined layer bits.