コード例 #1
0
    static public void AddLabel()
    {
        GameObject root = NGUIMenu.SelectedRoot();

        if (NGUIEditorTools.WillLosePrefab(root))
        {
            NGUIEditorTools.RegisterUndo("Add a Bitmap Font Label", root);

            GameObject obj = new GameObject("UIBitmapFontLabel");
            obj.layer            = root.layer;
            obj.transform.parent = root.transform;

            UIBitmapFontLabel label = obj.AddComponent <UIBitmapFontLabel>();
            label.MakePixelPerfect();
            label.transform.localPosition = new Vector3(0, 0, -1);
            label.transform.localScale    = new Vector3(1, 1, 1);
            label.fontName     = "Font/font";
            label.text         = "Bitmap Font Label";
            label.size         = 16;
            label.spaceAdvance = 0.25f;
            label.lineSpacing  = 1;
            label.tabSpacing   = 4f;
            label.width        = 500;
            label.height       = 100;

            Selection.activeGameObject = obj;
        }
    }