menu_bookDocumentation
ComponentFlags: Hidden, NotSaved, NotNetworked, NotCloned — Controlling Component Behavior
ComponentFlags: Controlling Component Serialization, Networking, and Visibility
ComponentFlags is a flags enum on Component.Flags that controls how a component behaves in the editor, serialization, and networking.Values
| Flag | Value | Effect |
|---|---|---|
| Hidden | 1 | Hide this component in the component inspector |
| NotSaved | 2 | Don't save this component to disk |
| Error | 4 | Marks the component as having an error |
| Loading | 8 | Component is loading (not fully implemented) |
| Deserializing | 16 | Component is currently being deserialized |
| NotEditable | 32 | Cannot be edited in the inspector (not fully implemented) |
| NotNetworked | 64 | Keep local — don't include this component in the scene snapshot |
| NotCloned | 256 | Don't serialize this component when cloning the GameObject |
| ShowAdvancedProperties | 512 | Show advanced properties in the inspector |
Usage
CSHARP
// Hide a component from the inspector (e.g., internal helper component)
Flags |= ComponentFlags.Hidden;
// Prevent a component from being networked as part of the scene snapshot
Flags |= ComponentFlags.NotNetworked;
// Prevent a component from being included when the GameObject is cloned
Flags |= ComponentFlags.NotCloned;
// Don't save this component to disk
Flags |= ComponentFlags.NotSaved;Important: NotNetworked
ComponentFlags.NotNetworked prevents the component from being included in the scene snapshot sent to clients. This is useful for server-only components or components that manage local state that shouldn't be replicated.Note: This only affects NetworkMode.Snapshot objects. For NetworkMode.Object objects, [Sync] properties control what is synchronized.
Was this helpful?