In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use NGUI HUD Text, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
NGUI HUD Text is a good plug-in for displaying information on the top of the elf's head, such as dialogue display on the top of the character's head, injury, digital display of treatment, and so on. As the name implies, this plug-in is based on NGUI, which means it must be used with NGUI. There is no need for me to introduce any more of the famous plug-ins like NGUI. Students who don't have NGUI don't have to worry. NGUI HUD Text integrates a Lite version of NGUI, which is enough to display data on the top of your head.
Let me give you a general idea of how to use this plug-in. Import the plug-in first, and then you will see the folder "HUD Text" in the Project panel. Expand the folder and you will see a Scripts folder that contains the core code of the plug-in. One is "HUD Text.cs" and one is "UIFollowTarget.cs". The first one is used to display the information on the top of the head, and the second one is used to do UI follow (let the message display UI to follow the goal setting). Let me use the example included in the HUD Text plug-in as an example (the path of the example is HUD Text/Examples/Scenes). Open the "ExampleTwo" scene file and you will see some small tents and an orc in the Game window. Run the program, hovering over the orc body with the mouse will display "Left-Click,Right-Click", the left mouse button click the orc will display the red damage number, right-click the orc will show the green treatment number. Let's take a look at how this effect is achieved in HUD Text. The steps are simple. Let me talk about the implementation process.
1. Create a HUDText Prefab to mount the HUDText and UIFollowTarget scripts provided by the plug-in on this Prefab (the UIFollowTarget script in the example is through the Collider Display Text script Add on the Orc (orcs) object, and the plug-in has provided the finished HUDText Prefab, which can be used directly by lazy people in the Prefabs file under the Examples folder).
two。 Set some variables for the HUDText and UIFollowTarget scripts. The Font variable of HUDText is used to set the font of HUDText. It must be the character set Prefab made by NGUI Font Maker before it can be mounted. Effect is used to set the font display effect, there are normal, shadow, edge these three effects. The following Curve can be ignored and is used to set the display effect of characters that pop up and disappear for a short time. The Target variable in UIFollowTarget sets the pop-up position of the character, which pops up from the position of the Target (this Target is usually an empty GameObject and is placed on the top of the character's head where the data on the top of the head needs to be displayed). The following GameCamera variable sets the MainCamera,UICamera for the entire game to the UICamera provided by NGUI. Just tick the last Disable If Invisible.
3. Write a script that displays characters in the Target location. In fact, the Collider Display Text script in the plug-in example is already very clear. Let me say briefly here that, first of all, the HUD Text Prefab must be mounted under the UI Camera of NGUI before it can take effect. There are many ways to add Prefab to a GameObject, the most common of which is to build a Prefab through the Instantiate () function, and then set its parent property equal to the corresponding GameObject. Or, more conveniently, use the NGUITools.AddChild method provided by the NGUI plug-in. The way to display characters in the Target position is HUDText mText.Add (String text, Color color, float stayDuration), text is the text to be displayed, color is the text color, and stayDuration is the time when the text is displayed. Isn't it easy? Just use this simple method to display beautiful text messages on the top of the character's head.
Finally, the official price of the HUD Text plug-in is $20.
Thank you for reading this article carefully. I hope the article "how to use NGUI HUD Text" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.