Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Color Picker for Unity UI

Discussion in 'Assets and Asset Store' started by cr4y, Nov 19, 2016.

  1. cr4y

    cr4y

    Joined:
    Jul 12, 2012
    Posts:
    38
    http://u3d.as/DsD

    Description:

    A color picker window that contains all basic tools for color selection. Its behaviour is similar to Unity’s built in color picker.

    We’ve included two different window prefabs, one built using Layout Groups, the other using RectTransform anchors. Both scale in a different way, so you can choose the one that better suits your needs and project setup.

    Features:
    • color Hex input
    • RGB sliders / inputs
    • HSV palette
    • Dropper tool
    Usage:
    Simply drag the prefab to your canvas, choose whether you need an alpha channel, setup default color, assign its reference to your script and that’s all. You can access the color selected with either the SelectedColor property or subscribe to ColorUpdated event that will be fired when the color is selected in game.

    scr1.jpg
     
    Last edited: Mar 9, 2017
    rakkarage likes this.
  2. cr4y

    cr4y

    Joined:
    Jul 12, 2012
    Posts:
    38
    Small fix: if anyone has issues with using dropper tool, please just drag one reference as on attached image.
    Version with this fix should be on assetstore within week.
     

    Attached Files:

    • fix.png
      fix.png
      File size:
      44.5 KB
      Views:
      662
  3. cr4y

    cr4y

    Joined:
    Jul 12, 2012
    Posts:
    38
    Thanks for your reply rakkarge. I've added link on top of description. I am aware that there are cheaper or free alternatives (and more expensive as well) packages available. If any of them would be useful enough for us, we'd never create this asset.
    We have done it for our game, and then put additional week of polishing into it and are really happy with results :)
    It has been tested by more than thousand players already and I believe it can definitely save some development time.
     
    rakkarage likes this.
  4. noorbeast

    noorbeast

    Joined:
    Jun 21, 2016
    Posts:
    9
    Can I clarify if this can be used with a ray cast pointer in SteamVR?
     
  5. lemondropkid

    lemondropkid

    Joined:
    Jul 3, 2017
    Posts:
    2
    Hi there cr4y. I purchased your Asset and it's great, but I do have an issue. If I put it inside a canvas that is set to render as Screen Space - Camera, clicking on the Palette to select a color doesn't work. This is also true if I change the canvas in the example scene. It applies to both the Layout Groups and Anchor Scaling prefabs. Is there a way to make this work?

    Also, no matter what I do, in my rather simple scene (nearly identical to the Example Scene in Hierarchy), I get the error "NullReferenceException: Object reference not set to an instance of an object
    Dropper.Awake () (at Assets/Color Picker/Code/Components/Dropper.cs:25)" at the start of scene play. That points to the line:
    Code (CSharp):
    1.  
    2. Camera.main.targetTexture = renderTexture;
    3.  
    I've also gotten it once or twice in the Example Scene but I can't seem to make it happen on command. It hasn't affected operation yet, but I haven't gotten very deep into implementation (i.e. using its values to affect any other elements) yet. Clicking the palette does work in my scene, as long as the containing canvas is set to Overlay (I'd rather use Camera but I'll cope for now) but the error is a little unsettling. Any insight you can provide would be greatly appreciated. Thanks in advance.
     
  6. cr4y

    cr4y

    Joined:
    Jul 12, 2012
    Posts:
    38
    Hi @lemondropkid ! I'm happy that you like the package. We'll check your issue and reach you back on Monday.
    Could you write me in PM your e-mail (in case if we'd have additional questions)?
     
  7. cr4y

    cr4y

    Joined:
    Jul 12, 2012
    Posts:
    38
    New version with HSV sliders added has just been uploaded to the AssetStore (should be available to download within week).
    Package was separately uploaded using Unity 5.5 and 2017 to improve compatibility within the range of these versions of Unity.
     
  8. Berno

    Berno

    Joined:
    Oct 29, 2014
    Posts:
    26
    Was there a solution to this as I have bought the asset today and hit the same problem in Screen Space - Camera.
    I need to run that Render mode for VR.

    It seems like InverseTransformPoint gives different results in that mode in the following function:
    Code (CSharp):
    1.         Vector2 GetClampedLocalPosition(Vector2 position) {
    2.             var pointerPosition = paletteImage.gameObject.transform.InverseTransformPoint(position);
    3.             pointerPosition.x = Mathf.Clamp(pointerPosition.x, 0, paletteImage.rectTransform.rect.width);
    4.             pointerPosition.y = Mathf.Clamp(pointerPosition.y, 0, paletteImage.rectTransform.rect.height);
    5.             return pointerPosition;
    6.         }
     
  9. jeffcrouse

    jeffcrouse

    Joined:
    Apr 30, 2010
    Posts:
    13
    How do I go about setting the initial color via script? I have tried both "colorPicker.SelectColor(c)" and "colorPicker.SelectedColor = c", and I do get a callback saying that the color has changed, but then it immediately changes back to red.
     
unityunity