예제 #1
0
        void OnEnable()
        {
            category   = serializedObject.FindProperty("category");
            overrideUI = serializedObject.FindProperty("overrideUI");
            uiType     = serializedObject.FindProperty("uiType");

            textUI  = serializedObject.FindProperty("textUI");
            imageUI = serializedObject.FindProperty("imageUI");

            buttonUI     = serializedObject.FindProperty("buttonUI");
            toggleUI     = serializedObject.FindProperty("toggleUI");
            sliderUI     = serializedObject.FindProperty("sliderUI");
            scrollbarUI  = serializedObject.FindProperty("scrollbarUI");
            inputFieldUI = serializedObject.FindProperty("inputfieldUI");
            dropDownUI   = serializedObject.FindProperty("dropdownUI");

            comp = (ApplyUISkin)target;

            if (!overrideUI.boolValue)
            {
                comp.UpdateUI();
            }
        }
예제 #2
0
        public void ApplySkin(ApplyUISkin applyUISkin)
        {
            if (applyUISkin.uiType == ApplyUISkin.UI.Button) //Button
            {
                ButtonSkin buttonSkin = null;
                if (buttonSkins.ContainsKey(applyUISkin.category))
                {
                    buttonSkin = skin.buttonSkins[buttonSkins[applyUISkin.category]];
                }
                else
                {
                    buttonSkin = skin.buttonSkins[0];
                }

                SetButtonSkin(applyUISkin.buttonUI, buttonSkin);
            }
            else if (applyUISkin.uiType == ApplyUISkin.UI.Toggle) //Toggle
            {
                ToggleSkin toggleSkin = null;
                if (toggleSkins.ContainsKey(applyUISkin.category))
                {
                    toggleSkin = skin.toggleSkins[toggleSkins[applyUISkin.category]];
                }
                else
                {
                    toggleSkin = skin.toggleSkins[0];
                }

                SetToggleSkin(applyUISkin.toggleUI, toggleSkin);
            }
            else if (applyUISkin.uiType == ApplyUISkin.UI.Slider) //Slider
            {
                SliderSkin sliderSkin = null;
                if (sliderSkins.ContainsKey(applyUISkin.category))
                {
                    sliderSkin = skin.sliderSkins[sliderSkins[applyUISkin.category]];
                }
                else
                {
                    sliderSkin = skin.sliderSkins[0];
                }

                SetSliderSkin(applyUISkin.sliderUI, sliderSkin);
            }
            else if (applyUISkin.uiType == ApplyUISkin.UI.Scrollbar) //Scrollbar
            {
                ScrollbarSkin scrollbarSkin = null;
                if (scrollbarskins.ContainsKey(applyUISkin.category))
                {
                    scrollbarSkin = skin.scrollbarSkins[scrollbarskins[applyUISkin.category]];
                }
                else
                {
                    scrollbarSkin = skin.scrollbarSkins[0];
                }

                SetScrollbar(applyUISkin.scrollbarUI, scrollbarSkin);
            }
            else if (applyUISkin.uiType == ApplyUISkin.UI.InputField) //Scrollbar
            {
                InputFieldSkin inputFieldSkin = null;
                if (inputFieldSkins.ContainsKey(applyUISkin.category))
                {
                    inputFieldSkin = skin.inputFieldSkins[inputFieldSkins[applyUISkin.category]];
                }
                else
                {
                    inputFieldSkin = skin.inputFieldSkins[0];
                }

                SetInputFieldUI(applyUISkin.inputfieldUI, inputFieldSkin);
            }
            else if (applyUISkin.uiType == ApplyUISkin.UI.DropDown) //DropDown
            {
                DropDownSkin dropDownSkin = null;
                if (dropDownSkins.ContainsKey(applyUISkin.category))
                {
                    dropDownSkin = skin.dropDownSkins[dropDownSkins[applyUISkin.category]];
                }
                else
                {
                    dropDownSkin = skin.dropDownSkins[0];
                }

                SetDropDownSkin(applyUISkin.dropdownUI, dropDownSkin);
            }
            else if (applyUISkin.uiType == ApplyUISkin.UI.Text)
            {
                TextSkin textSkin = null;
                if (textSkins.ContainsKey(applyUISkin.category))
                {
                    textSkin = skin.textSkins[textSkins[applyUISkin.category]];
                }
                else
                {
                    textSkin = skin.textSkins[0];
                }

                SetTextSkin(applyUISkin.textUI, textSkin);
            }
            else if (applyUISkin.uiType == ApplyUISkin.UI.Image)
            {
                ImageSkin imageSkin = null;
                if (imageSkins.ContainsKey(applyUISkin.category))
                {
                    imageSkin = skin.imageSkins[imageSkins[applyUISkin.category]];
                }
                else
                {
                    imageSkin = skin.imageSkins[0];
                }

                SetImageSkin(applyUISkin.imageUI, imageSkin);
            }
        }
예제 #3
0
        public override void OnInspectorGUI()
        {
            category.stringValue = EditorGUILayout.TextField("Category", category.stringValue);

            overrideUI.boolValue = EditorGUILayout.Toggle("Override UI", overrideUI.boolValue);

            if (overrideUI.boolValue)
            {
                if (targets.Length == 1)
                {
                    ApplyUISkin.UI uiTypeE = (ApplyUISkin.UI)uiType.enumValueIndex;
                    uiTypeE = (ApplyUISkin.UI)EditorGUILayout.EnumPopup(new GUIContent("UI"), uiTypeE);
                    uiType.enumValueIndex = (int)uiTypeE;

                    switch (uiTypeE)
                    {
                    case ApplyUISkin.UI.Image:
                        EditorGUILayout.PropertyField(imageUI, new GUIContent("Button UI"), true);
                        break;

                    case ApplyUISkin.UI.Text:
                        EditorGUILayout.PropertyField(textUI, new GUIContent("Button UI"), true);
                        break;

                    case ApplyUISkin.UI.Button:
                        EditorGUILayout.PropertyField(buttonUI, new GUIContent("Button UI"), true);
                        break;

                    case ApplyUISkin.UI.Toggle:
                        EditorGUILayout.PropertyField(toggleUI, new GUIContent("Toggle UI"), true);
                        break;

                    case ApplyUISkin.UI.Slider:
                        EditorGUILayout.PropertyField(sliderUI, new GUIContent("Slider UI"), true);
                        break;

                    case ApplyUISkin.UI.Scrollbar:
                        EditorGUILayout.PropertyField(scrollbarUI, new GUIContent("ScrollBar UI"), true);
                        break;

                    case ApplyUISkin.UI.InputField:
                        EditorGUILayout.PropertyField(inputFieldUI, new GUIContent("InputField UI"), true);
                        break;

                    case ApplyUISkin.UI.DropDown:
                        EditorGUILayout.PropertyField(dropDownUI, new GUIContent("DropDown UI"), true);
                        break;
                    }
                }

                if (GUILayout.Button("Update UI"))
                {
                    for (int i = 0; i < targets.Length; i++)
                    {
                        ApplyUISkin comp = (ApplyUISkin)targets[i];
                        comp.UpdateUI();
                    }
                }
            }

            serializedObject.ApplyModifiedProperties();
        }