Class BasicText
Places a simple text object on the screen and keeps it there until either hidden (or a designated fade-to-black timer has passed). By default uses the same font/size/color as the "Press Any Button To Begin" message at the beginning of the game, and appears centered about 1/3 down the screen, but all parameters can be reconfigured.
public class BasicText
- Inheritance
-
BasicText
- Inherited Members
- Extension Methods
Examples
SIMPLE USAGE EXAMPLE:BasicText message = new BasicText();
message.ShowMessage("This Message Will Fade In 10 Seconds", 10);
COMPLEX USAGE EXAMPLE:
BasicText message = new BasicText(TextAnchor.UpperLeft); // Note many other properties could also be set as constructor parameters
message.setColor(Color.red); // Set Color
message.setSize(20); // Set Font Size
message.setLoc(200, 400); // Set x/y position (0,0 is center of screen)
message.setFontStyle(FontStyle.Bold); // Bold
message.ShowMessage("This message stays on screen until hidden"); // Display message; if fadeout seconds not specified, it just keeps showing
... // other things happen, time goes by
message.Hide(); // Hides the message
Constructors
BasicText()
Creates a new instances of BasicText with all default options.
public BasicText()
BasicText(int)
Creates a new instances of BasicText with a specified size.
public BasicText(int useSize)
Parameters
useSize
int- The text size to uset
BasicText(int, int)
Creates a new instances of BasicText at the specified origin point.
public BasicText(int set_x, int set_y)
Parameters
BasicText(int, int, int)
Creates a new instances of BasicText with a specified origin point and size.
public BasicText(int set_x, int set_y, int useSize)
Parameters
set_x
int- The x coordinate to set
set_y
int- The y coordinate to set
useSize
int- The text size to use
BasicText(int, int, int, Color)
Creates a new instances of BasicText with a specified origin point, size, and UnityEngine.Color.
public BasicText(int set_x, int set_y, int useSize, Color useColor)
Parameters
set_x
int- The x coordinate to set
set_y
int- The y coordinate to set
useSize
int- The text size to use
useColor
Color- The text color to use
BasicText(int, int, int, Color, TextAlignmentOptions)
Creates a new instances of BasicText with a specified origin point, size, UnityEngine.Color, and UnityEngine.TextAnchor.
public BasicText(int set_x, int set_y, int useSize, Color useColor, TextAlignmentOptions useAlign)
Parameters
set_x
int- The x coordinate to set
set_y
int- The y coordinate to set
useSize
int- The text size to use
useColor
Color- The text color to use
useAlign
TextAlignmentOptions- The text anchor to align to
BasicText(int, TextAlignmentOptions)
Creates a new instances of BasicText with a specified size and UnityEngine.TextAnchor.
public BasicText(int useSize, TextAlignmentOptions useAlign)
Parameters
useSize
int- The text size to use
useAlign
TextAlignmentOptions- The text anchor to align to
BasicText(int, Color)
Creates a new instances of BasicText with a specified size and UnityEngine.Color.
public BasicText(int useSize, Color useColor)
Parameters
useSize
int- The text size to use
useColor
Color- The text color to use
BasicText(int, Color, TextAlignmentOptions)
Creates a new instances of BasicText with a specified size, UnityEngine.Color, and UnityEngine.TextAnchor.
public BasicText(int useSize, Color useColor, TextAlignmentOptions useAlign)
Parameters
useSize
int- The text size to use
useColor
Color- The text color to use
useAlign
TextAlignmentOptions- The text anchor to align to
BasicText(TextAlignmentOptions)
Creates a new instances of BasicText at a specified UnityEngine.TextAnchor.
public BasicText(TextAlignmentOptions useAlign)
Parameters
useAlign
TextAlignmentOptions- The text anchor to align to
BasicText(Color)
Creates a new instances of BasicText with a specified UnityEngine.Color.
public BasicText(Color useColor)
Parameters
useColor
Color- The text color to use
Methods
ClearAlign()
Resets to using "cloned" font style of Subnautica default
public void ClearAlign()
ClearColor()
Resets to using "cloned" color of Subnautica default.
public void ClearColor()
ClearFont()
Resets to using "cloned" font of Subnautica default.
public void ClearFont()
ClearFontStyle()
Resets to using "cloned" font style of Subnautica default.
public void ClearFontStyle()
ClearSize()
Resets to using "cloned" size of Subnautica default.
public void ClearSize()
GetText()
Returns our current text.
public string GetText()
Returns
Hide()
Hides our text item if it is displaying.
public void Hide()
SetAlign(TextAlignmentOptions)
Sets the text anchor.
public void SetAlign(TextAlignmentOptions useAlign)
Parameters
useAlign
TextAlignmentOptions- The text anchor to align to
SetColor(Color)
Sets the text color
public void SetColor(Color useColor)
Parameters
useColor
Color- The text color to use
SetFont(TMP_FontAsset)
Sets the font
public void SetFont(TMP_FontAsset useFont)
Parameters
useFont
TMP_FontAsset- The font to render the text as.
SetFontStyle(FontStyles)
Sets the font style.
public void SetFontStyle(FontStyles useStyle)
Parameters
useStyle
FontStyles- The text font style to use
SetLocation(float, float)
Sets screen display location (position relative to the actual text is determined by the alignment)
public void SetLocation(float set_x, float set_y)
Parameters
SetSize(int)
Sets the font size.
public void SetSize(int useSize)
Parameters
useSize
int- The text size to use
ShowMessage(string)
Shows our text item, with no schedule fade (i.e. indefinitely)
public void ShowMessage(string s)
Parameters
s
string- The text to display
ShowMessage(string, float)
Shows our text item, fading after a specified number of seconds (or stays on indefinitely if 0 seconds)
public void ShowMessage(string s, float seconds)