コード例 #1
0
ファイル: UIUtil.cs プロジェクト: atom-chen/tianyu
    public static void AddFloatLabel(GameObject parent, string msg, UIFont mFont, string color)
    {
        int     nextDepth = NGUITools.CalculateNextDepth(parent);
        UILabel lbl       = NGUITools.AddWidget <UILabel>(parent);

        lbl.name                 = "FloatLabel";
        lbl.depth                = nextDepth;
        lbl.bitmapFont           = mFont;
        lbl.pivot                = UILabel.Pivot.TopLeft;
        lbl.transform.localScale = new Vector3(mFont.defaultSize, mFont.defaultSize, 1f);
        lbl.MakePixelPerfect();
        lbl.supportEncoding = true;
        lbl.symbolStyle     = NGUIText.SymbolStyle.Normal;

        if (color != null)
        {
            lbl.color = ColorManage.GetColor(color);
        }
        lbl.text = msg;
        TweenPosition pos = TweenPosition.Begin(lbl.gameObject, 0.4f, lbl.transform.localPosition + new Vector3(0f, 20f, 0f));

        EventDelegate.Add(pos.onFinished, () =>
        {
            Destroy(lbl.gameObject);
        }, true);
    }
コード例 #2
0
ファイル: UIUtil.cs プロジェクト: atom-chen/tianyu
    private static UILabel CreateLabel(GameObject parent, string str, UIFont mFont, string color)
    {
        int     nextDepth = NGUITools.CalculateNextDepth(parent);
        UILabel lbl       = NGUITools.AddWidget <UILabel>(parent);

        lbl.name                 = "Label_text";
        lbl.depth                = nextDepth;
        lbl.bitmapFont           = mFont;
        lbl.pivot                = UILabel.Pivot.TopLeft;
        lbl.transform.localScale = new Vector3(mFont.defaultSize, mFont.defaultSize, 1f);
        lbl.MakePixelPerfect();
        lbl.supportEncoding = true;
        lbl.symbolStyle     = NGUIText.SymbolStyle.Normal;

        if (color != null)
        {
            lbl.color = ColorManage.GetColor(color);
        }
        lbl.text = str;
        return(lbl);
    }