InvalidTagCharacters

InvalidTagCharacters

#Overview

name: InvalidTagCharacters

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of InvalidTagCharacters is to define a set of characters that are not allowed to be used in gameplay tags within the Unreal Engine 5 system. This variable is part of the gameplay tag system, which is used for efficient string-based categorization and organization of game elements.

The InvalidTagCharacters setting variable is primarily used by the GameplayTags module in Unreal Engine 5. Specifically, it is utilized by the UGameplayTagsManager and UGameplayTagsSettings classes.

The value of this variable is initially set in the UGameplayTagsSettings constructor, where it is given a default value of “"’,”. This setting can be modified through the project settings in the Unreal Engine editor.

The InvalidTagCharacters variable interacts with other parts of the gameplay tag system, particularly in the tag validation process. It is used in conjunction with the FName::IsValidXName function to determine if a tag string is valid.

Developers must be aware that:

  1. Modifying this variable will affect what characters are considered invalid in gameplay tags across the entire project.
  2. The variable is used in both runtime and editor contexts.
  3. Additional characters (\r\n\t) are appended to this list internally by the UGameplayTagsManager.

Best practices when using this variable include:

  1. Be cautious when modifying the default value, as it may impact existing tags or systems relying on the current set of invalid characters.
  2. When creating new gameplay tags, ensure they don’t contain any of the characters defined in InvalidTagCharacters.
  3. If you need to change the invalid characters, do so early in the project’s development to avoid conflicts with existing tags.
  4. Document any changes to this variable clearly for the development team to maintain consistency in tag creation and usage.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultGameplayTags.ini:6, section: [/Script/GameplayTags.GameplayTagsSettings]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/GameplayTags/Classes/GameplayTagsManager.h:910

Scope (from outer to inner):

file
class        class UGameplayTagsManager : public UObject

Source code excerpt:


	/** String with outlawed characters inside tags */
	FString InvalidTagCharacters;

	// This critical section is to handle an issue where tag requests come from another thread when async loading from a background thread in FGameplayTagContainer::Serialize.
	// This class is not generically threadsafe.
	mutable FCriticalSection GameplayTagMapCritical;

#if WITH_EDITOR

#Loc: <Workspace>/Engine/Source/Runtime/GameplayTags/Classes/GameplayTagsSettings.h:126

Scope (from outer to inner):

file
class        class UGameplayTagsSettings : public UGameplayTagsList

Source code excerpt:

	/** These characters cannot be used in gameplay tags, in addition to special ones like newline*/
	UPROPERTY(config, EditAnywhere, Category = GameplayTags)
	FString InvalidTagCharacters;

	/** Category remapping. This allows base engine tag category meta data to remap to multiple project-specific categories. */
	UPROPERTY(config, EditAnywhere, Category = GameplayTags)
	TArray<FGameplayTagCategoryRemap> CategoryRemapping;

	/** List of data tables to load tags from */

#Loc: <Workspace>/Engine/Source/Runtime/GameplayTags/Private/GameplayTagsManager.cpp:427

Scope (from outer to inner):

file
function     void UGameplayTagsManager::ConstructGameplayTagTree

Source code excerpt:


		// Copy invalid characters, then add internal ones
		InvalidTagCharacters = MutableDefault->InvalidTagCharacters;
		InvalidTagCharacters.Append(TEXT("\r\n\t"));

		// Add prefixes first
		if (ShouldImportTagsFromINI())
		{
			SCOPE_LOG_GAMEPLAYTAGS(TEXT("UGameplayTagsManager::ConstructGameplayTagTree: ImportINI prefixes"));

#Loc: <Workspace>/Engine/Source/Runtime/GameplayTags/Private/GameplayTagsManager.cpp:2078

Scope (from outer to inner):

file
function     bool UGameplayTagsManager::IsValidGameplayTagString

Source code excerpt:


	FText TagContext = LOCTEXT("GameplayTagContext", "Tag");
	if (!FName::IsValidXName(TagString, InvalidTagCharacters, &ErrorText, &TagContext))
	{
		for (TCHAR& TestChar : FixedString)
		{
			for (TCHAR BadChar : InvalidTagCharacters)
			{
				if (TestChar == BadChar)
				{
					TestChar = TEXT('_');
				}
			}

#Loc: <Workspace>/Engine/Source/Runtime/GameplayTags/Private/GameplayTagsSettings.cpp:67

Scope (from outer to inner):

file
function     UGameplayTagsSettings::UGameplayTagsSettings

Source code excerpt:

	AllowEditorTagUnloading = true;
	AllowGameTagUnloading = false;
	InvalidTagCharacters = ("\"',");
	NumBitsForContainerSize = 6;
	NetIndexFirstBitSegment = 16;
}

#if WITH_EDITOR
void UGameplayTagsSettings::PreEditChange(FProperty* PropertyThatWillChange)