public void ApplyColors(GameObject root) { UIStyle[] styles = root.GetComponentsInChildren <UIStyle>(true) .Union(m_prefabs.Where(p => p != null).SelectMany(p => p.GetComponentsInChildren <UIStyle>(true))).ToArray(); for (int i = 0; i < styles.Length; ++i) { UIStyle style = styles[i]; switch (style.Name) { case "PrimaryColor": style.ApplyImageColor(Colors.Primary); break; case "SecondaryColor": style.ApplyImageColor(Colors.Secondary); break; case "BorderColor": style.ApplyImageColor(Colors.Border); break; case "Border2Color": style.ApplyImageColor(Colors.Border2); break; case "Border3Color": style.ApplyImageColor(Colors.Border3); style.ApplyOutlineColor(Colors.Border3); break; case "Border4Color": style.ApplyImageColor(Colors.Border4); style.ApplyOutlineColor(Colors.Border4); break; case "AccentColor": style.ApplyImageColor(Colors.Accent); break; case "TextColor": style.ApplyTextColor(Colors.Text); style.ApplyImageColor(Colors.Text); break; case "Text2Color": style.ApplyTextColor(Colors.Text2); style.ApplyImageColor(Colors.Text2); break; case "ModalOverlayColor": style.ApplyImageColor(Colors.ModalOverlay); break; case "MainMenuBarColor": style.ApplyImageColor(Colors.MainMenuBar); break; case "MainMenuButtonColor": UIMenuStyle.ApplyMainButtonColor(style, Colors.MainMenuButton.Normal, Colors.MainMenuButton.Highlight, Colors.MainMenuButton.Pressed); break; case "MenuItemColor": UIMenuStyle.ApplyMenuItemColor(style, Colors.MenuItem.SelectionColor, Colors.MenuItem.TextColor, Colors.MenuItem.DisabledSelectionColor, Colors.MenuItem.DisabledTextColor); break; case "ToolsToggleColor": style.ApplyImageColor(Colors.ToolsToggle); break; case "FooterColor": style.ApplyImageColor(Colors.Footer); break; case "HierarchyColor": UIEditorStyle.ApplyHierarchyColors(style, Colors.Hierarchy.NormalItem, Colors.Hierarchy.DisabledItem); break; case "ProjectFolderColor": style.ApplyImageColor(Colors.ProjectFolder); break; case "ConsoleButtonColor": style.ApplySelectableColor(Colors.ConsoleButton.Normal, Colors.ConsoleButton.Highlight, Colors.ConsoleButton.Pressed, Colors.ConsoleButton.Disabled, Colors.ConsoleButton.Selected); break; case "ScrollBarColor": style.ApplySelectableColor(Colors.ScrollBar.Normal, Colors.ScrollBar.Highlight, Colors.ScrollBar.Pressed, Colors.ScrollBar.Disabled, Colors.ScrollBar.Selected); break; case "ScrollBarBackgroundColor": Image image = style.GetComponent <Image>(); if (image != null) { if (Colors.ScrollBarBackground != RTEColors.DefaultScrollBarBackground) { image.sprite = null; } else { if (image.name.Contains("V")) { image.sprite = Resources.Load <Sprite>("DarkBackV"); } else { image.sprite = Resources.Load <Sprite>("DarkBackH"); } } } style.ApplyImageColor(Colors.ScrollBarBackground); break; case "ToggleColor": style.ApplySelectableColor(Colors.Toggle.Normal, Colors.Toggle.Highlight, Colors.Toggle.Pressed, Colors.Toggle.Disabled, Colors.Toggle.Selected); break; case "Toggle2Color": style.ApplySelectableColor(Colors.Toggle2.Normal, Colors.Toggle2.Highlight, Colors.Toggle2.Pressed, Colors.Toggle2.Disabled, Colors.Toggle2.Selected); break; case "ToggleButtonColor": style.ApplySelectableColor(Colors.ToggleButton.Normal, Colors.ToggleButton.Highlight, Colors.ToggleButton.Pressed, Colors.ToggleButton.Disabled, Colors.ToggleButton.Selected); break; case "InputFieldColor": style.ApplyInputFieldColor(Colors.InputField.Normal, Colors.InputField.Highlight, Colors.InputField.Pressed, Colors.InputField.Disabled, Colors.InputField.Selected); break; case "InputField2Color": style.ApplyInputFieldColor(Colors.InputField2.Normal, Colors.InputField2.Highlight, Colors.InputField2.Pressed, Colors.InputField2.Disabled, Colors.InputField2.Selected); break; case "ButtonColor": style.ApplySelectableColor(Colors.Button.Normal, Colors.Button.Highlight, Colors.Button.Pressed, Colors.Button.Disabled, Colors.Button.Selected); break; case "Button2Color": style.ApplySelectableColor(Colors.Button2.Normal, Colors.Button2.Highlight, Colors.Button2.Pressed, Colors.Button2.Disabled, Colors.Button2.Selected); break; case "SliderColor": style.ApplySelectableColor(Colors.Slider.Normal, Colors.Slider.Highlight, Colors.Slider.Pressed, Colors.Slider.Disabled, Colors.Slider.Selected); break; case "DropdownColor": style.ApplySelectableColor(Colors.Dropdown.Normal, Colors.Dropdown.Highlight, Colors.Dropdown.Pressed, Colors.Dropdown.Disabled, Colors.Dropdown.Selected); break; case "ToolCmdItemColor": UIEditorStyle.ApplyToolCmdItemColor(style, Colors.ToolCmdItem.Normal, Colors.ToolCmdItem.Highlight, Colors.ToolCmdItem.Pressed); break; case "TimlineControlBackgroundColor": UIEditorStyle.ApplyTimelineControlBackgroundColor(style, Colors.Secondary); break; } } }
public void ApplyColors(GameObject root) { UIStyle[] styles = root.GetComponentsInChildren <UIStyle>(true) .Union(m_prefabs.Where(p => p != null).SelectMany(p => p.GetComponentsInChildren <UIStyle>(true))).ToArray(); for (int i = 0; i < styles.Length; ++i) { UIStyle style = styles[i]; switch (style.Name) { case "PrimaryColor": style.ApplyImageColor(Colors.Primary); break; case "SecondaryColor": style.ApplyImageColor(Colors.Secondary); break; case "BorderColor": style.ApplyImageColor(Colors.Border); break; case "Border2Color": style.ApplyImageColor(Colors.Border2); break; case "Border3Color": style.ApplyImageColor(Colors.Border3); style.ApplyOutlineColor(Colors.Border3); break; case "Border4Color": style.ApplyImageColor(Colors.Border4); style.ApplyOutlineColor(Colors.Border4); break; case "AccentColor": style.ApplyImageColor(Colors.Accent); break; case "TextColor": style.ApplyTextColor(Colors.Text); style.ApplyImageColor(Colors.Text); break; case "Text2Color": style.ApplyTextColor(Colors.Text2); style.ApplyImageColor(Colors.Text2); break; case "ModalOverlayColor": style.ApplyImageColor(Colors.ModalOverlay); break; case "MainMenuBarColor": style.ApplyImageColor(Colors.MainMenuBar); break; case "MainMenuButtonColor": style.ApplyMainButtonColor(Colors.MainMenuButton.Normal, Colors.MainMenuButton.Highlight, Colors.MainMenuButton.Pressed); break; case "MenuItemColor": style.ApplyMenuItemColor(Colors.MenuItem.SelectionColor, Colors.MenuItem.TextColor, Colors.MenuItem.DisabledSelectionColor, Colors.MenuItem.DisabledTextColor); break; case "ToolsToggleColor": style.ApplyImageColor(Colors.ToolsToggle); break; case "FooterColor": style.ApplyImageColor(Colors.Footer); break; case "HierarchyColor": style.ApplyHierarchyColors(Colors.Hierarchy.NormalItem, Colors.Hierarchy.DisabledItem); break; case "ProjectFolderColor": style.ApplyImageColor(Colors.ProjectFolder); break; case "ConsoleButtonColor": style.ApplySelectableColor(Colors.ConsoleButton.Normal, Colors.ConsoleButton.Highlight, Colors.ConsoleButton.Pressed, Colors.ConsoleButton.Disabled); break; case "ScrollBarColor": style.ApplySelectableColor(Colors.ScrollBar.Normal, Colors.ScrollBar.Highlight, Colors.ScrollBar.Pressed, Colors.ScrollBar.Disabled); break; case "ScrollBarBackgroundColor": style.ApplyImageColor(Colors.ScrollBarBackground); break; case "ToggleColor": style.ApplySelectableColor(Colors.Toggle.Normal, Colors.Toggle.Highlight, Colors.Toggle.Pressed, Colors.Toggle.Disabled); break; case "ToggleButtonColor": style.ApplySelectableColor(Colors.ToggleButton.Normal, Colors.ToggleButton.Highlight, Colors.ToggleButton.Pressed, Colors.ToggleButton.Disabled); break; case "InputFieldColor": style.ApplyInputFieldColor(Colors.InputField.Normal, Colors.InputField.Highlight, Colors.InputField.Pressed, Colors.InputField.Disabled, Colors.InputField.Selected); break; case "InputField2Color": style.ApplyInputFieldColor(Colors.InputField2.Normal, Colors.InputField2.Highlight, Colors.InputField2.Pressed, Colors.InputField2.Disabled, Colors.InputField2.Selected); break; case "ButtonColor": style.ApplySelectableColor(Colors.Button.Normal, Colors.Button.Highlight, Colors.Button.Pressed, Colors.Button.Disabled); break; case "Button2Color": style.ApplySelectableColor(Colors.Button2.Normal, Colors.Button2.Highlight, Colors.Button2.Pressed, Colors.Button2.Disabled); break; case "SliderColor": style.ApplySelectableColor(Colors.Slider.Normal, Colors.Slider.Highlight, Colors.Slider.Pressed, Colors.Slider.Disabled); break; case "DropdownColor": style.ApplySelectableColor(Colors.Dropdown.Normal, Colors.Dropdown.Highlight, Colors.Dropdown.Pressed, Colors.Dropdown.Disabled); break; } } }