Unity Color Picker is a Visual Studio Code extension that provides an interactive color picker for various color formats used in Unity projects. It enhances your coding workflow by offering intuitive color previews and easy editing capabilities directly within your code editor.
📦 Features
Multiple Color Formats:
Unity Color: new Color(r, g, b, a) (Alpha values are optional)
Unity Color32: new Color32(r, g, b, a) (with values ranging from 0 to 255)
Preset Colors: Color.red, Color.green, Color.blue, etc.
Inline Color Decorations: Displays color swatches next to color definitions in your code.
Native Color Picker Integration: Click on a swatch to open VSCode’s built-in color picker for easy color adjustments.
Optional Background Color: Adds a background color decoration behind detected colors, configurable via settings.
🛠 Usage
Open a Supported File: Open any C# file (.cs) containing Unity color definitions.
using UnityEngine;
public class TestColor
{
void Start()
{
// Using new Color constructor
Color myColor = new Color(0.3f, 0.3f, 0.3f, 1f);
// Using Color32 constructor
Color32 myColor32 = new Color32(76, 153, 0, 255);
// Using preset color
Color presetColor = Color.red;
}
}
View Color Decorations: The extension automatically detects color values and displays a color swatch beside each color definition.
Edit Colors:
Using Native Picker: Click on the color swatch to open VSCode’s native color picker. Adjust the color as desired, and the color value in your code will update in real-time.
🔧 Configuration
Enable/Disable Background Color Decoration
You can toggle the background color decoration using the following setting:
Set to true to enable background color decorations.
Set to false to disable background color decorations.
Example settings.json Entry
{
"unityColorPicker.showBackgroundColor": true
}
🧾 License
This project is licensed under the MIT License.
🤝 Contributing
This extension will not be actively improved or updated with new features unless it breaks due to changes in VSCode or Unity. If you would like to see new features or improvements, I highly encourage you to fork the repository and make changes as needed. You can find the repository on my GitHub profile.