Game.Prefabs.UITagPrefabBase
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: abstract class
Base: PrefabBase
Summary:
A base prefab class used for UI tag prefabs. Provides a public optional string override that, when set, is used as the UI tag instead of any generated tag. Ensures that any prefab derived from this class includes the UITagPrefabData component in its prefab component set. This class is intended for use in modding Cities: Skylines 2 to create UI-related prefab data that other systems can read or write via the ECS ComponentType system.
Fields
public string m_Override
A public, optionally null string that, if assigned, will be used as the UI tag rather than a generated tag. Marked with a Tooltip for the inspector and [CanBeNull] to indicate it may be null. Typical use is to provide an explicit tag name for UI elements created from this prefab.
Properties
- This class does not declare any properties.
Constructors
- This class does not declare any explicit constructors. It uses the default parameterless constructor inherited from its base class.
Methods
public override void GetPrefabComponents(HashSet<ComponentType> prefabComponents)
Overrides PrefabBase.GetPrefabComponents to add required ECS component types for this prefab. The implementation calls the base method and then ensures the UITagPrefabData component is included by addingComponentType.ReadWrite<UITagPrefabData>()
to the provided set. Parameter:HashSet<ComponentType> prefabComponents
— the collection of component types to populate for the prefab.
Usage Example
// Example derived prefab that sets a manual UI tag via the inspector
public class MyButtonTagPrefab : UITagPrefabBase
{
// You can set this value in the inspector to override the generated tag
// public string m_Override = "MyCustomButtonTag";
// No need to override GetPrefabComponents unless you want to add more components.
// The base implementation already adds UITagPrefabData.
}
{{ Additional notes: - The class depends on UITagPrefabData (an ECS component data type). Ensure that type exists and is registered where appropriate. - The presence of m_Override allows designers to avoid relying on generated tag naming conventions; code that resolves UI tags should check this field first. - Because this class inherits from PrefabBase, lifecycle and prefab registration behavior are controlled by that base class and game-specific prefab systems. }}