test
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
## [2.0.0] - 2023-03-08
|
||||
Merge of the com.unity.textmeshpro package.
|
||||
|
||||
## [1.0.0] - 2019-01-08
|
||||
This is the first release of Unity UI as a built in package.
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c851bee4305bddf438cc6ffc515991ce
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,37 @@
|
||||
# Event System
|
||||
|
||||
The Event System is a way of sending events to objects in the application based on input, be it keyboard, mouse, touch, or custom input. The Event System consists of a few components that work together to send events.
|
||||
|
||||
When you add an Event System component to a GameObject you will notice that it does not have much functionality exposed, this is because the Event System itself is designed as a manager and facilitator of communication between Event System modules.
|
||||
|
||||
The primary roles of the Event System are as follows:
|
||||
|
||||
- Manage which GameObject is considered selected
|
||||
- Manage which Input Module is in use
|
||||
- Manage Raycasting (if required)
|
||||
- Updating all Input Modules as required
|
||||
|
||||
## Input Modules
|
||||
|
||||
An Input Module is where the main logic of how you want the Event System to behave lives, they are used for:
|
||||
|
||||
- Handling Input
|
||||
- Managing event state
|
||||
- Sending events to scene objects.
|
||||
|
||||
Only one Input Module can be active in the Event System at a time, and they must be components on the same GameObject as the Event System component.
|
||||
|
||||
If you want to write a custom Input Module, send events supported by existing UI components in Unity. To extend and write your own events, see the [Messaging System](MessagingSystem.md) documentation.
|
||||
|
||||
## Raycasters
|
||||
|
||||
Raycasters are used for figuring out what the pointer is over. It is common for Input Modules to use the Raycasters configured in the Scene to calculate what the pointing device is over.
|
||||
|
||||
There are 3 provided Raycasters that exist by default:
|
||||
|
||||
|
||||
- [Graphic Raycaster](script-GraphicRaycaster.md) - Used for UI elements
|
||||
- [Physics 2D Raycaster](script-Physics2DRaycaster.md) - Used for 2D physics elements
|
||||
- [Physics Raycaster](script-PhysicsRaycaster.md) - Used for 3D physics elements
|
||||
|
||||
If you have a 2d / 3d Raycaster configured in your Scene, it is easy to make non-UI elements receive messages from the Input Module. Simply attach a script that implements one of the event interfaces. For examples of this, see the [IPointerEnterHandler](xref:UnityEngine.EventSystems.IPointerEnterHandler) and [IPointerClickHandler](xref:UnityEngine.EventSystems.IPointerClickHandler) Scripting Reference pages.
|
@@ -0,0 +1,11 @@
|
||||
# Event System Reference
|
||||
|
||||
This section provides details about the following parts of the event system:
|
||||
|
||||
- [Event System Manager](script-EventSystem.md)
|
||||
- [Graphic Raycaster](script-GraphicRaycaster.md)
|
||||
- [Physics Raycaster](script-PhysicsRaycaster.md)
|
||||
- [Physics2D Raycaster](script-Physics2DRaycaster.md)
|
||||
- [Standalone Input Module](script-StandaloneInputModule.md)
|
||||
- [Touch Input Module](script-TouchInputModule.md)
|
||||
- [Event Trigger](script-EventTrigger.md)
|
@@ -0,0 +1,128 @@
|
||||
# Create Custom UI Effects With Shader Graph
|
||||
|
||||
Shader Graph can help you create customized UI effects, including animated backgrounds and unique UI elements. With Shader Graph, you can transform Image elements from static to dynamic and easily define your own button state appearances. Shader Graph can also provide you with more control over the appearance of your UI and help you optimize performance and texture memory.
|
||||
|
||||
Here are some examples of what you can achieve with Shader Graph in Unity UI:
|
||||
* Create custom backgrounds for your user interfaces that subtly swirl, flow, or drift.
|
||||
* Define visual button states, such as mouse hover and mouse press, or unfocused with just a single grayscale image.
|
||||
* Design animated HUD elements that indicate the passage of time.
|
||||
|
||||
## The Basics
|
||||
To create a Shader Graph shader for a Canvas UI element, use one of the following methods:
|
||||
|
||||
* Modify an existing Shader Graph:
|
||||
1. Open the Shader Graph in the Shader Editor.
|
||||
2. In **Graph Settings**, select the **HDRP** Target. If there isn't one, go to **Active Targets** > **Plus**, and select **HDRP**.
|
||||
3. In the **Material** drop-down, select **Canvas**.
|
||||
* Create a new Shader Graph. Go to **Assets** > **Create** > **Shader Graph** > **HDRP**, and select **Canvas Shader Graph**.
|
||||
|
||||
## Create animated backgrounds
|
||||
Follow these steps to create a simple animated background for a user interface.
|
||||
|
||||
1. Add two Sample Texture 2D nodes to the graph and set them to use a tiling clouds texture. We will scroll these in different directions speeds.
|
||||
<br/>
|
||||
|
||||
2. For each of the Sample Texture 2D nodes, add a Tiling and Offset node and connect it to the UV input port of the Sample Texture 2D node. We will use the Offset input ports to add the scrolling.
|
||||
<br/>
|
||||
|
||||
3. For each of the Tiling and Offset nodes, create a multiply node and connect it to the Offset input port.
|
||||
<br/>
|
||||
|
||||
4. For the first Multiply node, create a Vector 2 node connected to the A input port and set it to `0.2` and `0.13`. For the second Multiply node, create a Vector 2 node connected to the B input port and set it to `-0.1` and `0.23`. These values control the scrolling directions.
|
||||
<br/>
|
||||
|
||||
5. Create a Time node and multiply the Time output value by `0.3`. This value is used to adjust the speed of the effect.
|
||||
<br/>
|
||||
|
||||
6. Connect the ouput port of the Time multiply node to the other two multiply nodes. Now our textures are scrolling.
|
||||
<br/>
|
||||
|
||||
7. Create a new Blend node and use it to blend the outputs of the two Sample Texture 2D nodes. This will combine the contributions of both textures together.
|
||||
<br/>
|
||||
|
||||
8. Add a Lerp node and wire the output of the Blend node to the T input of the Lerp. This uses the texture contributions as a mask for blending.
|
||||
<br/>
|
||||
|
||||
9. To blend the two colors using the animated mask, create two Color nodes and connect them to the A and B inputs of the Lerp. Set the colors according to your preference.
|
||||
<br/>
|
||||
|
||||
10. Finally, connect the output of the Lerp to the Base Color input on the Fragment Context Block.
|
||||
|
||||
You now have an animated background shader. You can customize it by changing the colors, changing the texture being used, or controlling the speed.
|
||||
|
||||
## Apply the shader to a Canvas element
|
||||
|
||||
Follow the steps below to apply the shader you created to a Canvas UI element.
|
||||
1. Right-click your Shader Graph asset in the Project window and select **Create** > **Material**. Give your material a name.
|
||||
<br/>
|
||||
|
||||
2. Ensure that your scene has a Canvas element. If it doesn't, right-click in the Hierarchy panel and select UI > Canvas.
|
||||
<br/>
|
||||
|
||||
3. Add a new Image element to your Canvas. Right-click the Canvas element and select **UI** > **Image**.
|
||||
<br/>
|
||||
|
||||
4. Select the Image element in the Hierarchy panel. In the Inspector window, select **Browse** on the Material slot.
|
||||
<br/>
|
||||
|
||||
5. Select the Material asset you created in step 1.
|
||||
|
||||
Now your Canvas element is using the shader you created.
|
||||
|
||||
## Pass custom data into the shader
|
||||
|
||||
It's possible to retrieve custom data in a Shader Graph shader, such as the width and height dimensions of Canvas Image elements. You can easily achieve this using a script by following the steps below:
|
||||
|
||||
1. Follow the steps in [Apply The Shader To A Canvas Element](#apply-the-shader-to-a-canvas-element) to create a material and apply it to a Canvas Image element.
|
||||
|
||||
2. To access the Blackboard window, open the Shader Graph asset and then select **Blackboard** on the top right.
|
||||
<br/>
|
||||
|
||||
3. In the Blackboard window, click **+** on the top right to add a new Blackboard parameter.
|
||||
|
||||
4. Select the data type that matches the type of data you want to bring in. In this example, add a Vector 2 parameter.
|
||||
|
||||
5. Name the new parameter "Size". You can then drag the Size parameter into the graph and use it based on your needs.
|
||||
<br/>
|
||||
|
||||
6. Create the following script to connect the Canvas Image's Width and Height values to the shader's Size parameter:
|
||||
```
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[RequireComponent(typeof(Graphic))]
|
||||
[ExecuteAlways]
|
||||
public class ImageSize : MonoBehaviour
|
||||
{
|
||||
private Image m_myCanvasImage;
|
||||
private void Start()
|
||||
{
|
||||
m_myCanvasImage = GetComponent<Image>();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
void OnValidate() { UpdateMaterial(); }
|
||||
#endif
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
UpdateMaterial();
|
||||
}
|
||||
|
||||
void UpdateMaterial()
|
||||
{
|
||||
if (m_myCanvasImage != null && m_myCanvasImage.material != null)
|
||||
{
|
||||
var imageRect = m_myCanvasImage.rectTransform.rect;
|
||||
var widthHeight = new Vector2(x: imageRect.width, y: imageRect.height);
|
||||
m_myCanvasImage.material.SetVector(name: "_Size", widthHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
7. Save the script as `ImageSize.cs` and add it to your project.
|
||||
8. Select the Image element in the Hierarchy panel of your scene.
|
||||
9. In the Inspector window, select **Add Component** and then choose **Scripts** > **Image Size**.
|
||||
<br/>
|
||||
|
||||
The Image element's Width and Height values from the Rect Transform are passed into the Material's Size parameter. You can now use them in the shader.
|
@@ -0,0 +1,35 @@
|
||||
# Creating UI elements from scripting
|
||||
|
||||
If you are creating a dynamic UI where UI elements appear, disappear, or change based on user actions or other actions in the game, you may need to make a script that instantiates new UI elements based on custom logic.
|
||||
|
||||
|
||||
## Creating a prefab of the UI element
|
||||
|
||||
In order to be able to easily instantiate UI elements dynamically, the first step is to create a prefab for the type of UI element that you want to be able to instantiate. Set up the UI element the way you want it to look in the Scene, and then drag the element into the Project View to make it into a prefab.
|
||||
|
||||
For example, a prefab for a button could be a Game Object with a Image component and a Button component, and a child Game Object with a Text component. Your setup might be different depending on your needs.
|
||||
|
||||
You might wonder why we don't have a API methods to create the various types of controls, including visuals and everything. The reason is that there are an infinite number of way e.g. a button could be setup. Does it use an image, text, or both? Maybe even multiple images? What is the text font, color, font size, and alignment? What sprite or sprites should the image use? By letting you make a prefab and instantiate that, you can set it up exactly the way you want. And if you later want to change the look and feel of your UI you can just change the prefab and then it will be reflected in your UI, including the dynamically created UI.
|
||||
|
||||
|
||||
## Instantiating the UI element
|
||||
|
||||
Prefabs of UI elements are instantiated as normal using the Instantiate method. When setting the parent of the instantiated UI element, it's recommended to do it using the Transform.SetParent method with the worldPositionStays parameter set to false.
|
||||
|
||||
|
||||
## Positioning the UI element
|
||||
|
||||
A UI Element is normally positioned using its Rect Transform. If the UI Element is a child of a Layout Group it will be automatically positioned and the positioning step can be skipped.
|
||||
|
||||
When positioning a Rect Transform it's useful to first determine it has or should have any stretching behavior or not. Stretching behavior happens when the anchorMin and anchorMax properties are not identical.
|
||||
|
||||
For a non-stretching Rect Transform, the position is set most easily by setting the anchoredPosition and the sizeDelta properties. The anchoredPosition specifies the position of the pivot relative to the anchors. The sizeDelta is just the same as the size when there's no stretching.
|
||||
|
||||
For a stretching Rect Transform, it can be simpler to set the position using the offsetMin and offsetMax properties. The offsetMin property specifies the corner of the lower left corner of the rect relative to the lower left anchor. The offsetMax property specifies the corner of the upper right corner of the rect relative to the upper right anchor.
|
||||
|
||||
|
||||
## Customizing the UI Element
|
||||
|
||||
If you are instantiating multiple UI elements dynamically, it's unlikely that you'll want them all to look the same and do the same. Whether it's buttons in a menu, items in an inventory, or something else, you'll likely want the individual items to have different text or images and to do different things when interacted with.
|
||||
|
||||
This is done by getting the various components and changing their properties. See the scripting reference for the Image and Text components, and for how to work with UnityEvents from scripting.
|
@@ -0,0 +1,63 @@
|
||||
# Making UI elements fit the size of their content
|
||||
|
||||
Normally when positioning a UI element with its Rect Transform, its position and size is specified manually (optionally including behavior to stretch with the parent Rect Transform).
|
||||
|
||||
However, sometimes you may want the rectangle to be automatically sized to fit the content of the UI element. This can be done by adding a component called Content Size Fitter.
|
||||
|
||||
|
||||
## Fit to size of Text
|
||||
|
||||
In order to make a Rect Transform with a Text component on it fit the text content, add a Content Size Fitter component to the same Game Object which has the Text component. Then set both the Horizontal Fit and Vertical Fit dropdowns to the Preferred setting.
|
||||
|
||||
|
||||
### How does it work?
|
||||
|
||||
What happens here is that the Text component functions as a Layout Element that can provide information about how big its minimum and preferred size is. In a manual layout this information is not used. A Content Size Fitter is a type of Layout Controller, which listens to layout information provided by Layout Elements and control the size of the Rect Transform according to this.
|
||||
|
||||
|
||||
### Remember the pivot
|
||||
|
||||
When UI elements are automatically resized to fit their content, you should pay extra attention to the pivot of the Rect Transform. The pivot will stay in place when the element is resized, so by setting the pivot position you can control in which direction the element will expand or shrink. For example, if the pivot is in the center, then the element will expand equally in all directions, and if the pivot is in the upper left corner, then the element will expand to the right and down.
|
||||
|
||||
|
||||
## Fit to size of UI element with child Text
|
||||
|
||||
If you have a UI element, such as a Button, that has a background image and a child Game Object with a Text component on it, you probably want the whole UI element to fit the size of the text - maybe with some padding.
|
||||
|
||||
In order to do this, first add a Horizontal Layout Group to the UI element, then add a Content Size Fitter too. Set the Horizontal Fit, the Vertical Fit, or both to the Preferred setting. You can add and tweak padding using the padding property in the Horizontal Layout Group.
|
||||
|
||||
Why use a Horizontal Layout Group? Well, it could have been a Vertical Layout Group as well - as long as there is only a single child, they produce the same result.
|
||||
|
||||
|
||||
### How does it work?
|
||||
|
||||
The Horizontal (or Vertical) Layout Group functions both as a Layout Controller and as a Layout Element. First it listens to the layout information provided by the children in the group - in this case the child Text. Then it determines how large the group must be (at minimum, and preferably) in order to be able to contain all the children, and it functions as a Layout Element that provides this information about its minimum and preferred size.
|
||||
|
||||
The Content Size Fitter listens to layout information provided by any Layout Element on the same Game Object - in this case provided by the Horizontal (or Vertical) Layout Group. Depending on its settings, it then controls the size of the Rect Transform based on this information.
|
||||
|
||||
Once the size of the Rect Transform has been set, the Horizontal (or Vertical) Layout Group makes sure to position and size its children according to the available space. See the page about the Horizontal Layout Group for more information about how it controls the positions and sizes of its children.
|
||||
|
||||
|
||||
## Make children of a Layout Group fit their respective sizes
|
||||
|
||||
If you have a Layout Group (horizontal or vertical) and want each of the UI elements in the group to fit their respective content, what do you do?
|
||||
|
||||
You can't put a Content Size Fitter on each child. The reason is that the Content Size Fitter wants control over its own Rect Transform, but the parent Layout Group also wants control over the child Rect Transform. This creates a conflict and the result is undefined behavior.
|
||||
|
||||
However, it isn't necessary either. The parent Layout Group can already make each child fit the size of the content. What you need to do is to disable the Child Force Expand toggles on the Layout Group. If the children are themselves Layout Groups too, you may need to disable the Child Force Expand toggles on those too.
|
||||
|
||||
Once the children no longer expand with flexible width, their alignment can be specified in the Layout Group using the Child Alignment setting.
|
||||
|
||||
What if you want some of the children to expand to fill additional available space, but not the other children? You can easily control this by adding a Layout Element component to the children you want to expand and enabling the Flexible Width or Flexible Height properties on those Layout Elements. The parent Layout Group should still have the Child Force Expand toggles disabled, otherwise all the children will expand flexibly.
|
||||
|
||||
|
||||
### How does it work?
|
||||
|
||||
A Game Object can have multiple components that each provide layout information about minimum, preferred and flexible sizes. A priority system determines which values take effect over others. The Layout Element component has a higher priority than the Text, Image, and Layout Group components, so it can be used to override any layout information values they provide.
|
||||
|
||||
When the Layout Group listens to the layout information provided by the children, it will take the overridden flexible sizes into account. Then, when controlling the sizes of the children, it will not make them any bigger than their preferred sizes. However, if the Layout Group has the Child Force Expand option enabled, it will always make the flexible sizes of all the children be at least 1.
|
||||
|
||||
|
||||
## More information
|
||||
|
||||
This page has explained solutions to a few common use cases. For a more in depth explanation of the auto layout system, see the [UI Auto Layout](UIAutoLayout.md) page.
|
@@ -0,0 +1,57 @@
|
||||
# Designing UI for Multiple Resolutions
|
||||
|
||||
Modern games and applications often need to support a wide variety of different screen resolutions and particularly UI layouts need to be able to adapt to that. The UI System in Unity includes a variety of tools for this purpose that can be combined in various ways.
|
||||
|
||||
In this how-to we're going to use a simple case study and look at and compare the different tools in the context of that. In our case study we have three buttons in the corners of the screen as shown below, and the goal is to adapt this layout to various resolutions.
|
||||
|
||||

|
||||
|
||||
For this how-to we're going to consider four screen resolutions: Phone HD in portrait (640 x 960) and landscape (960 x 640) and Phone SD in portrait (320 x 480) and landscape (480 x 320). The layout is initially setup in the Phone HD Portrait resolution.
|
||||
|
||||
## Using anchors to adapt to different aspect ratios
|
||||
|
||||
UI elements are by default anchored to the center of the parent rectangle. This means that they keep a constant offset from the center.
|
||||
|
||||
If the resolution is changed to a landscape aspect ratio with this setup, the buttons may not even be inside the rectangle of the screen anymore.
|
||||
|
||||

|
||||
|
||||
One way to keep the buttons inside the screen is to change the layout such that the locations of the buttons are tied to their respective corners of the screen. The anchors of the top left button can be set to the upper left corner using the Anchors Preset drop down in the Inspector, or by dragging the triangular anchor handles in the Scene View. It's best to do this while the current screen resolution set in the Game View is the one the layout is initially designed for, where the button placement looks correct. (See the [UI Basic Layout](UIBasicLayout.md) page for more information on anchors.) Similarly, the anchors for the lower left and lower right buttons can be set to the lower left corner and lower right corner, respectively.
|
||||
|
||||
Once the buttons have been anchored to their respective corners, they stick to them when changing the resolution to a different aspect ratio.
|
||||
|
||||

|
||||
|
||||
When the screen size is changed to a larger or smaller resolution, the buttons will also remain anchored to their respective corners. However, since they keep their original size as specified in pixels, they may take up a larger or smaller proportion of the screen. This may or may not be desirable, depending on how you would like your layout to behave on screens of different resolutions.
|
||||
|
||||

|
||||
|
||||
In this how-to, we know that the smaller resolutions of Phone SD Portrait and Landscape don't correspond to screens that are physically smaller, but rather just screens with a lower pixel density. On these lower-density screens the buttons shouldn't appear larger than on the high-density screens - they should instead appear with the same size.
|
||||
|
||||
This means that the buttons should become smaller by the same percentage as the screen is smaller. In other words, the scale of the buttons should follow the screen size. This is where the **Canvas Scaler** component can help.
|
||||
|
||||
## Scaling with Screen Size
|
||||
|
||||
The **Canvas Scaler** component can be added to a root **Canvas** - a Game Object with a Canvas component on it, which all the UI elements are children of. It is also added by default when creating a new Canvas through the **GameObject** menu.
|
||||
|
||||
In the Canvas Scaler component, you can set its **UI Scale Mode** to **Scale With Screen Size**. With this scale mode you can specify a resolution to use as reference. If the current screen resolution is smaller or larger than this reference resolution, the scale factor of the Canvas is set accordingly, so all the UI elements are scaled up or down together with the screen resolution.
|
||||
|
||||
In our case, we set the **Canvas Scaler** to be the Phone HD portrait resolution of 640 x 960. Now, when setting the screen resolution to the Phone SD portrait resolution of 320 x 480, the entire layout is scaled down so it appears proportionally the same as in full resolution. Everything is scaled down: The button sizes, their distances to the edges of the screen, the button graphics, and the text elements. This means that the layout will appear the same in the Phone SD portrait resolution as in Phone HD portrait; only with a lower pixel density.
|
||||
|
||||

|
||||
|
||||
One thing to be aware of: After adding a Canvas Scaler component, it's important to also check how the layout looks at other aspect ratios. By setting the resolution back to Phone HD landscape, we can see that the buttons now appear bigger than they should (and used to).
|
||||
|
||||

|
||||
|
||||
The reason for the larger buttons in landscape aspect ratio comes down to how the Canvas Scaler setting works. By default it compares the width or the current resolution with the width of the Canvas Scaler and the result is used as the scale factor to scale everything with. Since the current landscape resolution of 960 x 640 has a 1.5 times larger width than the portrait Canvas Scaler of 640 x 960, the layout is scaled up by 1.5.
|
||||
|
||||
The component has a property called **Match** which can be 0 (Width), 1 (Height) or a value in between. By default it's set to 0, which compares the current screen width with the Canvas Scaler width as described.
|
||||
|
||||
If the **Match** property is set to 0.5 instead, it will compare both the current width to the reference width and the current height to the reference height, and choose a scale factor that's in between the two. Since in this case the landscape resolution is 1.5 times wider but also 1.5 times shorter, those two factor even out and produce a final scale factor of 1, which means the buttons keep their original size.
|
||||
|
||||
At this point the layout supports all the four screen resolutions using a combination of appropriate anchoring and the Canvas Scaler component on the Canvas.
|
||||
|
||||

|
||||
|
||||
See the [Canvas Scaler](script-CanvasScaler.md) reference page for more information on different ways to scale UI elements in relation to different screen sizes.
|
@@ -0,0 +1,179 @@
|
||||
# Creating Screen Transitions
|
||||
|
||||
The need to transition between multiple UI screens is fairly common. In this page we will explore a simple way to create and manage those transitions using animation and State Machines to drive and control each screen.
|
||||
|
||||
## Overview
|
||||
|
||||
The high-level idea is that each of our screens will have an [Animator Controller](https://docs.unity3d.com/Manual/class-AnimatorController.html) with two [states](https://docs.unity3d.com/Manual/class-State.html) (Open and Closed) and a boolean [Parameter](https://docs.unity3d.com/Manual/AnimationParameters.html) (Open). To transition between screens you will only need to close the currently open Screen and open the desired one. To make this process easier we will create a small Class ScreenManager that will keep track and take care of closing any already open Screen for us. The button that triggers the transition will only have to ask the ScreenManager to open the desired screen.
|
||||
|
||||
### Thinking about Navigation
|
||||
|
||||
If you plan to support controller/keyboard navigation of UI elements, then it's important to have a few things in mind. It's important to avoid having Selectable elements outside the screen since that would enable players to select offscreen elements, we can do that by deactivating any off-screen hierarchy. We also need to make sure when a new screen is shown we set a element from it as selected, otherwise the player would not be able to navigate to the new screen. We will take care of all that in the ScreenManager class below.
|
||||
|
||||
## Setting up the Animator Controller
|
||||
|
||||
Let's take a look at the most common and minimal setup for the Animation Controller to do a Screen transition. The controller will need a boolean parameter (Open) and two states (Open and Closed), each state should have an animation with only one keyframe, this way we let the State Machine do the transition blending for us.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Now we need to create the [transition](https://docs.unity3d.com/Manual/class-Transition.html) between both states, let's start with the transition from Open to Closed and let's set the condition properly, we want to go from Open to Closed when the parameter Open is set to false. Now we create the transition from Closed to Open and set the condition to go from Closed to Open when the parameter Open is true.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## Managing the screens
|
||||
|
||||
With all the above set up, the only thing missing is for us to set the parameter Open to true on the screens Animator we want to transition to and Open to false on the currently open screens Animator. To do that, we will create a small script:
|
||||
|
||||
````
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ScreenManager : MonoBehaviour {
|
||||
|
||||
//Screen to open automatically at the start of the Scene
|
||||
public Animator initiallyOpen;
|
||||
|
||||
//Currently Open Screen
|
||||
private Animator m_Open;
|
||||
|
||||
//Hash of the parameter we use to control the transitions.
|
||||
private int m_OpenParameterId;
|
||||
|
||||
//The GameObject Selected before we opened the current Screen.
|
||||
//Used when closing a Screen, so we can go back to the button that opened it.
|
||||
private GameObject m_PreviouslySelected;
|
||||
|
||||
//Animator State and Transition names we need to check against.
|
||||
const string k_OpenTransitionName = "Open";
|
||||
const string k_ClosedStateName = "Closed";
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
//We cache the Hash to the "Open" Parameter, so we can feed to Animator.SetBool.
|
||||
m_OpenParameterId = Animator.StringToHash (k_OpenTransitionName);
|
||||
|
||||
//If set, open the initial Screen now.
|
||||
if (initiallyOpen == null)
|
||||
return;
|
||||
OpenPanel(initiallyOpen);
|
||||
}
|
||||
|
||||
//Closes the currently open panel and opens the provided one.
|
||||
//It also takes care of handling the navigation, setting the new Selected element.
|
||||
public void OpenPanel (Animator anim)
|
||||
{
|
||||
if (m_Open == anim)
|
||||
return;
|
||||
|
||||
//Activate the new Screen hierarchy so we can animate it.
|
||||
anim.gameObject.SetActive(true);
|
||||
//Save the currently selected button that was used to open this Screen. (CloseCurrent will modify it)
|
||||
var newPreviouslySelected = EventSystem.current.currentSelectedGameObject;
|
||||
//Move the Screen to front.
|
||||
anim.transform.SetAsLastSibling();
|
||||
|
||||
CloseCurrent();
|
||||
|
||||
m_PreviouslySelected = newPreviouslySelected;
|
||||
|
||||
//Set the new Screen as then open one.
|
||||
m_Open = anim;
|
||||
//Start the open animation
|
||||
m_Open.SetBool(m_OpenParameterId, true);
|
||||
|
||||
//Set an element in the new screen as the new Selected one.
|
||||
GameObject go = FindFirstEnabledSelectable(anim.gameObject);
|
||||
SetSelected(go);
|
||||
}
|
||||
|
||||
//Finds the first Selectable element in the providade hierarchy.
|
||||
static GameObject FindFirstEnabledSelectable (GameObject gameObject)
|
||||
{
|
||||
GameObject go = null;
|
||||
var selectables = gameObject.GetComponentsInChildren<Selectable> (true);
|
||||
foreach (var selectable in selectables) {
|
||||
if (selectable.IsActive () && selectable.IsInteractable ()) {
|
||||
go = selectable.gameObject;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return go;
|
||||
}
|
||||
|
||||
//Closes the currently open Screen
|
||||
//It also takes care of navigation.
|
||||
//Reverting selection to the Selectable used before opening the current screen.
|
||||
public void CloseCurrent()
|
||||
{
|
||||
if (m_Open == null)
|
||||
return;
|
||||
|
||||
//Start the close animation.
|
||||
m_Open.SetBool(m_OpenParameterId, false);
|
||||
|
||||
//Reverting selection to the Selectable used before opening the current screen.
|
||||
SetSelected(m_PreviouslySelected);
|
||||
//Start Coroutine to disable the hierarchy when closing animation finishes.
|
||||
StartCoroutine(DisablePanelDeleyed(m_Open));
|
||||
//No screen open.
|
||||
m_Open = null;
|
||||
}
|
||||
|
||||
//Coroutine that will detect when the Closing animation is finished and it will deactivate the
|
||||
//hierarchy.
|
||||
IEnumerator DisablePanelDeleyed(Animator anim)
|
||||
{
|
||||
bool closedStateReached = false;
|
||||
bool wantToClose = true;
|
||||
while (!closedStateReached && wantToClose)
|
||||
{
|
||||
if (!anim.IsInTransition(0))
|
||||
closedStateReached = anim.GetCurrentAnimatorStateInfo(0).IsName(k_ClosedStateName);
|
||||
|
||||
wantToClose = !anim.GetBool(m_OpenParameterId);
|
||||
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
|
||||
if (wantToClose)
|
||||
anim.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
//Make the provided GameObject selected
|
||||
//When using the mouse/touch we actually want to set it as the previously selected and
|
||||
//set nothing as selected for now.
|
||||
private void SetSelected(GameObject go)
|
||||
{
|
||||
//Select the GameObject.
|
||||
EventSystem.current.SetSelectedGameObject(go);
|
||||
|
||||
//If we are using the keyboard right now, that's all we need to do.
|
||||
var standaloneInputModule = EventSystem.current.currentInputModule as StandaloneInputModule;
|
||||
if (standaloneInputModule != null)
|
||||
return;
|
||||
|
||||
//Since we are using a pointer device, we don't want anything selected.
|
||||
//But if the user switches to the keyboard, we want to start the navigation from the provided game object.
|
||||
//So here we set the current Selected to null, so the provided gameObject becomes the Last Selected in the EventSystem.
|
||||
EventSystem.current.SetSelectedGameObject(null);
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
Let's hook up this script, we do this by creating a new GameObject, we can rename it "ScreenManager" for instance, and add the component above to it. You can assign an initial screen to it, this screen will be open at the start of your scene.
|
||||
|
||||
Now for the final part, let's make the [UI buttons](script-Button.md) work. Select the button that should trigger the screen transition and add a new action under the **On Click ()** list in the Inspector. Drag the ScreenManager GameObject we just created to the ObjectField, on the dropdown select **ScreenManager->OpenPanel (Animator)** and drag and drop the panel you want to open when the user clicks the button to the las ObjectField.
|
||||
|
||||

|
||||
|
||||
## Notes
|
||||
This technique only requires each screen to have an AnimatorController with an Open parameter and a Closed state to work - it doesn't matter how your screen or State Machine are constructed. This technique also works well with nested screens, meaning you only need one ScreenManager for each nested level.
|
||||
|
||||
The State Machine we set up above has the default state of Closed, so all of the screens that use this controller start as closed. The ScreenManager provides an initiallyOpen property so you can specify which screen is shown first.
|
@@ -0,0 +1,35 @@
|
||||
# Creating a World Space UI
|
||||
|
||||
The UI system makes it easy to create UI that is positioned in the world among other 2D or 3D objects in the Scene.
|
||||
|
||||
Start by creating a UI element (such as an Image) if you don't already have one in your scene by using GameObject > UI > Image. This will also create a Canvas for you.
|
||||
|
||||
|
||||
## Set the Canvas to World Space
|
||||
|
||||
Select your Canvas and change the Render Mode to World Space.
|
||||
|
||||
Now your Canvas is already positioned in the World and can be seen by all cameras if they are pointed at it, but it is probably huge compared to other objects in your Scene. We'll get back to that.
|
||||
|
||||
|
||||
## Decide on a resolution
|
||||
|
||||
First you need to decide what the resolution of the Canvas should be. If it was an image, what should the pixel resolution of the image be? Something like 800x600 might be a good starting point. You enter the resolution in the Width and Height values of the Rect Transform of the Canvas. It's probably a good idea to set the position to 0,0 at the same time.
|
||||
|
||||
|
||||
## Specify the size of the Canvas in the world
|
||||
|
||||
Now you should consider how big the Canvas should be in the world. You can use the Scale tool to simply scale it down until it has a size that looks good, or you can decide how big it should be in meters.
|
||||
|
||||
If you want it to have a specific width in meters, you can can calculate the needed scale by using meter_size / canvas_width. For example, if you want it to be 2 meters wide and the Canvas width is 800, you would have 2 / 800 = 0.0025. You then set the Scale property of the Rect Transform on the Canvas to 0.0025 for both X, Y, and Z in order to ensure that it's uniformly scaled.
|
||||
|
||||
Another way to think of it is that you are controlling the size of one pixel in the Canvas. If the Canvas is scaled by 0.0025, then that is also the size in the world of each pixel in the Canvas.
|
||||
|
||||
## Position the Canvas
|
||||
|
||||
Unlike a Canvas set to Screen Space, a World Space Canvas can be freely positioned and rotated in the Scene. You can put a Canvas on any wall, floor, ceiling, or slanted surface (or hanging freely in the air of course). Just use the normal Translate and Rotate tools in the toolbar.
|
||||
|
||||
|
||||
## Create the UI
|
||||
|
||||
Now you can begin setting up your UI elements and layouts the same way you would with a Screen Space Canvas.
|
@@ -0,0 +1,9 @@
|
||||
# Input Modules
|
||||
|
||||
An Input Module is where the main logic of an event system can be configured and customized. Out of the box there are two provided Input Modules, one designed for Standalone, and one designed for Touch input. Each module receives and dispatches events as you would expect on the given configuration.
|
||||
|
||||
Input modules are where the 'business logic' of the Event System take place. When the Event System is enabled it looks at what Input Modules are attached and passes update handling to the specific module.
|
||||
|
||||
Input modules are designed to be extended or modified based on the input systems that you wish to support. Their purpose is to map hardware specific input (such as touch, joystick, mouse, motion controller) into events that are sent via the messaging system.
|
||||
|
||||
The built in Input Modules are designed to support common game configurations such as touch input, controller input, keyboard input, and mouse input. They send a variety of events to controls in the application, if you implement the specific interfaces on your MonoBehaviours. All of the UI components implement the interfaces that make sense for the given component.
|
@@ -0,0 +1,46 @@
|
||||
|
||||
# Messaging System
|
||||
|
||||
The new UI system uses a messaging system designed to replace SendMessage. The system is pure C# and aims to address some of the issues present with SendMessage. The system works using custom interfaces that can be implemented on a MonoBehaviour to indicate that the component is capable of receiving a callback from the messaging system. When the call is made a target GameObject is specified; the call will be issued on all components of the GameObject that implement the specified interface that the call is to be issued against. The messaging system allows for custom user data to be passed, as well as how far through the GameObject hierarchy the event should propagate; that is should it just execute for the specified GameObject, or should it also execute on children and parents. In addition to this the messaging framework provides helper functions to search for and find GameObjects that implement a given messaging interface.
|
||||
|
||||
The messaging system is generic and designed for use not just by the UI system but also by general game code. It is relatively trivial to add custom messaging events and they will work using the same framework that the UI system uses for all event handling.
|
||||
|
||||
## Defining A Custom Message
|
||||
|
||||
If you wish to define a custom message it is relatively simple. In the UnityEngine.EventSystems namespace there is a base interface called 'IEventSystemHandler'. Anything that extends from this can be considered as a target for receiving events via the messaging system.
|
||||
|
||||
````
|
||||
public interface ICustomMessageTarget : IEventSystemHandler
|
||||
{
|
||||
// functions that can be called via the messaging system
|
||||
void Message1();
|
||||
void Message2();
|
||||
}
|
||||
````
|
||||
|
||||
Once this interface is defined then it can be implemented by a MonoBehaviour. When implemented it defines the functions that will be executed if the given message is issued against this MonoBehaviours GameObject.
|
||||
|
||||
````
|
||||
public class CustomMessageTarget : MonoBehaviour, ICustomMessageTarget
|
||||
{
|
||||
public void Message1()
|
||||
{
|
||||
Debug.Log ("Message 1 received");
|
||||
}
|
||||
|
||||
public void Message2()
|
||||
{
|
||||
Debug.Log ("Message 2 received");
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
Now that a script exists that can receive the message we need to issue the message. Normally this would be in response to some loosely coupled event that occurs. For example, in the UI system we issue events for such things as PointerEnter and PointerExit, as well as a variety of other things that can happen in response to user input into the application.
|
||||
|
||||
To send a message a static helper class exists to do this. As arguments it requires a target object for the message, some user specific data, and a functor that maps to the specific function in the message interface you wish to target.
|
||||
|
||||
````
|
||||
ExecuteEvents.Execute<ICustomMessageTarget>(target, null, (x,y)=>x.Message1());
|
||||
````
|
||||
|
||||
This code will execute the function Message1 on any components on the GameObject target that implement the ICustomMessageTarget interface. The scripting documentation for the ExecuteEvents class covers other forms of the Execute functions, such as Executing in children or in parents.
|
@@ -0,0 +1,11 @@
|
||||
# Raycasters
|
||||
|
||||
A Raycaster is a component that determines what objects are under a specific screen space position, such as the location of a mouse click or a touch. It works by projecting a ray from the screen into the scene and identifying objects that intersect with that ray. Raycasters are essential for detecting user interactions with UI elements, 2D objects, or 3D objects.
|
||||
|
||||
Different types of Raycasters are used for different types of objects:
|
||||
|
||||
- [Graphic Raycaster](script-GraphicRaycaster.md): Detects UI elements on a Canvas.
|
||||
- [Physics 2D Raycaster](script-Physics2DRaycaster.md): Detects 2D physics elements.
|
||||
- [Physics Raycaster](script-PhysicsRaycaster.md): Detects 3D physics elements.
|
||||
|
||||
The Event System uses Raycasters to determine where to send input events. When a Raycaster is present and enabled in the scene, the Event System uses it to determine which object is closest to the screen at a given screen space position. If multiple Raycasters are active, the system will cast against all of them and sort the results by distance.
|
@@ -0,0 +1,119 @@
|
||||
# Rich Text
|
||||
|
||||
The text for UI elements and text meshes can incorporate multiple font styles and sizes. Rich text is supported both for the UI System and the legacy GUI system. The Text, GUIStyle, GUIText and TextMesh classes have a __Rich Text__ setting which instructs Unity to look for markup tags within the text. The [Debug.Log](ScriptRef:Debug.Log.html) function can also use these markup tags to enhance error reports from code. The tags are not displayed but indicate style changes to be applied to the text.
|
||||
|
||||
## Markup format
|
||||
|
||||
The markup system is inspired by HTML but isn't intended to be strictly compatible with standard HTML. The basic idea is that a section of text can be enclosed inside a pair of matching tags:-
|
||||
|
||||
`We are <b>not</b> amused.`
|
||||
|
||||
As the example shows, the tags are just pieces of text inside the "angle bracket" characters, `<` and `>`.
|
||||
|
||||
You place the _opening_ tag at the beginning of the section. The text inside the tag denotes its name (which in this case is just **b**).
|
||||
|
||||
You place another tag at the end of the section. This is the _closing_ tag. It has the same name as the opening tag, but the name is prefixed with a slash `/` character. Every opening tag must have a corresponding closing tag. If you don't _close_ an opening tag, it is rendered as regular text.
|
||||
|
||||
The tags are not displayed to the user directly but are interpreted as instructions for styling the text they enclose. The `b` tag used in the example above applies boldface to the word "not", so the text appears ons creen as:-
|
||||
|
||||
We are **not** amused
|
||||
|
||||

|
||||
|
||||
A marked up section of text (including the tags that enclose it) is referred to as an **element**.
|
||||
|
||||
|
||||
### Nested elements
|
||||
|
||||
It is possible to apply more than one style to a section of text by "nesting" one element inside another
|
||||
|
||||
`We are <b><i>definitely not</i></b> amused`
|
||||
|
||||
The `<i>` tag applies italic style, so this would be presented onscreen as
|
||||
|
||||
We are **_definitely not_** amused
|
||||
|
||||

|
||||
|
||||
Note the ordering of the closing tags, which is in reverse to that of the opening tags. The reason for this is perhaps clearer when you consider that the inner tags need not span the whole text of the outermost element
|
||||
|
||||
`We are <b>absolutely <i>definitely</i> not</b> amused`
|
||||
|
||||
which gives
|
||||
|
||||
We are **absolutely _definitely_ not** amused
|
||||
|
||||

|
||||
|
||||
|
||||
### Tag parameters
|
||||
|
||||
Some tags have a simple all-or-nothing effect on the text but others might allow for variations. For example, the **color** tag needs to know which color to apply. Information like this is added to tags by the use of **parameters**:-
|
||||
|
||||
`We are <color=green>green</color> with envy`
|
||||
|
||||
Which produces this result:
|
||||
|
||||

|
||||
|
||||
Note that the ending tag doesn't include the parameter value. Optionally, the value can be surrounded by quotation marks but this isn't required.
|
||||
|
||||
Tag parameters cannot include blank spaces. For example:
|
||||
|
||||
`We are <color = green>green</color> with envy`
|
||||
|
||||
does not work because of the spaces to either side of the `=` character.
|
||||
|
||||
## Supported tags
|
||||
|
||||
The following list describes all the styling tags supported by Unity.
|
||||
|
||||
|**_Tag_** |**_Description_** |**_Example_** |**_Notes_** |
|
||||
|:---|:---|:---|:---|
|
||||
| **b**| Renders the text in boldface.| `We are <b>not</b> amused.`| |
|
||||
| **i**| Renders the text in italics.| `We are <i>usually</i> not amused.`| |
|
||||
| **size**| Sets the size of the text according to the parameter value, given in pixels.| `We are <size=50>largely</size> unaffected.`| Although this tag is available for Debug.Log, you will find that the line spacing in the window bar and Console looks strange if the size is set too large.|
|
||||
| <a name="ColorTag"></a>**color**| Sets the color of the text according to the parameter value. The color can be specified in the traditional HTML format. `#rrggbbaa` ...where the letters correspond to pairs of hexadecimal digits denoting the red, green, blue and alpha (transparency) values for the color. For example, cyan at full opacity would be specified by `color=#00ffffff`...<br/><br/>You can specify hexadecimal values in uppercase or lowercase; `#FF0000` is equivalent to `#ff0000`.| `We are <color=#ff0000ff>colorfully</color> amused`|Another option is to use the name of the color. This is easier to understand but naturally, the range of colors is limited and full opacity is always assumed. `<color=cyan>some text</color>` The available color names are given in the [table below](#ColorNames).|
|
||||
| **material** | This is only useful for text meshes and renders a section of text with a material specified by the parameter. The value is an index into the text mesh's array of materials as shown by the inspector.| `We are <material=2>texturally</material> amused` | |
|
||||
| **quad** | This is only useful for text meshes and renders an image inline with the text. It takes parameters that specify the material to use for the image, the image height in pixels, and a further four that denote a rectangular area of the image to display. Unlike the other tags, quad does not surround a piece of text and so there is no ending tag - the slash character is placed at the end of the initial tag to indicate that it is "self-closing". | `<quad material=1 size=20 x=0.1 y=0.1 width=0.5 height=0.5>` | This selects the material at position in the renderer's material array and sets the height of the image to 20 pixels. The rectangular area of image starts at given by the x, y, width and height values, which are all given as a fraction of the unscaled width and height of the texture.|
|
||||
|
||||
<a name="ColorNames"></a>
|
||||
### Supported colors
|
||||
|
||||
The following table lists colors for which you can use a name instead of a hexadecimal tag in the [`<color>`](#ColorTag) rich text tag.
|
||||
|
||||
|**_Color name_** |**_Hex value_** |**_Swatch_** |
|
||||
|:---|:---|:--|
|
||||
|aqua (same as cyan)|`#00ffffff`||
|
||||
|black|`#000000ff`||
|
||||
|blue|`#0000ffff`||
|
||||
|brown|`#a52a2aff`||
|
||||
|cyan (same as aqua)|`#00ffffff`||
|
||||
|darkblue|`#0000a0ff`||
|
||||
|fuchsia (same as magenta)|`#ff00ffff`||
|
||||
|green|`#008000ff`||
|
||||
|grey|`#808080ff`||
|
||||
|lightblue|`#add8e6ff`||
|
||||
|lime|`#00ff00ff`||
|
||||
|magenta (same as fuchsia)|`#ff00ffff`||
|
||||
|maroon|`#800000ff`||
|
||||
|navy|`#000080ff`||
|
||||
|olive|`#808000ff`||
|
||||
|orange|`#ffa500ff`||
|
||||
|purple|`#800080ff`||
|
||||
|red|`#ff0000ff`||
|
||||
|silver|`#c0c0c0ff`||
|
||||
|teal|`#008080ff`||
|
||||
|white|`#ffffffff`||
|
||||
|yellow|`#ffff00ff`||
|
||||
|
||||
|
||||
## Editor GUI
|
||||
|
||||
Rich text is disabled by default in the editor GUI system but it can be enabled explicitly using a custom [GUIStyle](ScriptRef:GUIStyle.html). The `richText` property should be set to true and the style passed to the GUI function in question:
|
||||
|
||||
````
|
||||
GUIStyle style = new GUIStyle ();
|
||||
style.richText = true;
|
||||
GUILayout.Label("<size=30>Some <color=yellow>RICH</color> text</size>",style);
|
||||
````
|
@@ -0,0 +1,23 @@
|
||||
# Supported Events
|
||||
|
||||
The Event System supports a number of events, and they can be customized further in user custom user written Input Modules.
|
||||
|
||||
The events that are supported by the Standalone Input Module and Touch Input Module are provided by interface and can be implemented on a MonoBehaviour by implementing the interface. If you have a valid Event System configured the events will be called at the correct time.
|
||||
|
||||
- [IPointerEnterHandler](xref:UnityEngine.EventSystems.IPointerEnterHandler) - OnPointerEnter - Called when a pointer enters the object
|
||||
- [IPointerExitHandler](xref:UnityEngine.EventSystems.IPointerExitHandler) - OnPointerExit - Called when a pointer exits the object
|
||||
- [IPointerDownHandler](xref:UnityEngine.EventSystems.IPointerDownHandler) - OnPointerDown - Called when a pointer is pressed on the object
|
||||
- [IPointerUpHandler](xref:UnityEngine.EventSystems.IPointerUpHandler)- OnPointerUp - Called when a pointer is released (called on the GameObject that the pointer is clicking)
|
||||
- [IPointerClickHandler](xref:UnityEngine.EventSystems.IPointerClickHandler) - OnPointerClick - Called when a pointer is pressed and released on the same object
|
||||
- [IInitializePotentialDragHandler](xref:UnityEngine.EventSystems.IInitializePotentialDragHandler) - OnInitializePotentialDrag - Called when a drag target is found, can be used to initialize values
|
||||
- [IBeginDragHandler](xref:UnityEngine.EventSystems.IBeginDragHandler) - OnBeginDrag - Called on the drag object when dragging is about to begin
|
||||
- [IDragHandler](xref:UnityEngine.EventSystems.IDragHandler) - OnDrag - Called on the drag object when a drag is happening
|
||||
- [IEndDragHandler](xref:UnityEngine.EventSystems.IEndDragHandler) - OnEndDrag - Called on the drag object when a drag finishes
|
||||
- [IDropHandler](xref:UnityEngine.EventSystems.IDropHandler) - OnDrop - Called on the object where a drag finishes
|
||||
- [IScrollHandler](xref:UnityEngine.EventSystems.IScrollHandler) - OnScroll - Called when a mouse wheel scrolls
|
||||
- [IUpdateSelectedHandler](xref:UnityEngine.EventSystems.IUpdateSelectedHandler) - OnUpdateSelected - Called on the selected object each tick
|
||||
- [ISelectHandler](xref:UnityEngine.EventSystems.ISelectHandler) - OnSelect - Called when the object becomes the selected object
|
||||
- [IDeselectHandler](xref:UnityEngine.EventSystems.IDeselectHandler) - OnDeselect - Called on the selected object becomes deselected
|
||||
- [IMoveHandler](xref:UnityEngine.EventSystems.IMoveHandler) - OnMove - Called when a move event occurs (left, right, up, down)
|
||||
- [ISubmitHandler](xref:UnityEngine.EventSystems.ISubmitHandler) - OnSubmit - Called when the submit button is pressed
|
||||
- [ICancelHandler](xref:UnityEngine.EventSystems.ICancelHandler) - OnCancel - Called when the cancel button is pressed
|
@@ -0,0 +1,135 @@
|
||||
* [Unity UI](index.md)
|
||||
* [Unity UI: Unity User Interface](index.md)
|
||||
* [Canvas](UICanvas.md)
|
||||
* [Basic Layout](UIBasicLayout.md)
|
||||
* [Visual Components](UIVisualComponents.md)
|
||||
* [Interaction Components](UIInteractionComponents.md)
|
||||
* [Animation Integration](UIAnimationIntegration.md)
|
||||
* [Auto Layout](UIAutoLayout.md)
|
||||
* [Rich Text](StyledText.md)
|
||||
* [Events](EventSystem.md)
|
||||
* [MessagingSystem](MessagingSystem.md)
|
||||
* [InputModules](InputModules.md)
|
||||
* [SupportedEvents](SupportedEvents.md)
|
||||
* [Raycasters](Raycasters.md)
|
||||
* [Reference](UIReference.md)
|
||||
* [Rect Transform](class-RectTransform.md)
|
||||
* [Canvas Components](comp-CanvasComponents.md)
|
||||
* [Canvas](class-Canvas.md)
|
||||
* [Canvas Scaler](script-CanvasScaler.md)
|
||||
* [Canvas Group](class-CanvasGroup.md)
|
||||
* [Canvas Renderer](class-CanvasRenderer.md)
|
||||
* [Visual Components](comp-UIVisual.md)
|
||||
* [Text](script-Text.md)
|
||||
* [Image](script-Image.md)
|
||||
* [Raw Image](script-RawImage.md)
|
||||
* [Mask](script-Mask.md)
|
||||
* [RectMask2D](script-RectMask2D.md)
|
||||
* [UI Effect Components](comp-UIEffects.md)
|
||||
* [Shadow](script-Shadow.md)
|
||||
* [Outline](script-Outline.md)
|
||||
* [Position as UV1](script-PositionAsUV1.md)
|
||||
* [Interaction Components](comp-UIInteraction.md)
|
||||
* [Selectable Base Class](script-Selectable.md)
|
||||
* [Transition Options](script-SelectableTransition.md)
|
||||
* [Navigation Options](script-SelectableNavigation.md)
|
||||
* [Button](script-Button.md)
|
||||
* [Toggle](script-Toggle.md)
|
||||
* [Toggle Group](script-ToggleGroup.md)
|
||||
* [Slider](script-Slider.md)
|
||||
* [Scrollbar](script-Scrollbar.md)
|
||||
* [Dropdown](script-Dropdown.md)
|
||||
* [Input Field](script-InputField.md)
|
||||
* [Scroll Rect](script-ScrollRect.md)
|
||||
* [Auto Layout](comp-UIAutoLayout.md)
|
||||
* [Layout Element](script-LayoutElement.md)
|
||||
* [Content Size Fitter](script-ContentSizeFitter.md)
|
||||
* [Aspect Ratio Fitter](script-AspectRatioFitter.md)
|
||||
* [Horizontal Layout Group](script-HorizontalLayoutGroup.md)
|
||||
* [Vertical Layout Group](script-VerticalLayoutGroup.md)
|
||||
* [Grid Layout Group](script-GridLayoutGroup.md)
|
||||
* [Events](EventSystemReference.md)
|
||||
* [Event System Manager](script-EventSystem.md)
|
||||
* [Graphic Raycaster](script-GraphicRaycaster.md)
|
||||
* [Panel Event Handler](script-PanelEventHandler)
|
||||
* [Panel Raycaster](script-PanelRaycaster)
|
||||
* [Physics Raycaster](script-PhysicsRaycaster.md)
|
||||
* [Physics 2D Raycaster](script-Physics2DRaycaster.md)
|
||||
* [Standalone Input Module](script-StandaloneInputModule.md)
|
||||
* [Touch Input Module](script-TouchInputModule.md)
|
||||
* [Event Trigger](script-EventTrigger.md)
|
||||
* [UI How Tos](UIHowTos.md)
|
||||
* [Designing UI for Multiple Resolutions](HOWTO-UIMultiResolution.md)
|
||||
* [Making UI elements fit the size of their content](HOWTO-UIFitContentSize.md)
|
||||
* [Creating a World Space UI](HOWTO-UIWorldSpace.md)
|
||||
* [Creating UI elements from scripting](HOWTO-UICreateFromScripting.md)
|
||||
* [Creating Screen Transitions](HOWTO-UIScreenTransition.md)
|
||||
* [Creating Custom UI Effects With Shader Graph](HOWTO-ShaderGraph.md)
|
||||
* [TextMesh Pro](TextMeshPro/index)
|
||||
* [Creating text](TextMeshPro/TMPObjects)
|
||||
* [UI Text GameObjects](TextMeshPro/TMPObjectUIText)
|
||||
* [3D Text GameObjects](TextMeshPro/TMPObject3DText)
|
||||
* [Font Assets](TextMeshPro/FontAssets)
|
||||
* [Font Asset Properties](TextMeshPro/FontAssetsProperties)
|
||||
* [Font Asset Creator](TextMeshPro/FontAssetsCreator)
|
||||
* [Line Metrics](TextMeshPro/FontAssetsLineMetrics)
|
||||
* [Signed Distance Fields](TextMeshPro/FontAssetsSDF)
|
||||
* [Dynamic Fonts](TextMeshPro/FontAssetsDynamicFonts)
|
||||
* [The Fallback Chain](TextMeshPro/FontAssetsFallback)
|
||||
* [Color emojis](TextMeshPro/ColorEmojis)
|
||||
* [Rich Text Tags](TextMeshPro/RichText)
|
||||
* [Supported Tags](TextMeshPro/RichTextSupportedTags)
|
||||
* [<align>](TextMeshPro/RichTextAlignment)
|
||||
* [<allcaps>](TextMeshPro/RichTextLetterCase)
|
||||
* [<alpha>](TextMeshPro/RichTextOpacity)
|
||||
* [<b>](TextMeshPro/RichTextBoldItalic)
|
||||
* [<color>](TextMeshPro/RichTextColor)
|
||||
* [<cspace>](TextMeshPro/RichTextCharacterSpacing)
|
||||
* [<font>](TextMeshPro/RichTextFont)
|
||||
* [<font-weight>](TextMeshPro/RichTextFontWeight)
|
||||
* [<gradient>](TextMeshPro/RichTextGradient)
|
||||
* [<i>](TextMeshPro/RichTextBoldItalic)
|
||||
* [<indent>](TextMeshPro/RichTextIndentation)
|
||||
* [<line-height>](TextMeshPro/RichTextLineHeight)
|
||||
* [<line-indent>](TextMeshPro/RichTextLineIndentation)
|
||||
* [<link>](TextMeshPro/RichTextLink)
|
||||
* [<lowercase>](TextMeshPro/RichTextLetterCase)
|
||||
* [<margin>](TextMeshPro/RichTextMargins)
|
||||
* [<mark>](TextMeshPro/RichTextMark)
|
||||
* [<mspace>](TextMeshPro/RichTextMonospace)
|
||||
* [<nobr>](TextMeshPro/RichTextNoBreak)
|
||||
* [<noparse>](TextMeshPro/RichTextNoParse)
|
||||
* [<page>](TextMeshPro/RichTextPageBreak)
|
||||
* [<pos>](TextMeshPro/RichTextPos)
|
||||
* [<rotate>](TextMeshPro/RichTextRotate)
|
||||
* [<s>](TextMeshPro/RichTextStrikethroughUnderline)
|
||||
* [<size>](TextMeshPro/RichTextSize)
|
||||
* [<smallcaps>](TextMeshPro/RichTextLetterCase)
|
||||
* [<space>](TextMeshPro/RichTextSpace)
|
||||
* [<sprite>](TextMeshPro/RichTextSprite)
|
||||
* [<style>](TextMeshPro/RichTextStyle)
|
||||
* [<sub>](TextMeshPro/RichTextSubSuper)
|
||||
* [<sup>](TextMeshPro/RichTextSubSuper)
|
||||
* [<u>](TextMeshPro/RichTextStrikethroughUnderline)
|
||||
* [<uppercase>](TextMeshPro/RichTextLetterCase)
|
||||
* [<voffset>](TextMeshPro/RichTextVOffset)
|
||||
* [<width>](TextMeshPro/RichTextWidth)
|
||||
* [Style Sheets](TextMeshPro/StyleSheets)
|
||||
* [Sprites](TextMeshPro/Sprites)
|
||||
* [Color Gradients](TextMeshPro/ColorGradients)
|
||||
* [Color Gradient Types](TextMeshPro/ColorGradientsTypes)
|
||||
* [Color Gradient Presets](TextMeshPro/ColorGradientsPresets)
|
||||
* [Shaders](TextMeshPro/Shaders)
|
||||
* [SDF Shaders]()
|
||||
* [Distance Field](TextMeshPro/ShadersDistanceField)
|
||||
* [Distance Field Overlay](TextMeshPro/ShadersDistanceField)
|
||||
* [Distance Field (Surface)](TextMeshPro/ShadersDistanceFieldSurface)
|
||||
* [Distance Field - Mobile](TextMeshPro/ShadersDistanceFieldMobile)
|
||||
* [Distance Field Masking - Mobile](TextMeshPro/ShadersDistanceFieldMaskingMobile)
|
||||
* [Distance Field Overlay - Mobile](TextMeshPro/ShadersDistanceFieldMobile)
|
||||
* [Distance Field (Surface) - Mobile](TextMeshPro/ShadersDistanceFieldSurfaceMobile)
|
||||
* [Bitmap Shaders]()
|
||||
* [Bitmap](TextMeshPro/ShadersBitmap)
|
||||
* [Bitmap Custom Atlas](TextMeshPro/ShadersBitmapCustomAtlas)
|
||||
* [Bitmap - MobileBitmapMobile](TextMeshPro/Shaders)
|
||||
* [Settings](TextMeshPro/Settings)
|
@@ -0,0 +1,56 @@
|
||||
# Color emojis
|
||||
|
||||
You can include color glyphs and emojis in text. To do so, import a font file that has color emojis in it and set it as the fallback emojis text assets.
|
||||
|
||||

|
||||
|
||||
## Set up color emojis
|
||||
|
||||
Create a color font asset and add it to the TMP Settings Fallback. Note this is the same as the Project Settings/TextMeshPro/Settings as depicted in the image.
|
||||
|
||||
1. In your project, import a font file that has color emojis in it.
|
||||
2. Right-click in the `Asset` folder, and then select **Create > TextMeshPro > FontAsset > Color**. This ensures that you create the font asset with the right shader (Sprite) and the right atlas rendering mode (Color).
|
||||
3. Open the TMP Settings asset or alternatively via the **Edit > ProjectSettings > TextMesh Pro > Settings**.
|
||||
4. Add the emoji font asset to the **Fallback Emoji Text Assets** section.
|
||||
|
||||

|
||||
|
||||
Alternatively, assigning a color font asset to the text object will work fine provided that the [Emoji Fallback Support](ColorEmojis) option in the Extra Settings of the text component is disabled.
|
||||
|
||||
## Include emojis in text
|
||||
|
||||
To include emojis in text, do the following:
|
||||
|
||||
- Include emojis in text through their Unicode. For example, enter `\U00001f60` to represent a smile.
|
||||
- Use OS Virtual Keyboard.
|
||||
- Copy the emojis from an external Text Editing tool and paste them in your text field.
|
||||
|
||||
To find more information about the Unicode Emojis Standard, see this [link](http://unicode.org/Public/emoji/14.0/).
|
||||
|
||||
## Control Emoji Fallback Search
|
||||
|
||||
The "Emoji Fallback Support" option controls where we search for characters defined in the Unicode Standards as Emojis.
|
||||
|
||||
When this option is enabled (default), the "Fallback Emoji Text Assets" list will be search first for any characters defined as Emojis.
|
||||
|
||||
When this option is disabled, the Primary font asset assigned to the text component will be searched first.
|
||||
|
||||
Basically, this option overrides the character search to prioritize searching thru the "Fallback Emoji Text Assets" list first when the character is an emoji.
|
||||
|
||||
This option is also useful when a font contains black-and-white emojis as it allows the user to control if the emojis contained in the primary will be used or those from the "Fallback Emoji Text Assets" list.
|
||||
|
||||
To update the `Emoji Fallback Support`:
|
||||
1. Select the **Text (TMP)** field in the hierarchy.
|
||||
2. In the Inspector window, under the `Extra Settings` foldout of the **Text (TMP)** field, select the **Emoji Fallback Support** toggle.
|
||||
|
||||

|
||||
|
||||
## Limitations
|
||||
|
||||
The color emojis feature has the following limitations:
|
||||
|
||||
- It doesn't support some OpenType font features, such as chain context and single substitution.
|
||||
- It doesn't support Apple fonts that use the AAT format. It's a predecessor to OpenType.
|
||||
- It doesn't support SVG color glyphs.
|
||||
- Dynamic OS FontAsset has limited support on some iOS devices. The `Apple Color Emoji` font file found on OSX and several iOS devices works fine. However, the `Apple Color Emoji-160px` found on newer iOS devices is not support as the emoji's are encoded in JPEG format which is not supported by FreeType.
|
||||
- Prior to Unity 2023.1, adding a UTF-32 through the inspector sends an error. The emojis won't display in the inspector.
|
@@ -0,0 +1,42 @@
|
||||
# Color Gradients
|
||||
|
||||
You can apply gradients of up to four colors to TextMesh Pro GameObjects. When you add a gradient, TextMesh Pro applies it to each character in the text individually. It stores gradient colors as in each character sprite's vertex colors.
|
||||
|
||||

|
||||
|
||||
_TextMesh Pro text with a four-color gradient_
|
||||
|
||||
Because each character sprite consists of two triangles, gradients tend to have a dominant direction. This is most obvious in diagonal gradients.
|
||||
|
||||
For example, the dominant direction in gradient below favors the red and black colors in the bottom-left and top-right corners
|
||||
|
||||

|
||||
|
||||
When you reverse the gradient colors, so both the top-right and bottom-left corners are yellow, the dominant color changes.
|
||||
|
||||

|
||||
|
||||
|
||||
TextMesh Pro multiplies gradient colors with the text's main vertex color (**Main Settings > Vertex Color** in the TextMesh Pro Inspector). If the main vertex color is white you see only the gradient colors. If it’s black you don’t see the gradient colors at all.
|
||||
|
||||
## Applying a Gradient
|
||||
|
||||
To apply a gradient to a TextMesh Pro GameObject, edit the [Gradient properties](TMPObjectUIText.md#color) in the Inspector.
|
||||
|
||||
> [!NOTE]
|
||||
> - To apply a gradient to only a portion of the text, use the [gradient](RichTextGradient.md) rich text tag.
|
||||
> - To apply a gradient to multiple text objects, use a [gradient preset](ColorGradientsPresets.md).
|
||||
|
||||

|
||||
|
||||
**To apply a color gradient to a TextMesh Pro GameObject:**
|
||||
|
||||
1. Enable the **Main Settings > Color Gradient** property.
|
||||
|
||||
1. Set **Main Settings > Color Gradient > Color Mode** to the [type of gradient](ColorGradientsTypes.md) you want to apply.
|
||||
|
||||
1. Use the **Main Settings > Color Gradient > Colors** settings to choose colors for the gradient. For each color you can:
|
||||
|
||||
- Click the color swatch to open a [Color Picker](https://docs.unity3d.com/Manual/EditingValueProperties.html).
|
||||
- Use the eyedropper to pick a color from anywhere on your screen.
|
||||
- Enter the color’s hexadecimal value directly in the text field.
|
@@ -0,0 +1,36 @@
|
||||
# Gradient Presets
|
||||
|
||||
Use gradient presets to reuse the same color gradients across text objects. A gradient preset overrides the text’s local gradient type and colors.
|
||||
|
||||
You have to store Gradient presets in a specific folder so TextMesh Pro can find them and include them in builds. You can change the folder from the [TextMesh Pro settings](Settings.md#color-gradient-presets).
|
||||
|
||||
## Creating gradient presets
|
||||
|
||||
To create a gradient preset, choose **Assets > Create > TextMesh Pro > Color Gradient** from the menu.
|
||||
|
||||
This adds a new TextMesh Pro Color Gradient Asset to the Scene, and opens it in the Inspector.
|
||||
|
||||

|
||||
|
||||
You can then select a [gradient type](ColorGradientTypes.md) from the **Color Mode** dropdown, and set the gradient **Colors**.
|
||||
|
||||
## Applying gradient presets
|
||||
|
||||
You apply a gradient preset to text from the TextMesh Pro Inspector.
|
||||
|
||||
**To apply a gradient preset:**
|
||||
|
||||
1. Enable the **Main Settings > Color Gradient** property.
|
||||
|
||||
1. Open the Object Picker (circle icon) for **Main Settings > Color Preset**, and choose choose a preset
|
||||
|
||||
When you apply a gradient preset, the Inspector overrides the text's gradient type and colors with the values from the preset.
|
||||
|
||||
> [!CAUTION]
|
||||
> If you modify the gradient settings in the TextMesh Pro Inspector after you apply a preset, it affects the preset itself. Changes affect every object that uses the same preset.
|
||||
|
||||
## Removing gradient presets
|
||||
|
||||
To remove a gradient preset, open the Object Picker (circle icon) for **Main Settings > Color Preset**, and choose **None**.
|
||||
|
||||
When you remove the preset, the text reverts to its local gradient properties.
|
@@ -0,0 +1,81 @@
|
||||
# Color Gradient Types
|
||||
|
||||
You can apply the following types of gradients to text.
|
||||
|
||||
- **[Single](#single-color):** A single color that is TextMesh Pro multiplies with the text object's vertex color.
|
||||
|
||||
- **[Horizontal](#horizontal-gradients):** A two-color side-to-side gradient.
|
||||
|
||||
- **[Vertical](#vertical-gradients):** A two-color up-and-down gradient.
|
||||
|
||||
- **[Four Corner](#four-corner-gradients):** A four-color gradient. Each color radiates from one corner.
|
||||
|
||||
<br/>
|
||||
_The TexMesh Pro color gradient settings_ <br/><br/>
|
||||
|
||||
The number of colors available in the **Colors** settings depends on the type of gradient you choose. Each swatch corresponds to the color's origin on a character sprite.
|
||||
|
||||
The image above shows a the settings for a four color gradient. Each color originates in the corresponding corner of the sprite (top-left, top-right, bottom-left, bottom-right). IT produces the following gradient:
|
||||
|
||||

|
||||
|
||||
|
||||
## Single Color
|
||||
|
||||
The **Single** gradient type applies a single color.
|
||||
|
||||

|
||||
|
||||
## Horizontal Gradients
|
||||
|
||||
The **Horizontal** gradient type applies two colors, and produces a side to side transition between them on each character.
|
||||
|
||||

|
||||
|
||||
<br/><br/>
|
||||
|
||||
## Vertical Gradients
|
||||
|
||||
The **Vertical** gradient type consists of two colors, and produces an up and down transition between the two on each character.
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
## Four Corner Gradients
|
||||
|
||||
The **Four Corner** gradient type applies four colors. Each one radiates out from its assigned corner of each character.
|
||||
|
||||
<br/><br/>
|
||||
|
||||

|
||||
|
||||
This is the most versatile gradient type. By varying some colors and keeping others identical, you can create different kinds of gradients. For example:
|
||||
|
||||
- Give three corners one color and the fourth a different color.
|
||||
|
||||

|
||||
|
||||
- Give pairs of adjacent corners the same color to create horizontal or vertical gradients.
|
||||
|
||||
<br/><br/>
|
||||
|
||||

|
||||
|
||||
- Give pairs of diagonally opposite corners the same color to create diagonal gradients.
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
- Create horizontal and vertical 3-color gradients with a dominant color at one end and a transition between two colors at the other.
|
||||
|
||||
<br/><br/>
|
||||
|
||||

|
||||
|
||||
- Give two diagonally opposite corners same color and give the other two corners different colors to create a diagonal stripe 3-color gradient.
|
||||
|
||||
<br/><br/>
|
||||
|
||||

|
@@ -0,0 +1,27 @@
|
||||
# Styles
|
||||
|
||||
Use styles to apply additional formatting to some or all of the text in a TextMesh Pro object. A style is a combination of opening and closing [rich text tags](RichText.md), and can also include leading and trailing characters.
|
||||
|
||||
* To define styles, use a TextMesh Pro [style sheet](StyleSheets.md).
|
||||
|
||||
* To apply styles to your text, use the [`<style>` rich text tag](RichTextStyle.md) in the text editor.
|
||||
|
||||
## Custom styles example
|
||||
|
||||
Say you want headings in your text to be big, red, and bold with an asterisk to either side and a line break at the end.
|
||||
|
||||

|
||||
|
||||
That requires several tags for each heading, which makes the formatting cumbersome to maintain, and the text more difficult to read in the editor.
|
||||
|
||||
`<font-weight=700><size=2em><color=#FF0000>*Heading*</color></size></font-weight><br>`
|
||||
|
||||
It's easier to put all of the markup in a style. The example below shows a style called `H1`.
|
||||
|
||||

|
||||
|
||||
Once you create the style you can format all of your headings with a single `<style>` tag.
|
||||
|
||||
`<style="H1">Heading</style>`
|
||||
|
||||
Not only does that make the text easier to read in the editor, you can now update all of the headings in your text just by changing the style.
|
@@ -0,0 +1,36 @@
|
||||
# Debugging TextMesh Pro text
|
||||
|
||||
Use the Text Info Debug Tool to display diagnostic information about a TextMesh Pro GameObject in the Scene view and the Inspector.
|
||||
|
||||
For example, you can display lines that indicate font metrics such as the line height, or the offset for superscript and subscript text. This can help you diagnose problems with fonts you import.
|
||||
|
||||

|
||||
_The TextMesh Pro debug tool set to show character bounding boxes and font metrics_
|
||||
|
||||
>[NOTE!]
|
||||
>The debug tool is part of the TextMesh Pro Examples & Extras package. You can install the package from the menu (select **Window > TextMesh Pro > Import TMP Examples and Extras**) or the [TextMesh Pro settings](Settings.md).
|
||||
|
||||
To use the debug tool:
|
||||
|
||||
1. Open a TextMesh Pro GameObject in the Inspector.
|
||||
|
||||
2. [Add](https://docs.unity3d.com/Manual/UsingComponents.html) a **TMP_TextInfoDebugTool** component.
|
||||
|
||||
3. From the **TMP_Text Info Debug Tool** section, turn debug [settings](#text-info-debug-tool-properties) on and off. You can see the results in the Scene view.
|
||||
|
||||
|
||||
## Text Info Debug Tool properties
|
||||
|
||||

|
||||
|
||||
|Property:|Function:|
|
||||
|-|-|
|
||||
|**Show Characters** | Displays each character's bounding box, as well as reference lines for font metrics, in the Scene view. |
|
||||
|**Show Words** | Displays the bounding box for each word in the Scene view. |
|
||||
|**Show Links** | Displays the bounding box for each link in the Scene view. |
|
||||
|**Show Lines** | Displays the bounding box for line of text word in the Scene view. |
|
||||
|**Show Mesh Bounds** | Displays the bounding box for the entire block of text in the Scene view. |
|
||||
|**Show Text Bounds** | Displays the boundary of the area that text can occupy, as defined by the font metrics, in the Scene view. |
|
||||
|**Object Stats** | Shows statistics about the TextMesh Pro GameObject, such as the number of characters, words, lines, and spaces. |
|
||||
|**Text Component** | Links to the TextMesh Pro GameObject's Text component. |
|
||||
|**Transform** | Links to the TextMesh Pro GameObject's RectTransform component. |
|
@@ -0,0 +1 @@
|
||||
# Debugging TextMesh Pro text
|
@@ -0,0 +1,75 @@
|
||||
# Font Assets
|
||||
|
||||
To use different fonts with TextMesh Pro, you need to create font assets. TextMesh Pro has its own font Asset format that is distinct from, but related to, [Unity's regular font Asset format](https://docs.unity3d.com/2019.1/Documentation/Manual/class-Font.html). You create TextMesh Pro font assets _from_ Unity font assets.
|
||||
|
||||
Every TextMesh Pro font Asset has two sub-Assets:
|
||||
|
||||
* **Font atlas:** a black and white or grayscale texture file that contains all of the characters included in the font Asset.<br/><br/><br/>_Example of a font atlas_
|
||||
* **Font material:** a material that controls the appearance of TextMesh Pro text using one of the [TextMesh Pro shaders](Shaders.md).
|
||||
|
||||
Font assets must be in a specific folder so TextMesh Pro can find them and include them in builds. To change the default folder for font assets, got to the [TextMesh Pro settings](Settings.md) and set the **Default Font Asset > Path** option.
|
||||
|
||||
## Creating Font Assets
|
||||
|
||||
To create a TextMesh Pro font Asset, use the TexMesh Pro [Font Asset Creator](FontAssetsCreator.md).
|
||||
|
||||
You can also create an empty TextMesh Pro font Asset from the Unity main menu. An empty font asset does not contain any characters by default, you must add them later. To create an empty TextMesh Pro font asset, select a Unity font Asset and then select **Asset > Create > TextMeshPro > Font Asset** from the menu.
|
||||
|
||||
## Types of font atlas
|
||||
|
||||
Font Assets can have the following types of font atlas:
|
||||
|
||||
* **Distance Field:** This type of atlas contains [signed distance field (SDF)](FontAssetsSDF.md) information.<br/><br/>This is the recommended Font Asset type for most applications because SDF atlases produce text that is smooth when transformed.
|
||||
|
||||
* **Smooth/Hinted Smooth:** This type of atlas is an antialiased bitmap texture. A Hinted smooth atlas aligns glyph pixels with texture pixels to produce a smoother result.<br/><br/>Smooth atlases work well for static text that is viewed head on, in situations where there is a good correspondence between texture pixels and screen pixels. Transforming text generated from a smooth atlas blurs the text edges.
|
||||
|
||||
* **Raster/Raster Hinted:** Raster atlases are un-smoothed bitmap textures. They almost always produce text with jagged, pixellated edges. The Hinted rater atlases align glyph pixels with texture pixels to produce a smoother result.
|
||||
|
||||
## Get Font Features
|
||||
|
||||
This option determines if OpenType font features should be retrieved from the source font file as new characters and glyphs are added to the font asset. Disabling this option will prevent extracting font features.
|
||||
|
||||
To update the Get Font Features option on a FontAsset:
|
||||
1. Select the FontAsset
|
||||
2. In the FontAsset inspector, navigate to the Generation Settings section.
|
||||
3. Select **Get Font Features**.
|
||||
|
||||

|
||||
|
||||
## Reset
|
||||
The `Reset` context menu option clears all tables which includes the Character and Glyph tables along with all font features tables such as the Ligature, Glyph Adjustment, Mark to Base, Mark to Mark tables. This option also clears the font asset's atlas texture and resets it back to size zero.
|
||||
|
||||
To reset a FontAsset:
|
||||
1. Select the FontAsset
|
||||
2. Expand the top right menu in the FontAsset Inspector.
|
||||
3. Select **Reset**.
|
||||
|
||||

|
||||
|
||||
## Clear Dynamic Data
|
||||
The `Clear Dynamic Data` context menu option clears the character and glyph tables as well as the font asset's atlas texture which is also resized back to size zero. This option preserves all font feature table data such as Ligatures, Glyph Adjustment, Mark to Base, Mark to Mark, etc.
|
||||
|
||||
To clear a FontAsset:
|
||||
1. Select the FontAsset
|
||||
2. Expand the top right menu in the FontAsset Inspector.
|
||||
3. Select **Clear Dynamic Data**.
|
||||
|
||||

|
||||
|
||||
This preserves the custom ligatures, kernings, and diacritical marks you added to the font asset when clearing the atlas.
|
||||
|
||||
## Clear Dynamic Data on Build
|
||||
|
||||
The "Clear Dynamic Data on Build" option works like the "Clear Dynamic Data" context menu option but also clears data when building the project or closing the Editor.
|
||||
|
||||
When enabled, this option resizes the texture to 0 (empty) during the build process.
|
||||
|
||||
For dynamic FontAssets, it resets the glyph atlas, character table, and glyph table to their initial states. This feature helps reduce build size by minimizing the FontAsset's data footprint.
|
||||
|
||||
To update the Clear Dynamic Data on Build option:
|
||||
|
||||
1. Select the FontAsset
|
||||
2. In the FontAsset inspector, navigate to the Generation Settings section.
|
||||
3. Select **Clear Dynamic Data on Build**.
|
||||
|
||||

|
@@ -0,0 +1,86 @@
|
||||
## Font Asset Creator
|
||||
|
||||
The Font Asset Creator converts [Unity font assets](FontAssets.md) into TextMesh Pro font assets. You can use it to create both Signed [Distance Field (SDF)](FontAssetsSDF.md) fonts and bitmap fonts.
|
||||
|
||||
When you create a new font Asset, TextMesh Pro generates the Asset itself, as well as the atlas texture and material for the font.
|
||||
|
||||
After you create a TextMesh Pro font Asset, you can delete the Unity font Asset you used as a source, although you may want to keep it in the Scene in case you need to regenerate the TextMesh Pro font Asset.
|
||||
|
||||
## Creating a font Asset
|
||||
|
||||
Before you start, make sure that you've already imported the font (usually a TrueType .ttf file) you want to use into the project. For more information about importing fonts into Unity, see the documentation on [Fonts](https://docs.unity3d.com/Manual/class-Font.html) in the Unity manual.
|
||||
|
||||
**To create a TextMesh Pro font Asset:**
|
||||
|
||||
1. From the menu, choose: **Window > TextMesh Pro > Font Asset Creator** to open the Font Asset Creator.
|
||||
|
||||
1. Choose a **Source Font File**. This the Unity font Asset that you want to convert into a TextMesh Pro font Asset.
|
||||
|
||||
1. Adjust the **[Font Settings](#FontAssetCreatorSettings)** as needed, then click **Generate Font Atlas** to create the atlas texture<br/><br/>The atlas, and information about the font Asset appear in the texture preview area.<br/><br/>IMAGE
|
||||
|
||||
1. Continue adjusting the settings and regenerating the atlas until you're satisfied with the result.
|
||||
|
||||
1. Click **Save** or **Save as...** to save the font Asset to your project.<br/><br/>You must save the Asset to a **Resources** folder to make it accessible to TextMesh Pro.
|
||||
|
||||
<a name="FontAssetCreatorSettings"></a>
|
||||
## Font Asset Creator Settings:
|
||||
|
||||
|Property:||Function:|
|
||||
|-|-|-|
|
||||
|**Source Font File**||Select a font from which to generate a Text Mesh Pro font Asset.<br/><br/>This font is not included in project builds, unless you use it elsewhere in the project, or put it in a Resources folder.<br/><br/>You can use one of the default TextMesh Pro font assets, or [import your own](https://docs.unity3d.com/Manual/class-Font.html).|
|
||||
|**Sampling Point Size**||Set the font size, in points, used to generate the font texture.|
|
||||
|**Auto Sizing**||Use the largest point size possible while still fitting all characters on the texture.<br/><br/>This is the usual setting for SDF fonts.|
|
||||
|**Custom Size**||Use a custom point size. Enter the desired size in the text box.<br/><br/>Use this setting to achieve pixel-accurate control over bitmap-only fonts.|
|
||||
|**Padding**||Specify the space, in pixels, between characters in the font texture.<br/><br/>Padding provides the space required to render character separately, and to generate the SDF gradient (See the documentation on [Font Assets](FontAssetsSDF.md) for details).<br/><br/>The larger the padding, the smoother the transition, which allows for higher-quality rendering and larger effects, like thick outlines.<br/><br/>A padding of 5 is often fine for a 512x512 texture.|
|
||||
|**Packing Method**||Specify how to fit the characters into the font texture.|
|
||||
||Optimum|Finds the largest possible automatic font size that still fits all characters in the texture.<br/><br/>Use this setting to generate the final font texture.
|
||||
||Fast|Computes character packing more quickly, but may use a smaller font size than Optimum mode.<br/><br/>Use this setting when testing out font Asset creation settings.|
|
||||
|**Atlas Resolution**||Set the size width and height of the font texture, in pixels.<br/><br/>A resolution of 512 x 512 is fine for most fonts, as long as you are only including ASCII characters. Fonts with more characters may require larger resolutions, or multiple atlases. <br/><br/>When using an SDF font, a higher resolution produces finer gradients, and therefore higher quality text.|
|
||||
|**Character Set**||The characters in a font file aren't included in the font Asset automatically. You have to specify which ones you need. You can select a predefined character set, provide a list of characters to include, or include all of the characters in an existing font Asset or text Asset.|
|
||||
||ASCII|Includes the visible characters in the ASCII character set.|
|
||||
||Extended ASCII|Includes the visible characters in the extended ASCII character set.|
|
||||
||ASCII Lowercase|Includes only visible lower-case characters from the ASCII character set.|
|
||||
||ASCII Uppercase|Includes only visible upper-case characters from the ASCII character set.|
|
||||
||Numbers + Symbols|Includes only the visible numbers and symbols from the ASCII character set.|
|
||||
||Custom Range|Includes a range of characters that you define.<br/><br/>Enter a sequence of decimal values, or ranges of values, to specify which characters to include.<br/><br/>Use a hyphen to separate the first and last values of a range. Use commas to separate values and ranges (for example `32-126,160,8230`).<br/><br/>You can also choose an existing font Asset to include the characters in that Asset.|
|
||||
||Unicode Range (Hex)|Includes a range of characters that you define.<br/><br/>Enter a sequence of unicode hexadecimal values, or ranges of values, to specify which characters to include.<br/><br/>Use a hyphen to separate the first and last values of a range. Use commas to separate values and ranges (for example `20-7E,A0,2026`).<br/><br/>You can also choose an existing font Asset to include the characters in that Asset.|
|
||||
||Custom Characters|Includes a range of characters that you define.<br/><br/>Enter a sequence of characters to specify which characters to include.<br/><br/>Enter characters one after the other, with no spaces or delimiting characters in between (for example `abc123*#%`).<br/><br/>You can also choose an existing font Asset to include the characters in that Asset.|
|
||||
||Characters from File|Includes all the characters in a text Asset that you specify.<br/><br/>Use this option when you want to save your character set.|
|
||||
|**Font Style**||Apply basic font styling when creating a bitmap-only font Asset.<br/><br/>For SDF fonts, you configure the styling in the shader rather than the font Asset.|
|
||||
||Normal|Generates characters with no styling.|
|
||||
||Bold, Italic, Bold_Italic|Generates the font Asset with bold characters, italicized characters, or both.<br/><br/>With these settings, you can set a strength value that applied to bolding and italicization|
|
||||
||Outline|Generates the font Asset with outline characters.|
|
||||
||Bold_Sim|Generates the font Asset with a simulated bold.|
|
||||
|**Render Mode**||Specify the render mode to use when outputting the font atlas.|
|
||||
||SMOOTH|Renders the atlas to an antialiased bitmap.|
|
||||
||RASTER|Renders the atlas to a non-antialiased bitmap.|
|
||||
||SMOOTH_HINTED|Renders the atlas to an antialiased bitmap, and aligns character pixels with texture pixels for a crisper result.|
|
||||
||RASTER_HINTED|Renders the atlas to a non-antialiased bitmap and aligns character pixels with texture pixels for a crisper result.|
|
||||
| |SDF| Renders the atlas using a slower, but more accurate SDF generation mode, and no oversampling. |
|
||||
| |SDFAA| Renders the atlas using a faster, but less accurate SDF generation mode. It produces font atlases that are sufficient for most situations.|
|
||||
| |SDFAA_HINTED| Renders the atlas using a faster, but less accurate SDF generation mode, and aligns character pixels with texture pixels for a crisper result.. It produces font atlases that are sufficient for most situations |
|
||||
| |SDF8| Renders the atlas using a slower, but more accurate SDF generation mode, and 8x oversampling. |
|
||||
| |SDF16| Renders the atlas using a slower, but more accurate SDF generation mode, and 16x oversampling. |
|
||||
| |SDF32| Renders the atlas using a slower, but more accurate SDF generation mode, and 32x oversampling. Use this setting for fonts with complex or small characters. |
|
||||
|**Get Kerning Pairs**||Enable this option to copy the kerning data from the font.<br/><br/>Kerning data is used to adjust the spacing between specific character pairs to produce a more visually pleasing result.<br/><br/>**Note:** It isn't always possible to import kerning data. Some fonts store kerning pairs in their glyph positioning (GPOS) table, which is not supported by FreeType, the font engine used by TextMesh Pro. Other fonts do not store kerning pairs at all.|
|
||||
|**Generate Font Atlas**||Generate the font atlas texture.|
|
||||
|**Save**||Save the current font atlas.|
|
||||
|**Save As**||Save the current font atlas as a new font Asset.|
|
||||
|
||||
## Tips for creating font assets
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Characters in the font texture need some padding between them so they can be rendered separately. This padding is specified in pixels.
|
||||
Padding also creates room for the SDF gradient. The larger the padding, the smoother the transition, which allows for higher-quality rendering and larger effects, like thick outlines. A padding of 5 is often fine for a 512x512 texture.
|
||||
|
||||
|
||||
For most fonts, a 512x512 texture resolution is fine when including all ASCII characters.
|
||||
When you need to support thousands of character, you will have to use large textures. But even at maximum resolution, you might not be able to fit everything. In that case, you can split the characters by creating multiple font assets. Put the most often used characters in a main font Asset, and the others in a fallback font assets.
|
@@ -0,0 +1,52 @@
|
||||
|
||||
# Dynamic fonts assets
|
||||
Normally when you generate a font Asset using the Font Asset Creator, you choose which characters to include, and bake them into a Font Atlas texture.
|
||||
|
||||
Dynamic font assets work the other way around. Instead of baking characters into an atlas in advance, you start with an empty atlas to which characters are added automatically as you use them.
|
||||
|
||||
This makes dynamic fonts assets more flexible, but that flexibility comes at a cost.
|
||||
|
||||
* Dynamic fonts require more computational resources than static fonts.
|
||||
|
||||
* Dynamic font assets maintain a link to the original font file used to create them. That means:
|
||||
|
||||
* During development, you must keep the font file in the project. You cannot delete it as you can the source fonts of static font assets.
|
||||
* Source fonts of any dynamic font assets in your game are included in builds, which can increase build size.
|
||||
|
||||
|
||||
This has several uses, for example:
|
||||
|
||||
* Use dynamic fonts during development to capture characters you forgot to include in your baked font assets.
|
||||
|
||||
* Use dynamic fonts in runtime when you don't know in advance which characters the user will enter in a text field.
|
||||
|
||||
## Creating a dynamic font Asset
|
||||
|
||||
Empty font assets are dynamic by default. To create one:
|
||||
|
||||
* From Unity's main menu, choose **Assets > Create > TextMeshPro > Font Asset** or press **Ctrl/Cmd + Shift + F12**.
|
||||
|
||||
To make an existing font Asset dynamic:
|
||||
|
||||
1. Select Asset and open it in the Inspector.
|
||||
|
||||
1. Set the **Generation Settings > Atlas Population Mode** property to **Dynamic**.
|
||||
|
||||
## Resetting a dynamic font Asset
|
||||
|
||||
You reset TextMesh Pro dynamic font assets, the same way you reset other components: by choosing **Reset** from the gear icon menu or context menu in the Inspector.
|
||||
|
||||
[IMAGE]
|
||||
|
||||
However, instead of resetting all of the Asset's properties to their default values, the command affects only:
|
||||
|
||||
* The Font Atlas
|
||||
* The Character Table
|
||||
* The Glyph Table
|
||||
* The Glyph Adjustment Table (kerning)
|
||||
|
||||
These are reset to include only the characters/glyphs used by TextMesh Pro text objects that use the font Asset.
|
||||
|
||||
If the Asset is currently unused, TextMesh Pro resizes the atlas texture to 0 x 0 pixels.
|
||||
|
||||
**NOTE:** Resetting a static font Asset leaves the atlas texture as-is, but empties the character-, glyph-, and glyph adjustment tables.
|
@@ -0,0 +1,34 @@
|
||||
# Fallback font assets
|
||||
|
||||
A font atlas, and by extension a font Asset, can only contain a certain number of glyphs. The exact number depends on the font, the size of the atlas texture, and the settings you use when generating the atlas. The fallback font system allows you to specify other font assets to search when TextMesh Pro can't find a glyph in a text object's font Asset.
|
||||
|
||||
This is useful in a variety of situations, including:
|
||||
* Working with languages that have very large alphabets (Chinese, Korean, and Japanese, for example). Use fallback fonts to distribute an alphabet across several assets.
|
||||
|
||||
* Designing for mobile devices, where an imposed maximum texture size prevents you from fitting an entire set of glyphs in a single atlas of sufficient quality.
|
||||
|
||||
* Including special characters from other alphabets in your text.
|
||||
|
||||
## Local and general fallback font assets
|
||||
|
||||
Every font Asset can have its own list of fallback font assets. You set these in the [font Asset properties](FontAssetsProperties.md).
|
||||
|
||||
You can also set general fallback font assets that apply to every TextMesh Pro font Asset in your project. You set these in the [TextMesh Pro settings](Settings.md).
|
||||
|
||||
## The fallback chain
|
||||
|
||||
In addition to a text object's fallback fonts, TextMesh Pro searches several other assets for missing glyphs. Together, these assets form the fallback chain.
|
||||
|
||||
The table below lists the assets in the fallback chain in the order in which they are searched.
|
||||
|
||||
|Position:| Asset: | Defined in:|Notes:|
|
||||
|:-:|-|-||
|
||||
|1 | TextMesh Pro object's primary **Font Asset** | [Text object properties](TMPObjects.md) ||
|
||||
|2 | Primary font assets **Fallback Font Assets** | [Font Asset properties](FontAssetsProperties.md) |TexMesh Pro searches these assets in the order they're listed in the [font Asset properties](FontAssetsProperties.md). <br/><br/>The search is recursive, and includes each fallback Asset's fallback assets. |
|
||||
|3 | Text object's **Sprite Asset** | [Text object properties](TMPObjects.md) |When searching sprite assets, TextMesh Pro looks for sprites with an assigned unicode value that matches the missing character's unicode value.|
|
||||
|4 | General **Fallback Font Assets** | [TextMesh Pro settings](Settings.md) |TexMesh Pro searches these assets in the order they're listed in the [font Asset properties](FontAssetsProperties.md). <br/><br/>The search is recursive, and includes each fallback Asset's fallback assets. |
|
||||
|5 | **Default Sprite Asset** | [TextMesh Pro settings](Settings.md) |When searching sprite assets, TextMesh Pro looks for sprites with an assigned unicode value that matches the missing character's unicode value.|
|
||||
|6 | **Default Font Asset** | [TextMesh Pro settings](Settings.md) | |
|
||||
|7 | **Missing glyphs** character | [TextMesh Pro settings](Settings.md) | |
|
||||
|
||||
The fallback chain search is designed to detect circular references so each Asset in the chain is only searched once.
|
@@ -0,0 +1,26 @@
|
||||
# Line metrics.
|
||||
|
||||
TextMesh Pro sets line metrics automatically when you generate a font Asset.
|
||||
|
||||
If the generated values produce strange or incorrect results, you can tweak the line metrics settings to fine-tune the font.
|
||||
|
||||
Most line metric values are relative to the **Baseline**, which is the horizontal line that characters sit on.
|
||||
|
||||
- Values for above-the-baseline metrics, such as the **Ascender** height, are greater that the **Baseline** value.
|
||||
- Values for below-the-baseline metrics, such as the **Descender** height, are less than **Baseline** value.
|
||||
|
||||

|
||||
|
||||
|Metric:|Function:|
|
||||
|-|-|
|
||||
|**Line Height**|The distance between the tops of consecutive lines.<br/><br/>If you set the line height to a value greater than the combined size of the **Ascender** and **Descender**, it creates a gap between lines.<br/><br/>If you set a line height to a value less than the combined size of the ascender and descender results in potential overlap between characters on different lines.|
|
||||
|**Ascender**|The ascender height, which specifies how far characters can extend above the baseline. It corresponds to the top of a line.|
|
||||
|**Cap Height**|The height of capital letters from the baseline.|
|
||||
|**Baseline**|The baseline height.<br/><br/>The baseline is the horizontal line that characters sit on.|
|
||||
|**Descender**|The descender height, which specifies how far characters can extend below the baseline.|
|
||||
|**Underline Offset**|The position of underlines relative to the baseline.|
|
||||
|**Strikethrough Offset**|The position of strikethrough lines relative to the baseline.|
|
||||
|**Superscript/ Subscript Offset**|Adjust the baseline for superscript and subscript text.|
|
||||
|**Super/ Subscript Size**|The scale of superscript and subscript text relative to the normal font size.|
|
||||
|**Padding**|The amount of padding between characters in the font atlas texture.<br/><br/>TextMesh Pro sets this value when you generate the font Asset. It is not editable.|
|
||||
|**Width/Height**|The font atlas texture's width and height, in pixels.<br/><br/>TextMesh Pro sets these values when you generate the font Asset. They are not editable.|
|
@@ -0,0 +1,157 @@
|
||||
# Font Asset Properties
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||

|
||||
|
||||
Properties are divided into the following sections:
|
||||
|
||||
||||
|
||||
|-|-|-|
|
||||
|**A** | **[Face Info](#face-info)** ||
|
||||
|**B** | **[Generation Settings](#generation-settings)** ||
|
||||
|**C** | **[Atlas & Material](#atlas-material)** ||
|
||||
|**D** | **[Font Weights](#font-weights)** ||
|
||||
|**E** | **[Fallback Font Assets](#fallback-font-assets)** ||
|
||||
|**F** | **[Character Table](#character-table)** | |
|
||||
|**G** | **[Glyph Table](#glyph-table)** ||
|
||||
|**H** | **[Glyph Adjustment Table](#glyph-adjustment-table)** ||
|
||||
|
||||
### Face Info
|
||||
|
||||
The Face Info properties control the font's line metrics. They also include read-only properties that the [Font Asset Creator](FontAssetsCreator.md) generates when you create the Asset.
|
||||
|
||||

|
||||
_Line metrics_
|
||||
|
||||
|Property:|Function:|
|
||||
|-|-|
|
||||
|**Update Texture Atlas**|Open the [Font Asset Creator](FontAssetsCreator.md) pre-configured to modify and regenerate this font Asset.|
|
||||
|**Family Name**|The name of the font used to create this font Asset.<br/><br/>TextMesh Pro sets this value when you generate the font Asset. You cannot change it manually.|
|
||||
|**Style Name**|The style of the font used to create this font Asset. For example, **Regular**, **Bold**, **Italic**, and so on.<br/><br/>TextMesh Pro sets this value when you generate the font Asset. You cannot change it manually.|
|
||||
|**Point Size**|The font size in points.<br/><br/>TextMesh Pro bakes this value into the atlas texture when you generate the font Asset. You cannot change it manually.|
|
||||
|**Scale**|Scales the font by this amount. For example, a value of **1.5** scales glyphs to 150% of their normal size.|
|
||||
|**Line Height**|Controls the distance between the tops of consecutive lines.<br/><br/>If you set a line height greater than the sum of the **Ascent Line** and **Descent Line** values, it creates in a gap between lines.<br/><br/>If you set a line height greater than the sum of the **Ascent Line** and **Descent Line** values, characters on different lines might overlap.|
|
||||
|**Ascent Line**|Controls the maximum distance that glyphs can extend above the baseline. It corresponds to the top of a line.|
|
||||
|**Cap Line**|Controls the distance between the base line and the tops of uppercase glyphs.|
|
||||
|**Mean Line**|Controls the maximum height for non-ascending lowercase glyphs (for example. "a" and "c", but not "b" and "d," which have ascenders).<br/><br/>The tops of rounded glyphs sometimes extend a slightly above the mean line.|
|
||||
|**Baseline**|Controls the height of the baseline.<br/><br/>The baseline is the horizontal line that characters sit on.|
|
||||
|**Descent Line**|Controls the maximum distance that glyphs can extend below the baseline.|
|
||||
|**Underline Offset**|Controls the position of underlines relative to the baseline.|
|
||||
|**Underline Thickness** | Controls the thickness of underlines. |
|
||||
|**Strikethrough Offset**|Controls the position of strikethrough lines relative to the baseline.|
|
||||
|**Superscript Offset**| Offsets superscript text from the baseline.|
|
||||
|**Superscript Size**|Scales superscript text relative to the normal font size.|
|
||||
|**Subscript Offset**| Offsets subscript text from the baseline.|
|
||||
|**Subscript Size**|Scales subscript text relative to the normal font size.|
|
||||
| **Tab Width** | Specifies the width of a TAB character. |
|
||||
|
||||
### Generation Settings
|
||||
|
||||
The [Font Asset Creator](FontAssetsCreator.md) generates these values when you generate the Font Asset.
|
||||
|
||||
> [!NOTE]
|
||||
> When the **Atlas Population Mode** is set to **Dynamic**, you can change the atlas size without regenerating the atlas.
|
||||
|
||||
|Property:||Function:|
|
||||
|-|-|-|
|
||||
|**Source Font File** || |
|
||||
|**Atlas Population Mode** || |
|
||||
| |Dynamic| |
|
||||
| |Static| |
|
||||
|**Atlas Render Mode** || |
|
||||
||SMOOTH|Renders the atlas to an antialiased bitmap.|
|
||||
||RASTER|Renders the atlas to a non-antialiased bitmap.|
|
||||
||SMOOTH_HINTED|Renders the atlas to an antialiased bitmap, and aligns character pixels with texture pixels for a crisper result.|
|
||||
||RASTER_HINTED|Renders the atlas to a non-antialiased bitmap and aligns character pixels with texture pixels for a crisper result.|
|
||||
| |SDF| Renders the atlas using a slower, but more accurate SDF generation mode, and no oversampling. |
|
||||
| |SDFAA| Renders the atlas using a faster, but less accurate SDF generation mode. It produces font atlases that are sufficient for most situations.|
|
||||
| |SDFAA_HINTED| Renders the atlas using a faster, but less accurate SDF generation mode, and aligns character pixels with texture pixels for a crisper result.. It produces font atlases that are sufficient for most situations |
|
||||
| |SDF8| Renders the atlas using a slower, but more accurate SDF generation mode, and 8x oversampling. |
|
||||
| |SDF16| Renders the atlas using a slower, but more accurate SDF generation mode, and 16x oversampling. |
|
||||
| |SDF32| Renders the atlas using a slower, but more accurate SDF generation mode, and 32x oversampling. Use this setting for fonts with complex or small characters. |
|
||||
|**Sampling Point Size** || The size, in points, of characters in the font texture. |
|
||||
|**Padding**||The amount of padding between characters in the font atlas texture.<br/><br/>This value is set when you generate the font Asset, and is not editable.|
|
||||
|**Atlas Width/Height**||The width and height the font atlas texture.<br/><br/>Choose for each dimension, choose one of the available values from the drop-down menu.|
|
||||
|**Multi Atlas Textures** | | |
|
||||
|
||||
|
||||
### Atlas & Material
|
||||
|
||||
This section lists the sub-assets that the [Font Asset Creator](FontAssetsCreator.md) creates when you generate the Asset. Do not edit these directly.
|
||||
|
||||
|Property:|Function:|
|
||||
|-|-|
|
||||
|Font Atlas|The font texture atlas created when you generated the font Asset.|
|
||||
|Font Material|The font material created when you generated the font Asset.|
|
||||
|
||||
### Font Weights
|
||||
|
||||
The Font Weights options control the appearance of bold and italicized text. There are two ways of doing this:
|
||||
|
||||
1. Create different bold and italic variants of the font Asset, and add them to the **Font Table**.<br/><br/>You can specify regular and italic fonts for weights ranging from 100 (Thin) to 900 (Black).
|
||||
|
||||
1. Define "fake" bolding and italicization by setting the **Font Weight > Italic Style** and **Bold Weight** properties.<br/><br/>These settings tell TextMesh Pro how to adjust characters in the current font Asset when you bold or italicize text.
|
||||
|
||||
|
||||
|Property:||Function:|
|
||||
|-|-|-|
|
||||
|**Font Table**||Specify font assets to use for the following font variants.<br/><br/>100 - Thin<br/>200 - Extra-Light<br/>300 - Light<br/>400 - Regular (italic only)<br/>500 - Medium<br/>600 - Semi-Bold<br/>700 - Bold<br/>800 - Heavy<br/>900 - Black <br/><br/> * **400 - Regular > Regular Typeface** is the current font Asset. You cannot change it.<br/><br/> If you don't specify font assets, TextMesh Pro "fakes" bolding and italicization according to the rest of the the **Font Weights** settings. Using "faked" font weights limits you to regular and italic versions of normal and bold text (equivalent to weights of 400 and 700 respectively). |
|
||||
|**Normal Weight**||Set the regular font weight to use when no font Asset is available.|
|
||||
|**Bold Weight**||Set the bold font weight assumed when no font Asset is available.|
|
||||
|**Spacing Offset**||Add space between characters when using the normal text style.|
|
||||
|**Bold Spacing**||Add space between characters when using the fake bold text style (meaning you haven’t specified a Bold font Asset).|
|
||||
|**Italic Style**||If you don’t specify a font Asset for **400 - Regular > Italic Style** variant, TextMeshPro slanting the character sprites in the Normal Style font Asset by an amount defined in the **Italic Style** setting.<br/><br/>Set this value to control the |
|
||||
|**Tab Multiple**||Set the tab size. This value is multiplied by the width of the font's space character to calculate the tab size used.|
|
||||
|
||||
<a name="FallbackFontAssets"></a>
|
||||
### Fallback Font Assets
|
||||
|
||||
Each font Asset contains a limited number of characters. When you use a character that the current Font Asset does not contain, TextMesh Pro searches the fallback font list until it finds a font Asset that includes it. The text object then uses that font to render the character.
|
||||
|
||||
You can use this feature to distribute fonts over multiple textures, or use different fonts for specific characters. Be aware that searching the list for missing characters requires extra computing resources, and that using additional fonts requires additional draw calls.
|
||||
|
||||
For more information about how fallback fonts work, see [The Fallback font chain](FontAssetsFallback.md).
|
||||
|
||||
|Property:|Function:|
|
||||
|-|-|
|
||||
|**Fallback Font Asset list**|Manage the fallback fonts for this font Asset.<br/><br/>Click **+** and **-** to add and remove font slots.<br/><br/>Click the circle icon next to a font to open an Object Picker where you can choose a font Asset.<br/><br/>Drag the handles on the left side of any font Asset to reorder the list.|
|
||||
|
||||
### Character Table
|
||||
|
||||
|
||||
|
||||
### Glyph Table
|
||||
|
||||
The glyph table contains information about each of the glyphs in the Font Asset. You can adjust the attributes of individual glyphs, which is useful when you need to correct problems that can occur when TextMesh Pro imports font data.
|
||||
|
||||
|Property:||Function:|
|
||||
|-|-|-|
|
||||
|**Glyph Search**||Search the character list by character, ASCII value, or Hex value.<br/><br/>Search results are ordered by ASCII value, lowest to highest.|
|
||||
|**Previous Page/Next Page**||Long character lists are split into pages, which you can navigate using these buttons (also located at the bottom of the section).|
|
||||
|**Glyph Properties**||Displays a single glyph’s properties. Each glyph has its own entry.<br/><br/>Click an entry to make it active. You can then edit the glyph, copy it, or remove it from the list.|
|
||||
||Ascii|Displays the character’s ASCII decimal value.|
|
||||
||Hex|Displays the character’s Unicode Hex value.|
|
||||
||Char|Displays the character.|
|
||||
||X, Y, W, H|Define the rectangular area the character occupies in the font atlas.|
|
||||
||OX, OY|Control the placement of the character's sprite, defined at its top-left corner relative to its origin on the baseline.|
|
||||
||ADV|Specify how far to advance along the baseline before placing the next character.|
|
||||
||SF|Change this scaling factor value to adjust the size of the character.|
|
||||
|**Copy to**||Duplicate this glyph.<br/><br/>To make a copy, enter an unused Unicode (Hex) ID in the text field and click **Copy to**.|
|
||||
|**Remove**||Remove this glyph from the list.|
|
||||
|
||||
### Glyph Adjustment Table
|
||||
|
||||
The glyph adjustment table controls spacing between specific pairs of characters. Some fonts include kerning information, which is imported automatically. You can add kerning pairs for fonts that don’t include them.
|
||||
|
||||
|Property:||Function:|
|
||||
|-|-|-|
|
||||
|**Adjustment Pair Search**||Search the adjustment table by character or ASCII value.<br/><br/>Search results include entries where either the left or right character matches the search string.<br/><br/>Search results are ordered by the ASCII value of the left character, lowest to highest.|
|
||||
|**Previous Page/Next Page**||Long adjustment tables are split into pages, which you can navigate using these buttons (also located at the bottom of the section).|
|
||||
|**Glyph Properties**||Displays a single glyph’s properties. Each glyph has its own entry.<br/><br/>Click an entry to make it active. You can then edit the glyph, copy it, or remove it from the list.|
|
||||
||Char (left and right)|Display the left and right characters for the kerning pair.<br/><br/>When you add anew kerning pair, you can specify the left and right characters to use by typing them in these fields.|
|
||||
||ID (left and right)|Display the left and right characters’ ASCII decimal values.<br/><br/>When you add anew kerning pair, you can specify the left and right characters to use by typing their ASCII values in these fields.|
|
||||
||OX, OY|For each character in the kerning pair, set the horizontal (**X**) and vertical (**Y**) offset relative to the character's initial position.|
|
||||
||AX|For each character in the kerning pair, specify how far to advance along the baseline before placing the next character.<br/><br/>Practically speaking, the left **AX** value controls the distance between the characters in the kerning pair, while the right **AX** value controls the distance between the kerning pair and the next character.|
|
||||
|**Add New Kerning Pair**||Add a new entry to the Glyph Adjustment Table.<br/><br/>You cannot duplicate an existing entry.|
|
@@ -0,0 +1,16 @@
|
||||
## About SDF fonts
|
||||
|
||||
TextMesh Pro takes advantage of Signed Distance Field (SDF) rendering to generate font assets that look crisp when you transform and magnify them, and support effects such as outlines and drop shadows.
|
||||
|
||||
Unlike black and white bitmap font textures, SDF font assets contain contour distance information. In font atlases, this information looks like grayscale gradients running from the middle of each glyph to a point past its edge. The gradient's mid-point corresponds to the edge of the glyph.
|
||||
|
||||
The images below show bitmap and SDF font assets and the rendered text they produce. Notice that the bitmap fonts produce text whose edges are more or less jagged/blurry, depending on how far the text is from the camera, and how it is transformed/distorted. The SDF font, on the other hand produces text with completely smooth edges regardless of the distance from the camera.
|
||||
|
||||

|
||||
_A bitmap font, atlas texture and rendered result_
|
||||
|
||||

|
||||
_A smoothed bitmap, atlas texture and rendered result_
|
||||
|
||||

|
||||
_An SDF font, atlas texture and rendered result_
|
@@ -0,0 +1,88 @@
|
||||
# Rich Text
|
||||
|
||||
Rich text tags alter the appearance and layout of text by supplementing or overriding TextMesh Pro GameObject properties. For example, you can use rich text tags to change the color or alignment of some, or all of your text without modifying its properties or material.
|
||||
|
||||
**To use rich text tags:**
|
||||
* Enter any [supported rich text tags](RichTextSupportedTags.md) in the TextMeshPro [**Text** input field](TMPObjectUIText.md#text), inline with the text you want to display.
|
||||
|
||||
**To disable rich text for a TextMesh Pro object:**
|
||||
* Open the TextMesh Pro GameObject in the Inspector, and disable the **Text Mesh Pro > Extra Settings > Rich Text** property.
|
||||
|
||||
## Rich Text Tags
|
||||
|
||||
Rich text tags are similar to HTML or XML tags, but have less strict syntax.
|
||||
|
||||
A simple tag consists of only the tag name, and looks like this:
|
||||
|
||||
`<tag>`
|
||||
|
||||
For example, the `<b>` tag makes text bold, while the `<u>` tag underlines it.
|
||||
|
||||
### Tag attributes and values
|
||||
|
||||
Some tags have additional values or attributes, and look like this:
|
||||
|
||||
`<tag="value">` or `<tag attribute="value">`
|
||||
|
||||
For example `<color=”red”>` makes text red. `Red` is the `color` tag’s value.
|
||||
|
||||
Similarly `<sprite index=3>` inserts the fourth sprite from the default Sprite Asset. `index` is an attribute of the `sprite` tag, and its value is `3`.
|
||||
|
||||
A tag, including its attributes, can be up to 128 characters long.
|
||||
|
||||
The table below lists possible attribute/value types.
|
||||
|
||||
|Attribute/value type:|Example|
|
||||
|-------------|-------------|
|
||||
|Decimals|`0.5`|
|
||||
|Percentages|`25%`|
|
||||
|Pixel values|`5px`|
|
||||
|Font units|`1.5em`|
|
||||
|Hex color values|`#FFFFFF` (RGB)<br/>`#FFFFFFFF` (RGBA)<br/>`#FF` (A)|
|
||||
|Names|Both `<link=”ID”>` and `<link=ID>` are valid.|
|
||||
|
||||
## Tag scope and nested tags
|
||||
|
||||
Tags have a scope that defines how much of the text they affect. Most of the time, a tag added to a given point in the text affects all of the text from that point forward.
|
||||
|
||||
For example, adding the tag `<color="red">` at the beginning of the text affects the entire text block:
|
||||
|
||||
`<color="red">This text is red`
|
||||
|
||||
<br/>
|
||||
_Successive color tags_
|
||||
|
||||
Adding the same tag in the middle of the text block affects only the text between the tag and the end of the block :
|
||||
|
||||
`This text turns<color="red"> red`
|
||||
|
||||
<br/>
|
||||
_Successive color tags_
|
||||
|
||||
If you use the same tag more than once in a text block, the last tag supersedes all previous tags of the same type.
|
||||
|
||||
`<color="red">This text goes from red<color="green"> to green`
|
||||
|
||||
<br/>
|
||||
_Successive color tags_
|
||||
|
||||
You can also limit the scope of most tags using a closing tag. Closing tags contain only a forward slash and the tag name, like this: `</tag>`
|
||||
|
||||
Tags can also be _nested_ so one tag’s scope is within another tag’s scope. For example:
|
||||
|
||||
```
|
||||
<color=red>This text is <color=green>mostly </color>red.
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Successive color tags_
|
||||
|
||||
The first `<color>` tag’s scope is the entire text block. The the second `<color>` tag has a closing tag that limits its scope to one word.
|
||||
|
||||
When you nest tags, you don't have to close their scopes in the same order that you started them.
|
||||
|
||||
## Rich-text tags and right-to-left text
|
||||
|
||||
TextMesh Pro's right-to-left editor does not distinguish between regular text and rich text tags. Rich text tags that you enter in the right-to-left editor do not work unless you type them right-to-left as well.
|
||||
|
||||
The easiest way to apply rich text tags to right-to-left text is to type the text in the right-to-left editor, and then apply the tags in the regular editor.
|
@@ -0,0 +1,24 @@
|
||||
# Text Alignment
|
||||
|
||||
Each text object has an overall alignment, but you can override this with `<align>` tags. All [horizontal alignment options](TMPObjectUIText.md#alignment) are available except for **Geometry Center**.
|
||||
|
||||
Normally you put these tags at the start of a paragraph. Successive alignment scopes don't stack. If you put multiple alignment tags on the same line, the last one overrides the others.
|
||||
|
||||
The closing `</align>` tag reverts back to the object's overall alignment.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
<align="left"><b>Left-aligned</b>
|
||||
|
||||
<align="center"><b>Center-aligned</b>
|
||||
|
||||
<align="right"><b>Right-aligned</b>
|
||||
|
||||
<align="justified"><b>Justified:</b> stretched to fill the display area (except for the last line)
|
||||
|
||||
<align="flush"><b>Flush:</b> stretched to fill the display area (including the last line)
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Text Alignment_
|
@@ -0,0 +1,14 @@
|
||||
# Bold and Italic
|
||||
|
||||
You can apply bold and italic styling to your text with the `<b>` and `<i>` tags respectively. The [font Asset](FontAssetsProperties.md) defines how bold and italicized text looks when rendered.
|
||||
|
||||
The closing `</b>` and `</i>` tags revert to the text's normal appearance.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
The <i>quick brown fox</i> jumps over the <b>lazy dog</b>.
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Bold and italic._
|
@@ -0,0 +1,16 @@
|
||||
# Character Spacing
|
||||
|
||||
The `<cspace>` tag allows you to adjust character spacing, either absolute or relative to the original font Asset. You can use pixels or font units.
|
||||
|
||||
Postive adjustments push the characters apart, negative adjustments pull them together.
|
||||
|
||||
The closing `</cspace>` tag reverts back to the font's normal spacing.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
<cspace=1em>Spacing</cspace> is just as important as <cspace=-0.5em>timing.
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Character spacing_
|
@@ -0,0 +1,25 @@
|
||||
# Text Color
|
||||
|
||||
There are two ways to change text color with color tags:
|
||||
|
||||
* Use named colors, as in `<color="colorName">`<br/><br/>
|
||||
The following color names are supported: `black`, `blue`, `green`, `orange`, `purple`, `red`, `white`, and `yellow`.<br/><br/>
|
||||
* Use hexadecimal values, as in `<color=#FFFFFF>` or `<color=#FFFFFFFF>` if you also want to define the alpha value.
|
||||
|
||||
If you apply successive `<color>` tags in the same text, the last one takes precedence over the others until you either add another `<color>`tage or use a closing `</color>` tag to end the current color's scope.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
<color="red">Red <color=#005500>Dark Green <#0000FF>Blue <color=#FF000088>Semitransparent Red
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Successive color tags_
|
||||
|
||||
```
|
||||
<color="red">Red, <color="blue">Blue,</color> and red again.
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Closing color tag_
|
@@ -0,0 +1,22 @@
|
||||
# Font
|
||||
|
||||
You can switch to a different font using `<font="fontAssetName">`.
|
||||
|
||||
The font you specify replaces the default font until you insert a closing `<font>` tag. Font tags can be nested.
|
||||
|
||||
You can also use the `material` attribute to switch between different materials for a single font.
|
||||
|
||||
You must place the font and material assets in the directory that is specified in the **TextMesh Settings > Default Font Asset > Path** field. The default path is `Assets/TextMesh Pro/Resources/Fonts & Materials`. If you don't have it in your project, select **Window > TextMeshPro > Import TMP Essential Resources** to add it. For more information, refer to [Importing required resources into projects](index.md).
|
||||
|
||||
To revert to the default font:
|
||||
* Close all open font tags using `</font>` tag
|
||||
* Use another `<font>` tag and set the font Asset name to `default`
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
Would you like <font="Impact SDF">a different font?</font> or just <font="NotoSans" material="NotoSans Outline">a different material?
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Mixing fonts and materials_
|
@@ -0,0 +1,26 @@
|
||||
# Font weight
|
||||
|
||||
Use the `<font-weight>` tag to switch between the font weights available for the current [Font Asset](FontAssets.md).
|
||||
|
||||
You specify the weight using its numeric value, for example `400` for **normal**, `700` for **bold**, and so on.
|
||||
|
||||
You can only apply font weights defined in the [Font Asset properties](FontAssetsProperties.md#FontWeights). If you have not defined any font weights, you can still use values of **400** and **700** to apply the multipliers set in the **Normal Weight** and **Bold Weight** properties.
|
||||
|
||||
The closing `</font-weight>` tag reverts to the original font specified for the TextMesh Pro object.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
<font-weight="100">Thin</font-weight>
|
||||
<font-weight="200">Extra-Light</font-weight>
|
||||
<font-weight="300">Light</font-weight>
|
||||
<font-weight="400">Regular</font-weight>
|
||||
<font-weight="500">Medium</font-weight>
|
||||
<font-weight="600">Semi-Bold</font-weight>
|
||||
<font-weight="700">Bold</font-weight>
|
||||
<font-weight="800">Heavy</font-weight>
|
||||
<font-weight="900">Black</font-weight>
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Font weights_
|
@@ -0,0 +1,36 @@
|
||||
# Gradient
|
||||
|
||||
The `<gradient>` tag applies a pre-defined gradient preset to text.
|
||||
|
||||
For more information about creating gradient presets, see the documentation on [Gradient Presets](ColorGradientsPresets.md).
|
||||
|
||||
The closing `</gradient>` tag reverts to the TextMesh pro object's original color.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
Apply<b>
|
||||
<gradient="Yellow to Orange - Vertical">any
|
||||
<gradient="Light to Dark Green - Vertical">gradient
|
||||
<gradient="Blue to Purple - Vertical">preset</gradient>
|
||||
</b>to your text
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Successive gradient tags ended with a closing `</gradient>`_
|
||||
|
||||
**Note:** When you apply a gradient using this tag, it's multiplied by the TextMesh Pro object's current vertex colors.
|
||||
|
||||
```
|
||||
This <gradient="Light to Dark Green - Vertical">Light to Dark Green gradient</gradient> is tinted by the red vertex color
|
||||
```
|
||||
<br/>
|
||||
_Applying a green gradient to red text_
|
||||
|
||||
To apply the pure gradient to a selection of text, you can use a `<color>` tag to "reset" the color to white before applying the gradient.
|
||||
|
||||
```
|
||||
This <color=#FFFFFFFF><gradient="Light to Dark Green - Vertical">Light to Dark Green gradient</gradient></color> is no longer tinted by the red vertex color
|
||||
```
|
||||
<br/>
|
||||
_"Resetting" the text's vertex color before applying a gradient_
|
@@ -0,0 +1,17 @@
|
||||
# Indentation
|
||||
|
||||
The `<indent>` tag controls the horizontal caret position the same way the [`<pos>`](RichTextPos.md) tag does, but the effect persists across lines.
|
||||
|
||||
Use this tag to create text patterns, such as bullet points, that work with word-wrapping.
|
||||
|
||||
You specify indentation in pixels, font units, or percentages.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
1. <indent=15%>It is useful for things like bullet points.</indent>
|
||||
2. <indent=15%>It is handy.
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Using indentation to make a list._
|
@@ -0,0 +1,20 @@
|
||||
# Lowercase, Uppercase, and Smallcaps
|
||||
|
||||
The `<lowercase>`, `<uppercase>`, `<allcaps>` and `<smallcaps>` tags alter the capitalization of your text before rendering. The text in the **Text** field remains as you entered it.
|
||||
|
||||
* The `<lowercase>` and `<uppercase>` tags work as you would expect, converting to all capitals or no capitals before rendering.
|
||||
|
||||
* The `<allcaps>` tag is functionally identical to `<uppercase>`.
|
||||
|
||||
* The `<smallcaps>` tag works like `<uppercase>`, but also reduces the size of all characters that you entered in lowercase.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
<lowercase>Alice and Bob watched TV.</lowercase>
|
||||
<uppercase>Alice and Bob watched TV.</uppercase>
|
||||
<allcaps>Alice and Bob watched TV.</allcaps>
|
||||
<smallcaps>Alice and Bob watched TV.</smallcaps>
|
||||
```
|
||||
<br/>
|
||||
_Modifying capitalization._
|
@@ -0,0 +1,14 @@
|
||||
# Line Break
|
||||
|
||||
Use the `<br>` tag to force a line break in text.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
Add line breaks wherever you want
|
||||
|
||||
Add line breaks <br>wherever <br>you <br>want
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Adding line breaks_
|
@@ -0,0 +1,22 @@
|
||||
# Line Height
|
||||
|
||||
Use the `<line-height>` tag to manually control line height. The line-height controls how far down from the current line the next line starts. It does not change the current line.
|
||||
|
||||
Smaller values pull lines closer together. Larger values push them farther apart.
|
||||
|
||||
You can specify the line height in pixels, font units, or percentages.
|
||||
|
||||
Adjustments you make using this tag are relative to the line-height specified in the [Font Asset](FontAssetsProperties.md#FaceInfo). The `</line-height>` closing tag reverts to this height.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
Line height at 100%
|
||||
<line-height=50%>Line height at 50%
|
||||
<line-height=100%>Rather cozy.
|
||||
<line-height=150%>Line height at 150%
|
||||
Such distance!
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Different line heights_
|
@@ -0,0 +1,16 @@
|
||||
# Line Indentation
|
||||
|
||||
The `<line-indent>` tag inserts horizontal space directly after it, and before the start of each new line. It only affects manual line breaks (including line breaks created with the [`<br>` tag](RichTextLineBreak.md), not word-wrapped lines.
|
||||
|
||||
You can specify the indentation in pixels, font units, or percentages.
|
||||
|
||||
The `</line-indent>` closing tag ends the indentation of lines.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
<line-indent=15%>This is the first line of this text example.
|
||||
This is the second line of the same text.
|
||||
```
|
||||
<br/>
|
||||
_Indent every new line, with one tag_
|
@@ -0,0 +1,7 @@
|
||||
# Text Link
|
||||
|
||||
You can use `<link="ID">my link</link>` to add link metadata to a text segment. The link ID should be unique to allow you to retrieve its ID and link text content when the user interacts with your text.
|
||||
|
||||
You do not have to give each link a unique ID. You can reuse IDs when it makes sense, for example when linking to the same data multiple times. The `linkInfo` array contains each ID only once.
|
||||
|
||||
While this link enables user interaction, it does not change the appearance of the linked text. You have to use other tags for that.
|
@@ -0,0 +1,19 @@
|
||||
# Margin
|
||||
|
||||
You can increase the horizontal margins of the text with the `<margin>` tag.
|
||||
|
||||
If you only want to adjust the left or right margin, you can use the `<margin-left>` or `<margin-right>` tag.
|
||||
|
||||
You can specify the margins in pixels, font units, and percentages. Negative values have no effect.
|
||||
|
||||
Adjustments you make using this tag are relative to the margins specified in the [TexMesh Pro object](TMPObjectUIText.md#extra-settings). The `</margin>` closing tag reverts to this value.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
Our margins used to be very wide.
|
||||
<margin=5em>But those days are long gone.
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Adjusting margins_
|
@@ -0,0 +1,16 @@
|
||||
# Mark
|
||||
|
||||
The `<mark>` tag adds an overlay on top of the text. You can use it to highlight portions of your text.
|
||||
|
||||
Because markings are overlaid on the text, you have to give them a semitransparent color for the text to show through. You can do this by specifying the color using a hex value that includes Alpha.
|
||||
|
||||
You cannot combine marks. Each tag affects the text between itself and the next `<mark>` tag or a closing `</mark>` tag.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
Text <mark=#ffff00aa>can be marked with</mark> an overlay.
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Marked text_
|
@@ -0,0 +1,16 @@
|
||||
# Monospacing
|
||||
|
||||
You can override a font's character spacing and turn it into a monospace font with the `<mspace>` tag. This gives all characters the same amount of horizontal space.
|
||||
|
||||
You can specify the character width in pixels or font units.
|
||||
|
||||
The `</mspace>` closing tag clears all monospace overrides.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
Any font can become <mspace=2.75em>monospace, if you really want it.
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Treating a font as monospace_
|
@@ -0,0 +1,16 @@
|
||||
# No Break
|
||||
|
||||
Use the `<nobr>` tag to keep specific words together, and not be separated by word wrapping.
|
||||
|
||||
The closing `</nobr>` tag reverts to the default behavior of allowing words to break where the line wraps.
|
||||
|
||||
If you apply the `<nobr>` tag to a segment of text that is too big to fit on one line, the segment will break wherever the line wraps.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
You don't want <nobr>I M P O R T A N T</nobr> things to be broken up.
|
||||
```
|
||||
|
||||
<br/>
|
||||
_The important parts stay together_
|
@@ -0,0 +1,14 @@
|
||||
# Noparse
|
||||
|
||||
The `<noparse>` tag creates a scope that TextMesh Pro does not parse.
|
||||
|
||||
This is useful for rendering text that TextMesh Pro normally interprets as a rich text tag, without disabling rich text tags.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
Use <noparse><b></noparse> for <b>bold</b> text.
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Prevent parsing of some tags_
|
@@ -0,0 +1,12 @@
|
||||
# Text Opacity (Alpha)
|
||||
|
||||
Use the `<alpha>` tag to change text opacity. It works with hexadecimal values.
|
||||
|
||||
**Example:**
|
||||
|
||||
```
|
||||
<alpha=#FF>FF <alpha=#CC>CC <alpha=#AA>AA <alpha=#88>88 <alpha=#66>66 <alpha=#44>44 <alpha=#22>22 <alpha=#00>00
|
||||
```
|
||||
|
||||
<br/>
|
||||
_Successive `<alpha>` tags_
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user