Esempio n. 1
0
        public static GameObject CreateCheckBoxButton(GameObject parrent, UiCheckBoxButton newUiCheckBoxButton)
        {
            if (newUiCheckBoxButton.uiButtonBackgroundObject == null)
            {
                newUiCheckBoxButton.uiButtonBackgroundObject = new UiInteractiveBackgroundObject();
            }
            GameObject    buttonObj = CreateUiObject(parrent, newUiCheckBoxButton);
            GameObject    buttonRef = CreateBackgroundObj(buttonObj, newUiCheckBoxButton.uiButtonBackgroundObject);
            UiIntractable curUiObj  = buttonObj.AddComponent <UiIntractable>();

            curUiObj.targetImage  = buttonRef.GetComponent <Image>();
            curUiObj.ButtonColors = newUiCheckBoxButton.uiButtonBackgroundObject;
            curUiObj.switchColor(0, newUiCheckBoxButton.uiButtonBackgroundObject.normalColor);
            curUiObj.isCheckBox        = true;
            curUiObj.isCheckBoxChecked = true;
            curUiObj.checkBoxRef       = CreateBackgroundObj(buttonObj, newUiCheckBoxButton.uiCheckMarkObject);
            if (newUiCheckBoxButton.uiButtonIcon != null)
            {
                buttonObj.GetComponent <UiIntractable>().targetIcon = CreateBackgroundObj(buttonObj, newUiCheckBoxButton.uiButtonIcon);
            }
            if (newUiCheckBoxButton.uiButtonText != null)
            {
                CreateTextObj(buttonObj, newUiCheckBoxButton.uiButtonText);
            }
            return(buttonObj);
        }
Esempio n. 2
0
        // TODO : Replace all get component calls.
        public static UiIntractable CreateButton(GameObject parrent, UiButtonObject newUiButtonObject, bool disableText = false)
        {
            if (newUiButtonObject == null)
            {
                newUiButtonObject = new UiButtonObject();
            }
            if (newUiButtonObject.uiButtonBackgroundObject == null)
            {
                newUiButtonObject.uiButtonBackgroundObject = new UiInteractiveBackgroundObject();
            }
            GameObject    buttonObj = CreateUiObject(parrent, newUiButtonObject);
            GameObject    buttonRef = CreateBackgroundObj(buttonObj, newUiButtonObject.uiButtonBackgroundObject);
            UiIntractable button    = buttonObj.AddComponent <UiIntractable>();

            button.targetImage  = buttonRef.GetComponent <Image>();
            button.ButtonColors = newUiButtonObject.uiButtonBackgroundObject;
            button.switchColor(0, newUiButtonObject.uiButtonBackgroundObject.normalColor);
            if (newUiButtonObject.uiButtonIcon != null)
            {
                newUiButtonObject.uiButtonBackgroundObject.uiObjName = "Icon";
                buttonObj.GetComponent <UiIntractable>().targetIcon  = CreateBackgroundObj(buttonObj, newUiButtonObject.uiButtonIcon);
                buttonObj.GetComponent <UiIntractable>().targetIcon.GetComponent <Image>().preserveAspect = true;
            }
            if (!disableText)
            {
                if (newUiButtonObject.uiButtonText != null)
                {
                    newUiButtonObject.uiButtonText.uiObjName = "Text";
                    CreateTextObj(buttonObj, newUiButtonObject.uiButtonText);
                }
            }
            return(button);
        }