Exemplo n.º 1
0
 void Start()
 {
     mInput = GetComponent <GameUIInput>();
     //         for (int i = 0; i < 30; ++i)
     //         {
     //             textList.Add(((i % 2 == 0) ? "[FFFFFF]" : "[AAAAAA]") +
     //                 "This is an example paragraph for the text list, testing line " + i + "[-]");
     //         }
 }
Exemplo n.º 2
0
    /// <summary>
    /// Submit the input field's text.
    /// </summary>

    void Submit()
    {
        current = this;

        if (EventDelegate.IsValid(onSubmit))
        {
            EventDelegate.Execute(onSubmit);
        }
        else if (eventReceiver != null && !string.IsNullOrEmpty(functionName))
        {
            // Legacy functionality support (for backwards compatibility)
            eventReceiver.SendMessage(functionName, mText, SendMessageOptions.DontRequireReceiver);
        }

        SaveToPlayerPrefs(mText);
        current = null;
    }
    public override void OnInspectorGUI()
    {
        NGUIEditorTools.SetLabelWidth(120f);
        GameUIInput input = target as GameUIInput;

        GUILayout.Space(6f);
        GUI.changed = false;

        UILabel label = (UILabel)EditorGUILayout.ObjectField("Input Label", input.label, typeof(UILabel), true);

        if (GUI.changed)
        {
            NGUIEditorTools.RegisterUndo("Input Change", input);
            input.label = label;
            UnityEditor.EditorUtility.SetDirty(input);
        }

        if (input.label != null)
        {
            GUI.changed = false;
            Color ia = EditorGUILayout.ColorField("Inactive Color", input.label.color);

            if (GUI.changed)
            {
                NGUIEditorTools.RegisterUndo("Input Change", input.label);
                input.label.color = ia;
                UnityEditor.EditorUtility.SetDirty(input.label);
            }
        }

        GUI.changed = false;
        Color c = EditorGUILayout.ColorField("Active Color", input.activeColor);

        GUILayout.BeginHorizontal();
        DefaultText dt  = input.useLabelTextAtStart ? DefaultText.KeepLabelsText : DefaultText.Blank;
        bool        def = (DefaultText)EditorGUILayout.EnumPopup("Default Text", dt) == DefaultText.KeepLabelsText;

        GUILayout.Space(18f);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GameUIInput.KeyboardType type = (GameUIInput.KeyboardType)EditorGUILayout.EnumPopup("Keyboard Type", input.type);
        GUILayout.Space(18f);
        GUILayout.EndHorizontal();

        GameObject sel = (GameObject)EditorGUILayout.ObjectField("Select on Tab", input.selectOnTab, typeof(GameObject), true);

        if (GUI.changed)
        {
            NGUIEditorTools.RegisterUndo("Input Change", input);
            input.activeColor         = c;
            input.type                = type;
            input.useLabelTextAtStart = def;
            input.selectOnTab         = sel;
            UnityEditor.EditorUtility.SetDirty(input);
        }

        GUI.changed = false;
        GUILayout.BeginHorizontal();
        string pp = EditorGUILayout.TextField("Auto-save Key", input.playerPrefsField);

        GUILayout.Space(18f);
        GUILayout.EndHorizontal();

        int    max = EditorGUILayout.IntField("Max Characters", input.maxChars, GUILayout.Width(160f));
        string car = EditorGUILayout.TextField("Carat Character", input.caratChar, GUILayout.Width(160f));
        bool   pw  = EditorGUILayout.Toggle("Password", input.isPassword);
        bool   ac  = EditorGUILayout.Toggle("Auto-correct", input.autoCorrect);

        if (GUI.changed)
        {
            NGUIEditorTools.RegisterUndo("Input Change", input);
            input.playerPrefsField = pp;
            input.maxChars         = max;
            input.caratChar        = car;
            input.isPassword       = pw;
            input.autoCorrect      = ac;
            UnityEditor.EditorUtility.SetDirty(input);
        }

        NGUIEditorTools.SetLabelWidth(80f);
        NGUIEditorTools.DrawEvents("On Submit", input, input.onSubmit);
    }