Git Product home page Git Product logo

hsv-color-picker-unity's Introduction

HSV Color Picker

openupm

HSV color picker using Unity UI. Unity Forum Thread

Versions

Unity 2020.3 LTS

Install

UPM

Follow the instructions on OpenUpm https://openupm.com/packages/com.judahperez.hsvcolorpicker/

{
    "scopedRegistries": [
        {
            "name": "package.openupm.com",
            "url": "https://package.openupm.com",
            "scopes": []
        }
    ],
    "dependencies": {
        "com.judahperez.hsvcolorpicker": "3.3.0"
    }
}

Unity Package

https://github.com/judah4/HSV-Color-Picker-Unity/releases

alt tag Should be really easy to use. Just add the prefab to the canvas, hook up an event, and it's good to go.

using HSVPicker;
using UnityEngine;

public class SomeClass : MonoBehavior
{

	public Renderer renderer;
	public ColorPicker picker;
     
	// Use this for initialization
	void Start ()
	{
		picker.onValueChanged.AddListener(color =>
		{
			renderer.material.color = color;
		});
		renderer.material.color = picker.CurrentColor;
	}
 
	// Update is called once per frame
	void Update () {
 
	}
	...

if you want to assign your own color first, just do this call and it sets the slider and picker to the proper selection.

    Color color = Color.green;
    picker.CurrentColor = color;

resizable panels

Can be toggled and sized as needed in settings.

Setup Settings

settings inspector

On the color picker setup section.

Show Rgb: Show RGB sliders.

Show Hsv: Show HSV sliders.

Show Alpha: Show the alpha slider.

Show Color Box: Show the larger color selection box and color column.

Show Color Slider Toggle: Show the button to toggle the HSV and RGB sliders.

Show Header: Options to show the top header with color preview and hex code.

  • Hide: Hide the top header.
  • Show Color: Show only the color preview in the header.
  • Show Color Code: Show only the color code in the header.
  • Show All: Show the entire top header.

Color Presets

The prefabs starts with 4 colors in the color presets. This can be updated in the Setup section of the picker prefab.
Set the Preset Colors Id for different shared list between color pickers.

hsv-color-picker-unity's People

Contributors

allista avatar benjaminbako avatar czpetrs avatar gamedev1020192 avatar grenqa avatar izanderlc avatar judah4 avatar kiwasi avatar kurozael avatar neogeek avatar scotsdez avatar segurvita avatar troien avatar yosun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hsv-color-picker-unity's Issues

Suggestion: Regenerate texture

Hi, I am trying to change the BoxSlider color, but after I have disabled the colorPicker, changed the color and then enabled the Color Picker the texture does not regenerate. It remains the same of the last color chosen.
Here the pic:
image

Previously I choose the green color, then disable the ColorPicker, and choose the purple color and at the end enable the ColorPicker. As can you see the texture is not generated.

But if I change the color afterwards the texture is correctly generated. If I understand correctly my problem is due this part of code from SVBoxSlider:

  private void OnEnable()
        {
            if (Application.isPlaying && picker != null)
            {
                slider.onValueChanged.AddListener(SliderChanged);
                picker.onHSVChanged.AddListener(HSVChanged);
            }
        }

that generate the texture after that the color has been changed. But in my case I have changed the code before the listener is active.

I have solved the problem adding RegenerateSVTexture(); at the end.

CSharp Files are missing namespace

Hi, nice package :)

In the latest release none of the .cs classes in this package has any namespaces. This makes it hard to add into a project as a UPM, as I cannot override / hard code a namespace for conflicting files.

Consider adding namespace to all CS files, to make it non conflicting.

I could add a pullrequest for this if I knew what namespace you wanted to use.

RGB color texture does not update

In order to maintain a compact design, I can only have 1 type of selector enabled at one time. This creates an issue when i modify the color from HSV and want to view it on RGB and vice-versa:
untitled

Type or namespace ColorChangedEvent/HSVChanged Event could not be found

Hi. Using Unity 2020.2.0b2.3094:

Assets/HSVPicker/UI/ColorPicker.cs(18,16): error CS0246: The type or namespace name 'ColorChangedEvent' could not be found (are you missing a using directive or an assembly reference)?

Assets/HSVPicker/UI/ColorPicker.cs(19,16): error CS0246: The type or namespace name 'HSVChangedEvent' could not be found (are you missing a using directive or an assembly reference)?

Thanks!
HSVPickerError

TextMeshPro Option

It would be really nice if this color picker had a TMPro option/version (or just make it the default)

Round version?

How can I make a roud version of this? So it fits in here?

color_picker

Doesn't work in the editor with Configurable Enter Play Mode

The picker stops working properly when fast enter play mode is enabled. The most obvious effect is that the hue slider on the left is white (ColorSliderImage's Awake is broken). There are also occasional errors in the console.

https://forum.unity.com/threads/configurable-enter-play-mode.768689/

ExecuteInEditMode/ExecuteAlways scripts are not destroyed/awaken - no OnDestroy/Awake calls for those.
Watch out for Awake/OnEnable methods which check EditorApplication.isPlaying property - Awake is not called and OnEnable is called only when EditorApplication.isPlaying is already true on Play Mode change.

Color not changing constantly.

"the color is not updated constantly. You have to hit one of the sides of the color box for the cube's color to change"

Hsv slider handle rectTransform becomes dirty on sceneload

Everytime I load the scene hsv slider handle recttransform value changes ( in some small way ) then If I try to switch the scene it will prompt me to save changes. also only happens if the panel is not active in the hierarchy. If its active and if I switch scenes it wont prompt to save scene.

LWRP Compatible shader

A shader that can be used on the new lightweight render pipeline would be great if could be implemented!

Cannot use HSVPicker

I could not use HSVPicker from Script.

When I installed it from unitypackage it was fine, when I called it from UPM by adding a URL, I could not using HSVPicker.

Would like the picker to start with my own, preset color

I'm not certain what to put or where to put it. I've been able to launch the picker, change the color and then save the value of the color changed; however, I have not been able to launch the picker with the starting color (whatever it is). Can you please help me? Thanks!

How to change color via script

I cannot use the Variable ColorPicker because unity cant find it for some reason, therefore not being able to change the color

Errors now with recent build of unity

From the patch notes:
UI- Added: void LayoutComplete(); and void GraphicUpdateComplete(); to ICanvasElement. These callbacks are issued when the referenced canvas events are completed. You will need to add these to any custom components that use this interface.

Errors we get are:
Assets/HSVPicker/BoxSlider.cs(9,22): error CS0738: UnityEngine.UI.BoxSlider' does not implement interface memberUnityEngine.UI.ICanvasElement.LayoutComplete()' and the best implementing candidate UnityEngine.UI.BoxSlider.Rebuild(UnityEngine.UI.CanvasUpdate)' return typevoid' does not match interface member return type `void'

Ok, so both voids but.. wait, what?

and

Assets/HSVPicker/BoxSlider.cs(9,22): error CS0535: UnityEngine.UI.BoxSlider' does not implement interface memberUnityEngine.UI.ICanvasElement.GraphicUpdateComplete()'

I tried putting in empty voids just to satisfy the error monster and it was still hungry.

Color Box doesn't update if you assign a colour via script

This is what it looks like when you use picker.AssignColor(Color) or picker.CurrentColor = Color
image
No matter what you do, the greyed out colour box will not update unless you click the input field with the hex code.
And this is what it looks like without these lines of code:
image

Is there a way to fix this?

slight issue when used as a pop-up that uses different colors

Scenario: You pick color 1 (let's say ends up as pure red) then close the color picker. You then pick color 2 from an originally gray color as base. The color box and other bars will still be in the red hue.

I solved this by adding
private void OnEnable() { SendChangedEvent(); }
on ColorPicker.cs

I believe the same issue happens with the sliders when you change from RGB to HSV, but I only use HSV so I didn't check on how to fix it.

Great tool by the way!

Hue Slider doesnt update on mouse click only drag

This is the only bug I've noticed however it could be working as intended. I apologize I didn't put into a branch/PR. Thanks for the color picker!

was able to fix by

  • adding following method to HSVPicker/UI/ColorSlider.cs
public void SliderClicked(BaseEventData data) {
       SliderChanged(slider.value);
}
  • Adding a EventTrigger Component to Hue ColorSlider
  • Adding SliderClicked to the eventtrigger

Unity 5.1/5.2 Hex Text not updating/working

I found that to get the hex text color to work I had to switch the public "Text" item over to be an actual "InputField" item and then access its .text component.
Examples:
// Unity 5.1/2 needs an InputFiled vs grabbing the text component
public InputField hexInput;

   public void ManipulateViaHex2RGB()
    {
string hex = hexInput.text;

...

Fails when hidden

I am trying to implement a car paint system. So, I hide the car paint window (where I have the color picker) in the main menu of my game. When I press a button to open (enable) the car paint window I get several errors.

Frist error:
Texture has out of range width / height
UnityEngine.Texture2D:.ctor(Int32, Int32)
HSVUtil:GenerateHSVTexture(Int32, Int32) (at Assets/HSVPicker/UtilityScripts/HSVUtil.cs:190)
HSVPicker:init() (at Assets/HSVPicker/HSVPicker.cs:57)
HSVPicker:Awake() (at Assets/HSVPicker/HSVPicker.cs:43)

Second error:
UnityException: Failed to create texture because of invalid parameters.
UnityEngine.Texture2D..ctor (Int32 width, Int32 height)
HSVUtil.GenerateHSVTexture (Int32 width, Int32 height) (at Assets/HSVPicker/UtilityScripts/HSVUtil.cs:190)
HSVPicker.init () (at Assets/HSVPicker/HSVPicker.cs:57)
HSVPicker.Awake () (at Assets/HSVPicker/HSVPicker.cs:43)

Errors on package import

Prefab errors
• Prefab's parent is missing a lot of script/component references
• Input field in prefab is not using TMPro causing reference errors

HSVPicker.asmdef Error
• Missing assembly reference to TMPro causing it not to work

Sliders do not refresh when changing from RGB to HSV - and viceversa

When working on a color on RGB, in compact mode where some of the sliders are hidden, if you make some changes, and then switch to HSV, HSV sliders are not up to date with the new color (textures display wrong colors and sliders are not in place).
If you keep making changes, sometimes its works, though, so this is easy to miss. Here there is a way to reproduce a mistake with the demo scene:
Picker bug

I tried to fix it working with the onEnabled functions on ColorSlider.cs and ColorSliderImage.cs, but that did not work for the HUE bar... I ended up doing a quick dirty fix on the ToggleColorSliders funciton on ColorPicker.cs

image

Sorry for not giving you a proper bug report with the bug perfectly described. I am unable at this time. I hope this helps, though. Thank you very much for the picker :-).

'HsvColor' does not contain a definition of 'NormalizedH'

I have just imported the newest release and the compiler throws out an error about these 3 lines of code in file "ColorPickerControl.cs" (I couldn't find it here on the repo)

230| _hue = color.NormalizedH;
231| _saturation = color.NormalizedS;
232| _brightness = color.NormalizedV;

It appears that changing the first letter of the word "Normalized" to lowercase in every line fixes the problem.

The generated texture for the color box should have it's texture wrap mode set to clamp

I'm not sure exactly why sometimes this happens and sometimes it doesn't, but in my current project there's been an issue where there's been an annoying 1 pixel wide border around the color box (probably something to do with the scaling of the color picker).
colorbox
This issue wasn't with the shader itself, but with the raw image component wrapping the generated texture weird.
I fixed this by (in the SVBoxSlider.cs) making a public variable for which texture wrap mode to use, defaulting it to clamp, and setting the generated textures to use that wrap mode.
I don't know if there's a better way to do that, but it fixed the problem (and it seems to me like it should be made the default for the generated color box texture).

Inverted HSV color

Thanks for the fantastic picker!
I tried to fix this issue myself but couldn't get a clue.
The HSV bar, differently from what is displayed on your images, is inverted. Contains red, magenta, blue and so on from top to down. When the slider is put on - say - magenta, that's the color after red from top to down, the color selected is actually yellow, that is the color after red from bottom up.
snap14
Thanks in advance! :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.