|
1 | | -## [UI]() |
2 | | - |
3 | | -Useful common UI controls that you can leverage in your application. |
4 | | - |
5 | | - |
6 | | - |
7 | | -### [Materials](Materials) |
8 | | - |
9 | | -Materials used in prefabs |
10 | | - |
11 | | -#### 3DTextSegoeUI.mat |
12 | | - |
13 | | -Material for 3DTextPrefab with occlusion support. Requires 3DTextShader.shader |
14 | | - |
15 | | -### [Prefabs](Prefabs) |
16 | | - |
17 | | -Common useful UI prefabs |
18 | | - |
19 | | -**IMPORTANT**: To use Text prefabs, please make sure to import Segoe UI.TTF font file from your system font folder (C:\Windows\Fonts\) |
20 | | - |
21 | | -1. Assign font texture to 3DTextSegoeUI.mat material. |
22 | | -2. On 3DTextSegoeUI.mat material, select the shader Custom/3DTextShader.shader This material will make text object occluded by the object in front of them. |
23 | | -3. Assign Segoe UI font and 3DTextSegoeUI material to the text components in the prefabs. |
24 | | -4. Follow the same steps for the sample text layout prefabs in HoloToolkit-Examples\Text |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | -#### 3DTextPrefab.prefab |
30 | | - |
31 | | -3D Text Mesh prefab with optimized scaling factor at 2-meter distance. |
32 | | - |
33 | | - |
34 | | - |
35 | | -#### UITextPrefab.prefab |
36 | | - |
37 | | -UI Text Mesh prefab with optimized scaling factor at 2-meter distance. |
38 | | - |
39 | | - |
40 | | - |
41 | | - |
42 | | -### [Scripts](Scripts) |
43 | | - |
44 | | - |
45 | | - |
46 | | -### [Shaders](Shaders) |
47 | | - |
48 | | -Materials used in prefabs |
49 | | - |
50 | | -#### 3DTextShader.shader |
51 | | - |
52 | | -Shader for 3DTextPrefab with occlusion support. Assign this to 3DTextSegoeUI.mat |
53 | | - |
54 | | ---- |
55 | | -##### [Go back up to the table of contents.](../../../README.md) |
56 | | ---- |
| 1 | +## [UI]() |
| 2 | + |
| 3 | +Useful common UI controls that you can leverage in your application. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +### [Materials](Materials) |
| 8 | + |
| 9 | +Materials used in prefabs |
| 10 | + |
| 11 | +#### 3DTextSegoeUI.mat |
| 12 | + |
| 13 | +Material for 3DTextPrefab with occlusion support. Requires 3DTextShader.shader |
| 14 | + |
| 15 | +### [Prefabs](Prefabs) |
| 16 | + |
| 17 | +Common useful UI prefabs |
| 18 | + |
| 19 | +#### 3DTextPrefab.prefab |
| 20 | + |
| 21 | +3D Text Mesh prefab with optimized scaling factor at 2-meter distance. (Please read the instructions below) |
| 22 | + |
| 23 | +#### UITextPrefab.prefab |
| 24 | + |
| 25 | +UI Text Mesh prefab with optimized scaling factor at 2-meter distance. (Please read the instructions below) |
| 26 | + |
| 27 | +**IMPORTANT**: To use Text prefabs, please make sure to import SegoeUI.TTF font file from your system font folder (C:\Windows\Fonts\) |
| 28 | + |
| 29 | +1. Assign font texture to 3DTextSegoeUI.mat material. |
| 30 | +2. On 3DTextSegoeUI.mat material, select the shader Custom/3DTextShader.shader This material will make text object occluded by the object in front of them. |
| 31 | +3. Assign Segoe UI font and 3DTextSegoeUI material to the text components in the prefabs. |
| 32 | +4. Follow the same steps for the sample text layout prefabs in HoloToolkit-Examples\Text |
| 33 | + |
| 34 | +**Working with Fonts in Unity** |
| 35 | + |
| 36 | +When adding a new 3D TextMesh to a scene in Unity there are two issues that are visually apparent. One, the font appears very large and two, the font appears very blurry. It is also interesting to notice that the default Font Size value is set to zero in the Inspector. Replacing this zero value with 13 will show no difference in size, because 13 is actually the default value. |
| 37 | + |
| 38 | +Unity assumes all new elements added to a scene is 1 Unity Unit in size, or 100% Transform scale, which translates to about 1 meter on the HoloLens. In the case of fonts, the bounding box for a 3D TextMesh comes in, by default at about 1 meter in height. |
| 39 | + |
| 40 | +**Font Scale and Font Sizes** |
| 41 | + |
| 42 | +Most visual designers use Points to define font sizes in the real world, as well as their design programs. There are about 2835 (2,834.645666399962) points in 1 meter. Based on the point system conversion to 1 meter and Unity's default TextMesh Font Size of 13, the simple math of 13 divided by 2835 equals 0.0046 (0.004586111116 to be exact) provides a good standard scale to start with, though some may wish to round to 0.005. |
| 43 | + |
| 44 | +Either way, scaling the Text object or container to these values will not only allow for the 1:1 conversion of font sizes from a design program, but also provides a standard to maintain consistency throughout the application or game. |
| 45 | + |
| 46 | +**UI Text** |
| 47 | + |
| 48 | +When adding a UI or canvas based Text element to a scene, the size disparity is greater still. The differences in the two sizes is about 1000%, which would bring the scale factor for UI based Text components to 0.00046 (0.0004586111116 to be exact) or 0.0005 for the rounded value. |
| 49 | + |
| 50 | +**Disclaimer**: The default value of any font may be effected by the texture size of that font or how the font was imported into Unity. These tests were performed based on the default Arial font in Unity, as well as one other imported font. |
| 51 | + |
| 52 | + |
| 53 | +### [Scripts](Scripts) |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +### [Shaders](Shaders) |
| 58 | + |
| 59 | +Materials used in prefabs |
| 60 | + |
| 61 | +#### 3DTextShader.shader |
| 62 | + |
| 63 | +Shader for 3DTextPrefab with occlusion support. |
| 64 | + |
| 65 | +--- |
| 66 | +##### [Go back up to the table of contents.](../../../README.md) |
| 67 | +--- |
0 commit comments