zoukankan      html  css  js  c++  java
  • (转)unity3d插件 HUD Text 学习

     转自:http://www.cnblogs.com/code1992/p/3657291.html

    使用版本 NGUI_HUD_Text_v1.11 。英语水平差,难免有很多不足之处,忘批评指正。本文为鬼脸苹果原创

      HUD Text 的其中一个用途是,涉及到非战斗场景时,你能通过在角色头顶显示文本行来呈现出有不同字符的对话。

      

      HUD Text 真正的优势在于显示数值的能力,能自动将它们按照正值和负值进行累加分组。试一下--把鼠标放到半兽人上并快速的点击鼠标左/右键,分组的值将持续上升直到下一个出现,因此很容易看到实时的DPS。

    ReadeMe中的介绍:

    Usage:
    1. Attach the HUDText script to a game object underneath your UIRoot and set the font it should use.
    2. To make it follow an object drawn with another camera, attach UIFollowTarget to the same object and set its target.
    3. From code, use HUDText's Add() function to add new floating text entries.
     
    You can also tweak the splines on the HUDText script, changing the motion of the text as you see fit.
     
        

    例子:

    1. 导入NGUI和HUD Text插件

    2. 新建一个Cube,在Cube下创建一个空的子对象命名为“Target”,调整Target的位置到Cube上方

    3. 新建一个2D UI,在Camera下新建一个空的子对象 命名为HUD Text,然后将HUDText.cs和UIFollowTarget.cs脚本赋给HUD Text对象,并按照下图给Font和Target赋值

    4. 新建脚本test.cs

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    using UnityEngine;
     
    public class test :MonoBehaviour
    {
        public HUDText hudText;
        void Update()
        {
            // 0f表示数字上升前的停留时间stayDuration
            hudText.Add(Time.deltaTime*10f, Color.white, 0f);
        }
     
        void OnClick()
        {
            hudText.Add("Click!", Color.green, 0f);
        }
    }

      

    5. 将test.cs赋给Cube,然后将HUDText对象赋给HudText变量

    6. 运行查看效果

    7. 如果单击Cube没有效果,需要打开NGUI-Open-Camera Tool,勾选 Main Camera(3D Default) 下的EV

  • 相关阅读:
    C# 并行线程调用
    Oracle定时备份
    读取Excel里面的内容转为DataTable
    c# 将json数据转为键值对
    Py基础+中级
    深入理解DIP、IoC、DI以及IoC容器(转载)
    错误页面的配置
    JavaScript重载
    关于为空必填js判断
    MyEclipse CI 2018.8.0正式发布(附下载)
  • 原文地址:https://www.cnblogs.com/wonderKK/p/3983542.html
Copyright © 2011-2022 走看看