Example #1
0
    /// <summary>
    /// 创建按钮
    /// </summary>
    private void CreateButton()
    {
        GameObject goParent = null;

        if (Selection.activeTransform != null)
        {
            goParent = Selection.activeTransform.gameObject;
        }
        else
        {
            goParent = NGUIEditorTools.SelectedRoot(true);
        }
        if (goParent != null)
        {
            var btnSprite = NGUISettings.AddSprite(goParent);
            Selection.activeGameObject = btnSprite.gameObject;
            var btn = btnSprite.gameObject;;
            btn.name = "Btn";
            btn.AddComponent <UIButton>();
            BtnOtherSet(btn);
            btn.AddComponent <BoxCollider>();
            btnSprite.autoResizeBoxCollider = true;

            var btnLbl = NGUISettings.AddLabel(goParent);
            btnLbl.name          = "BtnLbl";
            btnLbl.applyGradient = false;
            btnLbl.depth         = LabelDefaultDepth;

            btnLbl.transform.SetParent(btn.transform);
        }
    }
Example #2
0
    static public void AddLabel()
    {
        GameObject go = NGUIEditorTools.SelectedRoot(true);

        if (go != null)
        {
            Selection.activeGameObject = NGUISettings.AddLabel(go).gameObject;
        }
        //else Debug.Log("You must select a game object first.");
    }
Example #3
0
    static public void AddLabel()
    {
        GameObject go = NGUIEditorTools.SelectedRoot(true);

        if (go != null)
        {
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2
            Undo.RegisterSceneUndo("Add a Label");
#endif
            Selection.activeGameObject = NGUISettings.AddLabel(go).gameObject;
        }
        else
        {
            Debug.Log("You must select a game object first.");
        }
    }
Example #4
0
    /// <summary>
    /// Label creation function.
    /// </summary>

    void CreateLabel(GameObject go)
    {
        GUILayout.BeginHorizontal();
        Color c = EditorGUILayout.ColorField("Color", mColor, GUILayout.Width(220f));

        GUILayout.Label("Color tint the label will start with");
        GUILayout.EndHorizontal();

        if (mColor != c)
        {
            mColor = c;
            Save();
        }

        if (ShouldCreate(go, NGUISettings.ambigiousFont != null))
        {
            Selection.activeGameObject = NGUISettings.AddLabel(go).gameObject;
        }
    }