예제 #1
0
        public IEnumerable <GameObject> Initialize(UiSo ui, UiTheme theme)
        {
            UiThemeUtil.AddChild(ref textBeh, "Label", transform, ui);
            if (UiThemeUtil.AddChild(ref boxShapeBeh, "Box", transform, ui))
            {
                boxShapeBeh.gameObject.AddComponent <UiThemeShapeRipple>();
            }
            UiThemeUtil.AddChild(ref checkShapeBeh, "Check", boxShapeBeh.transform, ui);
            ripple = boxShapeBeh.gameObject.GetComponent <UiThemeShapeRipple>();
            textBeh.Initialize(ui, theme);
            boxShapeBeh.Initialize(ui, theme);
            checkShapeBeh.Initialize(ui, theme);
            ripple.Initialize(ui, theme);

            textBeh.SetAlignment(TextAnchor.MiddleRight);
            textBeh.SetColor(labelColor);
            textBeh.SetValue(label);
            textBeh.SetFontType(UIThemeFontType.Body);
            PositionBox(ui, boxShapeBeh.GetComponent <RectTransform>());
            boxShapeBeh.SetHasShadow(true);
            boxShapeBeh.SetColorType(boxColor);
            boxShapeBeh.SetShapeType(UiThemeShapeType.RoundedSquare);
            boxShapeBeh.SetIsOutline(false);
            checkShapeBeh.SetHasShadow(false);
            var checkRect = checkShapeBeh.GetComponent <RectTransform>();

            checkRect.offsetMax = Vector2.one * -2.0f;
            checkRect.offsetMin = Vector2.one * 2.0f;
            checkShapeBeh.SetShapeType(UiThemeShapeType.Check);
            checkShapeBeh.SetIsOutline(false);
            var textRect = textBeh.GetComponent <RectTransform>();

            textRect.offsetMax = Vector2.right * (-ui.checkboxSize - 5);
            boxShapeBeh.SetColorType(boxColor);
            boxShapeBeh.SetShapeType(UiThemeShapeType.RoundedSquare);

            SetChecked(isChecked);
            SetClickDisabled(isClickDisabled);

            return(UnityUtil.Once(gameObject));
        }
예제 #2
0
        public void SetClickDisabled(bool disabled)
        {
            isClickDisabled = disabled;
            shape.SetIsOutline(disabled);
            var color = isClickDisabled ?
                        colorType :
                        UiThemeUtil.ToOnColor[colorType];

            textBeh.SetColor(color);
            shape.SetHasShadow(!disabled);
            shape.SetColorType(colorType);
            shapeRipple.SetDisabled(disabled);
        }