Restrictions on Collections & Types
This page lists everything that is currently not supported in T#
T# does not fully support complex C# data types like Dictionary
, List<T>
, or user-defined script collections.This section lists the type system differences and shows how to work with Terra-compatible collections instead
๐งพ Dictionaries
In Unity, Dictionary<TKey, TValue>
is used to store and quickly access data using keys โ it's a common tool for lookups, mapping, and efficient access patterns. This pattern is not supported in T#.
๐ What you instead need to do in T# to use key-value pairs:
Use TerraDictionary
, which is interpreter-compatible.
๐ Lists
In Unity, List<T>
is the go-to for dynamic arrays โ it's used to manage growing or shrinking collections of elements like GameObjects, positions, and more. This approach is not supported in T#.
๐ What you instead need to do in T# to work with dynamic collections:
Use TerraList
, which works the same way but is compatible with T#.
๐ฆ Structs in TerraList
In Unity, structs are often used for lightweight data containers, and itโs common to store them in collections. This is not supported in T#.
๐ What you instead need to do in T#:
Avoid storing custom structs in TerraList
.Only primitive types (like int
, float
, bool
) or supported objects (e.g., GameObject
) should be added.
๐งฉ Custom Scripts in Collections
In Unity, it's common to store custom script instances inside List<T>
or Dictionary<TKey, TValue>
for managing multiple game behaviors. This is not supported in T#.
๐ What you instead need to do in T#:
Use GameObject
references and access the components as needed.
๐งฎ LINQ Libraries
Unity developers often use LINQ (.Where()
, .ToList()
, etc.) for elegant data filtering and querying collections. This is not supported in T#.
๐ What you instead need to do in T#: Use traditional loops to filter or transform data.
Last updated