UPalette
Centralized management & batch change system of colors for Unity.
Install / Use
/learn @Haruma-K/UPaletteREADME
Centrally manage colors and text styles in Unity projects.
<p align="center"> <img width="90%" src="https://user-images.githubusercontent.com/47441314/159275911-0445d1da-690b-4b56-86e8-85d57d79f257.gif" alt="Demo"> </p>Table of Contents
<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> <details> <summary>Details</summary>- Concept & Features
- Setup
- Getting Started
- Theme Feature Usage
- Advanced Usage
- Implemented Synchronizers
- Technical details
- How to update from version 1
- Demo
- Licenses
Concept & Features
In typical application development, one color is applied to multiple locations. The same blue color is applied to the button background, icon color, and outline in the following example.
<p align="center"> <img width="50%" src="https://user-images.githubusercontent.com/47441314/159170066-1bd16348-b013-4f47-8d64-988f43f2fde7.png" alt="Apply blue color"> </p>Now think about changing this color from blue to green. In Unity, color values are serialized in Prefabs and Scenes, so we need to change all these values one by one.
<p align="center"> <img width="50%" src="https://user-images.githubusercontent.com/47441314/158061951-ff91aaee-019a-4ea4-9c74-012a93f0558f.png" alt="Change the color to green"> </p>This workload increases with the size of the project. With uPalette, such changes can be applied in batches by centralizing color management.
<p align="center"> <img width="50%" src="https://user-images.githubusercontent.com/47441314/158061961-153d13ba-a4ee-45ee-b513-9d7956f21fa4.png" alt="uPalette"> </p>uPalette also allows you to manage text styles and gradients as well as colors.
<p align="center"> <img width="70%" src="https://user-images.githubusercontent.com/47441314/158065275-5b9e5801-88e8-4667-8cbe-67bc428d4b1e.png" alt="Character Styles & Gradients"> </p>In addition, the theme feature allows you to save a set of colors and text styles as a theme. By switching the active theme, you can reflect the colors and text style according to that theme.
<p align="center"> <img width="70%" src="https://user-images.githubusercontent.com/47441314/158065218-21a3f422-ad00-4da9-ab61-455408c2f7d1.gif" alt="Theme Feature"> </p>Setup
Requirements
Unity2020.1 or higher.
Installation
インストールは以下の手順で行います。
- Select
Window > Package Managerin Unity Editor. - Select
“+” Button > Add package from git URL. - Enter the following URL.
- https://github.com/Haruma-K/uPalette.git?path=/Assets/uPalette
If you want to install a specific version, add the version to the end of the URL as follows.
- https://github.com/Haruma-K/uPalette.git?path=/Assets/uPalette#2.0.0
You can also update the version in the same manner as installation.
Note that if you get a message like No 'git' executable was found. Please install Git on your system and restart Unity, you need to set up Git on your machine.
Getting Started
Create Palette Store
To use uPalette, first open the Palette Editor from Window > uPalette > Palette Editor. You will see a window like as follows when you open the Palette Editor.
Next, create a Palette Store asset by clicking the center Create Palette Store button. Palette Store is the asset that will hold the data for the uPalette. You can place this anywhere in the project, but not in the Editor folder or Streaming Assets folder because this asset is used at runtime.
After creating a Palette Store asset, the Palette Editor will change to the following display.
<p align="center"> <img width="70%" src="https://user-images.githubusercontent.com/47441314/157675124-bf3471c4-5f0f-4a07-ae10-8a97b3d986ad.png" alt="Palette Editor"> </p>Create Entry
In uPalette, color and character style settings are called Entries. You can add an Entry by pressing the “+” button in the upper right corner of the Palette Editor.
<p align="center"> <img width="70%" src="https://user-images.githubusercontent.com/47441314/157674758-981455be-7770-4a54-af49-71f69dd01276.gif" alt="Add Entry"> </p>You can rename an Entry by clicking on its name. Entries can also be deleted by right-clicking menu of them.
<p align="center"> <img width="70%" src="https://user-images.githubusercontent.com/47441314/157676311-1b7d12fc-a410-4303-a38a-fbe2f3192265.gif" alt="Rename & Remove Entry"> </p>You can also drag elements to reorder them.
Apply Entry
To apply the color and character style you created to components, select the target GameObject and press the Apply button for the target entry. The names of applicable components and properties will then be listed, and you can select the one you want to apply.
When multiple Synchronizers are implemented for the same component and property, the menu will display each Synchronizer name, allowing you to choose which Synchronizer to use.
<p align="center"> <img width="70%" src="https://user-images.githubusercontent.com/47441314/157679154-0e1aa71a-27f4-49c4-9c28-9eca8080f96d.gif" alt="Apply Entry"> </p>This will synchronize the entries and properties. When the value of a synchronized Entry changed, the property is automatically rewritten.
<p align="center"> <img width="70%" src="https://user-images.githubusercontent.com/47441314/157680482-2df5fe4c-3756-4422-89fb-208a89b1f657.gif" alt="Change Entry Value"> </p>At this time, a component named Synchronizer is attached to the target GameObject. You can change the target Entry from this Inspector. If you want to remove synchronization with the Entry, detach this component.
<p align="center"> <img width="70%" src="https://user-images.githubusercontent.com/47441314/162608969-56152f04-00f1-4b86-8d07-08537bd15c34.png" alt="Synchroizer"> </p>Note that When the Entry is applied to Prefab, It is not serialized in Prefab as in the normal Prefab workflow. You can serialize by right-clicking menu of Prefab.
<p align="center"> <img width="70%" src="https://user-images.githubusercontent.com/47441314/162609447-23ed99fb-2173-4717-84b6-79951ed70d88.gif" alt="Serialization"> </p>Highlight synchronized GameObjects
Select Highlight from the Entry’s right-clicking menu to highlight (select) the synchronized GameObjects.
<p align="center"> <img width="70%" src="https://user-images.githubusercontent.com/47441314/157684607-0b28a34a-c892-4458-9b0d-a3cdf8ea10e5.gif" alt="Highlight"> </p>Handling non-color Entries.
Up to this point, I have described how to manage colors in uPalette. In addition to colors, there are other palette types in uPalette, such as gradients and character styles. You can switch between Palette types from the drop-down menu in the upper left corner of the Palette Editor.
<p align="center"> <img width="70%" src="https://user-images.githubusercontent.com/47441314/157685702-e2d83f7c-4cfa-4b37-9561-0067f5c828c0.gif" alt="Various Palettes"> </p>Each drop-down menu is described below.
| Name | Description | | --- | --- | | Color | Use to manage color. | | Gradient | Use to manage gradient. | | Character Style | Use to manage character style of uGUI Text. | | Character Style TMP | Use to manage character style of Text Mesh Pro. |
Organizing Entries into Folders
You can organize entries into folders by separating entry names with slashes. When entries are organized into folders, they are displayed hierarchically in the Palette Editor as shown in the figure below.
<p align="center"> <img width="70%" src="Documentation/folder_mode.png" alt="Folder Mode"> </p> The setting to organize entries into folders can be changed from the following menu.- Project Set
