Create a new scene and follow the unity plugin's Ngui Learning (2) to create the UI Root.
Ready to work, make font, now the Project window creates a font folder, and then select the font you want from the system's own font folder, I select Bold, and then drag it to the font folder. Select the font you just imported.
The Font size defaults to 16, but the web has seen Size16 appear too small on iOS, so set to 30.
Select Ngui->open->font Maker from the menu
Type default is generated bitmap--generates material files, dynamic--dynamic fonts, but a yellow warning indicates that dynamic fonts produce extra drawcall, considering drawing performance issues, so generated Bitmap is selected.
SOURCE selects the bold font you just imported.
size--sets the size of the font in the material picture.
custom--can increase the text displayed in the game.
atlas--Select the original atlas that you have made(you need to mix the images in the same atlas).
Then click the Create the Font button and the Project window will generate the font's prefab
Set the identity of the graphic mix, select the font Prefab that you just made in the Project window, and then set the picture identity in the inspector window.
In the symbols and emoticons window, currently I just have the picture logo: "(<)" Using UNDO_BTN instead, "(?)" Use HELP_BTN instead.
Select Menu Ngui->open->widget Wizard (Legacy)
Atlas selects the atlas that just made the output in the font
Font Select the font Prefab you just made
Template Select Label
Add to select UI Root
Then set the label parameter in Inspector
Font size size--.
Overflow selects Resizeheight, which is determined by the overall height of the text.
Effect--none no special effects, shadow shadows, outline strokes.
Other properties you can try it yourself, you should be able to read it.
Text content:
[b]bold[/b],[i]italic[/i],[u]underline[/u], [s]strikethrough[/s],
[Sub]sub[/sub]
[00FF00] Green[-]
Lucy (?) the Legion of Lucy (<)
[Url=http://blog.csdn.net/xcookies] [U]clickable [/u][/url]
[b] [/b] blackbody [i][/i] italic [u][/u] underline [s][/s] underline [sub][/sub] subtitle effect [00ff00][-] color effect (?) (<) is the image logo [Url=http://blog.csdn.net/xcookies][/url] address link you just set
Look at the display effect
The following adds a label's click Effect so that the user clicks on the clickable word to open the URL link.
Create a C # Script
Using Unityengine;
using System.Collections;
public class Labelclicktest:monobehaviour {
void OnClick ()
{
Debug.Log ("Label click");
UILabel lbl = getcomponent<uilabel> ();
if (LBL! = null)
{
string url = lbl. Geturlatposition (UICamera.lastHit.point);
if (!string. IsNullOrEmpty (URL)) application.openurl (URL);
}
}
}
In the Hierarchy window select label, select Menu Component->physics->box Collider, tick is Trigger, set Box size size in inspector window, You can check Auto-adjust to match in the Widget's collider. Then add the Labelclicktest script you just added to the label.
Run the game, click the clickable word, will automatically open the browser, access to the label content URL link.
Ps:ngui's label is really very powerful, especially graphics and text mix, but also support the local blackbody, italic, underline and so on, the only regret is the text mixed, if the picture is too large, the layout is a bit ugly, so when making pictures, try to use the same font height of the picture is more appropriate.
Unity Plugin Ngui Learning (5)--Create a label text mix and click