Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


NativeText

An unmanaged, mutable, resizable UTF-8 string.
Read time 4 minutesLast updated 7 days ago

Definition

public struct NativeText : INativeList<byte>, IIndexable<byte>, INativeDisposable, IDisposable, IUTF8Bytes, IComparable<string>, IEquatable<string>, IComparable<NativeText>, IEquatable<NativeText>, IComparable<FixedString32Bytes>, IEquatable<FixedString32Bytes>, IComparable<FixedString64Bytes>, IEquatable<FixedString64Bytes>, IComparable<FixedString128Bytes>, IEquatable<FixedString128Bytes>, IComparable<FixedString512Bytes>, IEquatable<FixedString512Bytes>, IComparable<FixedString4096Bytes>, IEquatable<FixedString4096Bytes>

Remarks

The string is always null-terminated, meaning a zero byte always immediately follows the last character.

Static Fields

Value

Description

MaxCapacityThe maximum number of elements this type of container can hold.

Constructors

Constructor

Description

NativeText(System.Int32,Unity.Collections.Allocator)Initializes and returns an instance of NativeText.
NativeText(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(System.String,Unity.Collections.Allocator)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(System.String,Unity.Collections.AllocatorManager.AllocatorHandle)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(Unity.Collections.Allocator)Initializes and returns an instance of NativeText with an initial capacity of 512 bytes.
NativeText(Unity.Collections.AllocatorManager.AllocatorHandle)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(Unity.Collections.FixedString128Bytes@,Unity.Collections.Allocator)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(Unity.Collections.FixedString128Bytes@,Unity.Collections.AllocatorManager.AllocatorHandle)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(Unity.Collections.FixedString32Bytes@,Unity.Collections.Allocator)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(Unity.Collections.FixedString32Bytes@,Unity.Collections.AllocatorManager.AllocatorHandle)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(Unity.Collections.FixedString4096Bytes@,Unity.Collections.Allocator)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(Unity.Collections.FixedString4096Bytes@,Unity.Collections.AllocatorManager.AllocatorHandle)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(Unity.Collections.FixedString512Bytes@,Unity.Collections.Allocator)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(Unity.Collections.FixedString512Bytes@,Unity.Collections.AllocatorManager.AllocatorHandle)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(Unity.Collections.FixedString64Bytes@,Unity.Collections.Allocator)Initializes and returns an instance of NativeText with the characters copied from another string.
NativeText(Unity.Collections.FixedString64Bytes@,Unity.Collections.AllocatorManager.AllocatorHandle)Initializes and returns an instance of NativeText with the characters copied from another string.

Properties

Property

Description

CapacityThe current capacity in bytes of this string.
IsCreatedWhether this string's character buffer has been allocated (and not yet deallocated).
IsEmptyWhether this string has no characters.
this[]The byte at an index. Note that writing to a NativeText.Readonly is not supported; the setter of this property throws when safety checks are enabled.
LengthThe current length in bytes of this string.
ValueA copy of this string as a managed string.

Methods

Method

Description

AddAppends a byte.
AsReadOnlyReturns a readonly version of this NativeText instance.
ClearSets the length to 0.
CompareToReturns the lexicographical sort order of this string relative to another.
DisposeReleases all resources (memory and safety handles).
ElementAtReturns a reference to the byte (not character) at an index.
EqualsReturns true if this string and another object are equal.
GetEnumeratorReturns an enumerator for iterating over the characters of the NativeText.
GetHashCodeReturns a hash code of this string.
GetUnsafePtrReturns a pointer to this string's character buffer.
ToStringReturns a managed string copy of this string.
TryResizeAttempt to set the length in bytes of this string.

Operators

Operator

Description

operator ==Returns true if two strings are equal.
operator !=Returns true if two strings are unequal.

Structs

Struct

Description

NativeText.EnumeratorAn enumerator over the characters (not bytes) of a NativeText.
NativeText.ReadOnlyA read-only alias for the value of a NativeText. Does not have its own allocated storage.