Beispiel #1
0
        public TextInputFieldBuilder Animation(Color idle, Color highlighted, Color clicked, Color?toggled = null, float transition = 0.333f)
        {
            textInputField.RemoveComponentsOfType <UIColorAnimator>();

            UIColorAnimator animator = new UIColorAnimator(textInputField.Background);

            textInputField.AddComponent(animator);
            animator.Configure(idle, highlighted, clicked, toggled, transition);
            return(this);
        }
Beispiel #2
0
        public static TextInputField CreateTextField(Vector2 pos, Point size, string prompt = "", Transform parent = null, ColorSet theme = ColorSet.Light)
        {
            TextInputFieldBuilder tBuilder = new TextInputFieldBuilder(pos, size)
                                             .TextAlignment(Alignment.Left)
                                             .Prompt(prompt)
                                             .Parent(parent);

            switch (theme)
            {
            case ColorSet.Light:
                tBuilder.Background(PanelOpaque, Color.White, 4)
                .Font(editor, Color.Black)
                .Animation(Color.White, Color.Yellow, Color.Orange, Color.Red);
                break;

            case ColorSet.Dark:
                tBuilder.Background(PanelTransparent, new Color(Color.Black, 0.667f), 4)
                .Font(editor, Color.Red)
                .Animation(new Color(Color.Black, 0.667f), Color.DarkGray, Color.LightGray, Color.White);
                break;

            case ColorSet.Blue:
                tBuilder.Background(PanelTransparent, Color.Blue, 4)
                .Font(editor, Color.White)
                .Animation(Color.Blue, Color.DarkBlue, Color.Indigo, Color.Purple);
                break;

            case ColorSet.Red:
                tBuilder.Background(PanelTransparent, Color.Red, 4)
                .Font(editor, Color.Black)
                .Animation(Color.Red, Color.OrangeRed, Color.Orange, Color.Yellow);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(theme), theme, null);
            }
            TextInputField  textField = tBuilder;
            UIColorAnimator colorAnim = textField.GetComponent <UIColorAnimator>();

            if (colorAnim != null)
            {
                textField.OnFocus   += () => colorAnim.Toggle();
                textField.OnUnfocus += () => colorAnim.Untoggle();
            }
            return(textField);
        }