Game.Prefabs.ToolError
Assembly: Game
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Prefab component that represents a tool-related error notification. Exposes an ErrorType and boolean flags that control whether the notification is temporary and whether it should be disabled in gameplay or in the editor. During prefab initialization it writes a ToolErrorData component to the entity with the selected error and combined ToolErrorFlags. This component is annotated with a ComponentMenu placing it under "Notifications/" and referencing NotificationIconPrefab.
Fields
-
public Game.Tools.ErrorType m_Error
Specifies the error type to be written into ToolErrorData.m_Error. ErrorType is defined in Game.Tools. -
public bool m_TemporaryOnly
If true, sets the ToolErrorFlags.TemporaryOnly flag on the ToolErrorData written to the entity. -
public bool m_DisableInGame
If true, sets the ToolErrorFlags.DisableInGame flag on the ToolErrorData written to the entity. -
public bool m_DisableInEditor
If true, sets the ToolErrorFlags.DisableInEditor flag on the ToolErrorData written to the entity.
Properties
- None.
This component exposes only public fields; there are no CLR properties.
Constructors
public ToolError()
Implicit default parameterless constructor (not explicitly declared in source).
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the runtime component that this prefab will provide to created entities. Implementation adds ComponentType.ReadWrite() so the entity receives a writable ToolErrorData component. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Empty implementation — this prefab does not contribute additional archetype-level components beyond what GetPrefabComponents provides. -
public override void Initialize(EntityManager entityManager, Entity entity)
Initializes the entity's ToolErrorData from the prefab fields: - Creates a ToolErrorData instance and sets m_Error from the prefab's m_Error.
- Builds m_Flags by OR-ing ToolErrorFlags.TemporaryOnly, ToolErrorFlags.DisableInGame and/or ToolErrorFlags.DisableInEditor depending on the corresponding boolean fields.
- Writes the ToolErrorData to the entity via entityManager.SetComponentData(entity, componentData).
Notes: - ToolErrorData and ToolErrorFlags are used to represent the runtime data/flags; they are written as a component to the EntityManager during initialization. - The class is decorated with: [ComponentMenu("Notifications/", new Type[] { typeof(NotificationIconPrefab) })] which places it in the editor component menu under "Notifications/" and references NotificationIconPrefab.
Usage Example
// Example of the component's Initialize behavior (simplified)
public override void Initialize(EntityManager entityManager, Entity entity)
{
base.Initialize(entityManager, entity);
ToolErrorData componentData = default(ToolErrorData);
componentData.m_Error = m_Error;
componentData.m_Flags = (ToolErrorFlags)0;
if (m_TemporaryOnly)
{
componentData.m_Flags |= ToolErrorFlags.TemporaryOnly;
}
if (m_DisableInGame)
{
componentData.m_Flags |= ToolErrorFlags.DisableInGame;
}
if (m_DisableInEditor)
{
componentData.m_Flags |= ToolErrorFlags.DisableInEditor;
}
entityManager.SetComponentData(entity, componentData);
}
{{ Additional notes: Typically used on prefab GameObjects that represent notification icons. Ensure ToolErrorData, ToolErrorFlags and Game.Tools.ErrorType definitions are available in the runtime code so the written component matches expected ECS systems that process tool errors. }}