Class Message
A message is a piece of text that can be broken down into multiple sub fragments. A fragment can be writable or read only. A read only fragment indicates that the sub string should be preserved and not modified by ant pseudo methods.
Namespace: UnityEngine.Localization.Pseudo
Syntax
public class Message
Properties
Fragments
A message is comprised of writable and readonly fragments. Readonly fragments are those that should be preserved such as xml/rich text tags.
Declaration
public List<MessageFragment> Fragments { get; }
Property Value
Type | Description |
---|---|
List<MessageFragment> |
Length
Total length of the Message including all Fragments.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
Int32 |
Original
The original text before it was broken into fragments.
Declaration
public string Original { get; }
Property Value
Type | Description |
---|---|
String |
Methods
CreateReadonlyTextFragment(String)
Creates a ReadOnlyMessageFragment which represents string that should be preserved and not modified by any other pseudo methods. Fragments are created using an ObjectPool so they can be reused. Use ReleaseFragment(MessageFragment) to return the fragment or allow the Message to handle returning the fragment if it is part of Fragments.
Declaration
public ReadOnlyMessageFragment CreateReadonlyTextFragment(string original)
Parameters
Type | Name | Description |
---|---|---|
String | original | The source string. |
Returns
Type | Description |
---|---|
ReadOnlyMessageFragment | A new fragment. |
CreateReadonlyTextFragment(String, Int32, Int32)
Creates a ReadOnlyMessageFragment which represents a sub string of the original that should be preserved and not modified by any other pseudo methods. Fragments are created using an ObjectPool so they can be reused. Use ReleaseFragment(MessageFragment) to return the fragment or allow the Message to handle returning the fragment if it is part of Fragments.
Declaration
public ReadOnlyMessageFragment CreateReadonlyTextFragment(string original, int start, int end)
Parameters
Type | Name | Description |
---|---|---|
String | original | Original string |
Int32 | start | Sub string start |
Int32 | end | Sub string end |
Returns
Type | Description |
---|---|
ReadOnlyMessageFragment | A new fragment. |
CreateTextFragment(String)
Creates a new WritableMessageFragment which represents a string. Fragments are created using an ObjectPool so they can be reused. Use ReleaseFragment(MessageFragment) to return the fragment or allow the Message to handle returning the fragment if it is part of Fragments.
Declaration
public WritableMessageFragment CreateTextFragment(string original)
Parameters
Type | Name | Description |
---|---|---|
String | original | The source string. |
Returns
Type | Description |
---|---|
WritableMessageFragment | A new fragment. |
CreateTextFragment(String, Int32, Int32)
Creates a new WritableMessageFragment which represents a sub string of the original. Fragments are created using an ObjectPool so they can be reused. Use ReleaseFragment(MessageFragment) to return the fragment.
Declaration
public WritableMessageFragment CreateTextFragment(string original, int start, int end)
Parameters
Type | Name | Description |
---|---|---|
String | original | Original string |
Int32 | start | Sub string start |
Int32 | end | Sub string end |
Returns
Type | Description |
---|---|
WritableMessageFragment | A new fragment. |
ReleaseFragment(MessageFragment)
Returns a Fragment back to its ObjectPool so it can be used again.
Declaration
public void ReleaseFragment(MessageFragment fragment)
Parameters
Type | Name | Description |
---|---|---|
MessageFragment | fragment |
ReplaceFragment(MessageFragment, MessageFragment)
Replaces the Fragments in Fragments and returns the previous fragment back to the ObjectPool so it can be reused.
Declaration
public void ReplaceFragment(MessageFragment original, MessageFragment replacement)
Parameters
Type | Name | Description |
---|---|---|
MessageFragment | original | Fragment to replace. |
MessageFragment | replacement | Replacement Fragment. |