UnrealSharp
  • Home
  • FAQ
  • Getting Started
    • Setup
    • Your First Script
    • Debugging
    • Packaging
  • Documentation
    • Classes
      • Properties
        • C++ Functions As C# Properties
        • C++ Properties with Getters/Setters
      • Functions
        • Flags
        • MetaData
      • Default Actor Components
      • Helper Methods
    • Structs
    • Enums
    • Interfaces
    • Delegates
    • Collections
      • TArray
      • TNativeArray
      • TSet
      • TMap
    • Multiplayer
      • Replicated Properties
      • RPCs (Remote Procedure Calls)
      • Replicated UObjects
    • Primary Data Assets
      • Loading Primary Data Assets
    • Loading Soft References
    • Trace Channels
    • Static Variables
      • FWorldStaticVar<T>
      • FGameStaticVar<T>
    • Logging
    • Async
    • Gameplay Tags
      • Gameplay Tag Container
    • Extension / Mixin Methods
    • Subsystems
    • Module Lifecycle
  • Links
    • Github Repository
    • Roadmap
    • Discord
Powered by GitBook
On this page
  1. Documentation
  2. Collections

TMap

TMaps are defined by two types, a key type and a value type, which are stored as associated pairs in the map.

Example of using a TMap as a UProperty

[UClass]
public class AMyShowcaseClass : AActor
{
    [UProperty(PropertyFlags.EditAnywhere | PropertyFlags.BlueprintReadWrite)]
    public TMap<int, string> MyMap { get; set; }

    protected override void BeginPlay()
    {
        base.BeginPlay();

        MyMap.Add(1, "First Value");
        MyMap.Add(2, "Second Value");

        UpdateMapWithKey(2, "Updated Second Value");
    }    
}

TMap can also be represented as an IDictionary inside of a UFunction

[UFunction(FunctionFlags.BlueprintCallable)]
public void TestDictionary(IDictionary<string, string> MyDict)
{
    PrintString($"Dictionary Key Count: {MyDict.Keys.Count}");
}
PreviousTSetNextMultiplayer

Last updated 6 months ago