Example #1
0
        public static UICheckBox MakeCheckbox(UIPanel panel, string name, string text, Vector2 position, bool value,
                                              CheckboxSetValue setValue)
        {
            var label = panel.AddUIComponent <UILabel>();

            label.name             = name;
            label.text             = text;
            label.relativePosition = position;
            label.textScale        = 0.8f;
            label.textColor        = Color.black;

            var checkbox = panel.AddUIComponent <UICheckBox>();

            checkbox.AlignTo(label, UIAlignAnchor.TopLeft);
            checkbox.relativePosition = new Vector3(checkbox.relativePosition.x + 274.0f, checkbox.relativePosition.y - 2.0f);
            checkbox.size             = new Vector2(16.0f, 16.0f);
            checkbox.isVisible        = true;
            checkbox.canFocus         = true;
            checkbox.isInteractive    = true;

            if (setValue != null)
            {
                checkbox.eventCheckChanged += (component, newValue) =>
                {
                    setValue(newValue);
                };
            }

            var uncheckSprite = checkbox.AddUIComponent <UISprite>();

            uncheckSprite.size             = new Vector2(16.0f, 16.0f);
            uncheckSprite.relativePosition = new Vector3(0, 0);
            uncheckSprite.spriteName       = "check-unchecked";
            uncheckSprite.isVisible        = true;

            var checkSprite = checkbox.AddUIComponent <UISprite>();

            checkSprite.size             = new Vector2(16.0f, 16.0f);
            checkSprite.relativePosition = new Vector3(0, 0);
            checkSprite.spriteName       = "check-checked";

            checkbox.isChecked        = value;
            checkbox.checkedBoxObject = checkSprite;
            return(checkbox);
        }
        private static UICheckBox MakeCheckbox(UIPanel panel, string name, string text, float y, bool value,
                                               CheckboxSetValue setValue)
        {
            var label = panel.AddUIComponent <UILabel>();

            label.name             = name;
            label.text             = text;
            label.relativePosition = new Vector3(4.0f, y);
            label.textScale        = 0.8f;

            var checkbox = panel.AddUIComponent <UICheckBox>();

            checkbox.AlignTo(label, UIAlignAnchor.TopLeft);
            checkbox.relativePosition = new Vector3(checkbox.relativePosition.x + 332.0f, checkbox.relativePosition.y - 6.0f);
            checkbox.size             = new Vector2(20.0f, 20.0f);
            checkbox.isVisible        = true;
            checkbox.canFocus         = true;
            checkbox.isInteractive    = true;

            checkbox.eventCheckChanged += (component, newValue) =>
            {
                setValue(newValue);
            };

            var uncheckSprite = checkbox.AddUIComponent <UISprite>();

            uncheckSprite.size             = new Vector2(20.0f, 20.0f);
            uncheckSprite.relativePosition = new Vector3(0, 0);
            uncheckSprite.spriteName       = "check-unchecked";
            uncheckSprite.isVisible        = true;

            var checkSprite = checkbox.AddUIComponent <UISprite>();

            checkSprite.size             = new Vector2(20.0f, 20.0f);
            checkSprite.relativePosition = new Vector3(0, 0);
            checkSprite.spriteName       = "check-checked";

            checkbox.isChecked        = value;
            checkbox.checkedBoxObject = checkSprite;
            return(checkbox);
        }
Example #3
0
        public static UICheckBox MakeCheckbox(UIPanel panel, string name, string text, Vector2 position, bool value,
            CheckboxSetValue setValue)
        {
            var label = panel.AddUIComponent<UILabel>();
            label.name = name;
            label.text = text;
            label.relativePosition = position;
            label.textScale = 0.8f;
            label.textColor = Color.black;

            var checkbox = panel.AddUIComponent<UICheckBox>();
            checkbox.AlignTo(label, UIAlignAnchor.TopLeft);
            checkbox.relativePosition = new Vector3(checkbox.relativePosition.x + 274.0f, checkbox.relativePosition.y - 2.0f);
            checkbox.size = new Vector2(16.0f, 16.0f);
            checkbox.isVisible = true;
            checkbox.canFocus = true;
            checkbox.isInteractive = true;

            if (setValue != null)
            {
                checkbox.eventCheckChanged += (component, newValue) => setValue(newValue);
            }

            var uncheckSprite = checkbox.AddUIComponent<UISprite>();
            uncheckSprite.size = new Vector2(16.0f, 16.0f);
            uncheckSprite.relativePosition = new Vector3(0, 0);
            uncheckSprite.spriteName = "check-unchecked";
            uncheckSprite.isVisible = true;

            var checkSprite = checkbox.AddUIComponent<UISprite>();
            checkSprite.size = new Vector2(16.0f, 16.0f);
            checkSprite.relativePosition = new Vector3(0, 0);
            checkSprite.spriteName = "check-checked";

            checkbox.isChecked = value;
            checkbox.checkedBoxObject = checkSprite;
            return checkbox;
        }
        private static UICheckBox MakeCheckbox(UIPanel panel, string name, string text, float y, bool value,
            CheckboxSetValue setValue)
        {
            var label = panel.AddUIComponent<UILabel>();
            label.name = name;
            label.text = text;
            label.relativePosition = new Vector3(4.0f, y);
            label.textScale = 0.8f;

            var checkbox = panel.AddUIComponent<UICheckBox>();
            checkbox.AlignTo(label, UIAlignAnchor.TopLeft);
            checkbox.relativePosition = new Vector3(checkbox.relativePosition.x + 332.0f, checkbox.relativePosition.y - 6.0f);
            checkbox.size = new Vector2(20.0f, 20.0f);
            checkbox.isVisible = true;
            checkbox.canFocus = true;
            checkbox.isInteractive = true;

            checkbox.eventCheckChanged += (component, newValue) =>
            {
                setValue(newValue);
            };

            var uncheckSprite = checkbox.AddUIComponent<UISprite>();
            uncheckSprite.size = new Vector2(20.0f, 20.0f);
            uncheckSprite.relativePosition = new Vector3(0, 0);
            uncheckSprite.spriteName = "check-unchecked";
            uncheckSprite.isVisible = true;

            var checkSprite = checkbox.AddUIComponent<UISprite>();
            checkSprite.size = new Vector2(20.0f, 20.0f);
            checkSprite.relativePosition = new Vector3(0, 0);
            checkSprite.spriteName = "check-checked";

            checkbox.isChecked = value;
            checkbox.checkedBoxObject = checkSprite;
            return checkbox;
        }