Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Release] Color Palettes for Unity

Discussion in 'Assets and Asset Store' started by DomDom, Feb 10, 2015.

  1. DomDom

    DomDom

    Joined:
    Oct 18, 2013
    Posts:
    33
    Create awesome color sets to enhance your Games!

    The Color palettes asset gives you the possibility to setup various color schemes for your games. It can be used for SpriteRenderer and Material tinting, color transitions, customisation of characters, vertex coloring or simply applying color to any component which has a color.

    Available in the Asset Store: http://u3d.as/bFr

    Example with a Car model from the Sample Assets from Unity Technologies:

    AllCars.jpg

    Features of the version 1.0.1:
    • Simple, convenient UI for ColorPalettes with colorwidths
    • Collection script for multiple palettes
    • Import palettes from colourlovers.com and pltts.me
    • Example Scripts
      • Drag'n'Drop components on the palette to assign a color
      • Color switching / lerping through a palette
      • BackgroundPalette which changes in synch with the palette
      • Color switcher for vertex colors
      • Coloring of SpriteRenderer and switching through a collection

    Here is what the Editor Extenstion looks like:

    Palette_Vintage.jpg

    There are collections of Palettes aswell:

    Collection_1.jpg

    Here is a Preview to see these palette collection for tinting a car model, like the first picture:



    Similar collection of palettes with aircrafts:





    Hi Everyone

    For the very basic assignment of the colors no coding is needed, just drag and drop a gameobject with a renderer or any component with a color on it.

    drag'n'drop.png

    For any other assignments the colors and maybe how the percentages of a palette influence the gameobject coding is needed. But it's very simple, the PaletteData is just a list with Colors and Percentages. For example to tint multiple Sprites:

    Collection_sprites.gif



    The Assets includes five example scenes which provide give a starting point to very specific implementations.

    I'd like to hear what you think about the Color Palettes Asset! It is going to be available soon!


    Further links:

    Asset Store:
    http://u3d.as/bFr

    Video Tutorial about the examples:
    http://bit.ly/13Y9GRs

    API:
    http://dominikhaas.ch/ColorPalettes/namespaces.html

    Issues & Feature requests:
    https://trello.com/b/sllkb6cS
     
    Last edited: Feb 20, 2015
    alexanderameye likes this.
  2. DomDom

    DomDom

    Joined:
    Oct 18, 2013
    Posts:
    33
    Two minor updates in version 1.0.2

    Percentage values can be locked:

    LockPercentages.gif

    And the position of colors can be changed via drag'n'drop:

    ChangePosition.gif
     
  3. Kiori

    Kiori

    Joined:
    Jun 25, 2014
    Posts:
    161
    Hi there this asset luck fits onto what I'm working on right now. I have a few questions though
    Is it compatible with the current UI system?

    What i need specifically is i have sprites in game, and i want the user to be able to change the sprites colors at run time, not unlike mmos, even though these sprites are not characters.
    I thought offering the user a palette could be a nice idea.

    So is this possible for me, does it work on spriteRender colors, and can i display the palette to the end user at run time, and still have it work?
    I saw that it works with meshes and lights, but my color changing doesn't touch the materials themselves since i need the draw calls.
    Are there any overheads/performance considerations?
    can the user import its own 'downloaded' palette at runtime?


    Overall if it works good i can see a lot of uses for your asset.
     
  4. DomDom

    DomDom

    Joined:
    Oct 18, 2013
    Posts:
    33
    Hi Kiori

    The Color Palette works with Sprites (with the SpriteRenderer color) as shown here. And Here:
    Collection_sprites.gif

    You could create a Collection and then let the user choose a Palette or if you one sprite just let the chose the color and apply it.

    So would you like to offer different palettes and the user chooses one of them, or the user can create one during runtime?

    The UI System is supported for Drag'n'Drop for components which have one color, like Image or Text, for a Button which has multiple colors you would have to apply the colors during runtime via code (eg. in the Awake() function) or by yourself via Colorpicker. The examples are in the asset so it would be quite easy for you assign it via code.

    Displaying a Color Palette ingame isn't exactly done yet, there is an example the "BackgroundPalette" which represents the palette through planes. You could use that as a starting point and to show the palette to the user via UI. But I pick that up as a Feature Request: "Displaying a palette Ingame via UI", thank you for pointing it out!

    I'm working an a convenient script to make the color assignement easier. For know it requires a bit of coding.

    Considering performance it shouldn't create a overhead, since it only changes the color of a compontent or material. But I haven't made any stress test so far.

    The import of a palette only works in the UnityEditor, but the palette data is saved as .asset file and is Serializable so it could be sent over the network.
     
    Last edited: Feb 22, 2015
  5. Kiori

    Kiori

    Joined:
    Jun 25, 2014
    Posts:
    161
    Yeah the idea is to have a pre-made palette and offer it to the user as an option, so he's not lost scrambling for colors but has 'some' presets. And there are lots of ways i can do this, you know display an icon with x color in the ui and xcolor name, or even in a drop down list of some sort, and that icon/color triggers the spriterender color change for x color in said sprite.
    But if you had a way to display this in the gui system, it would be very elegant, and it would simplify a few hours of hacking and coding.

    I thought the example at 9m54s was for 3d meshes didn't realize you were using sprites. So collections link colors to specific game object structs, like material color, or spriterender color, or light color. And the you can switch them on the go, correct?

    This in its self is quite handy.
    Another feature request that i'd have is, you mentioned colourlovers, well it would be cool if the user could make his own palette, in whatever format, or download one from that website. Maybe in html format to make things easier? and then a script at run time would convert said palette to a in-game usable one, -And ideally it would link to a collection or whatnot.
    Therefore the first color in line would change color A of an item, second color, color B, etc of the entire whatever being displayed.

    I'm not sure I fully understand your system so i may be wrong, but you got the general idea.

    Please let me know on any progress made, either way I'll be picking this up in the near future, simply having a set of colors saved somewhere as presets is already really good for artists.
     
  6. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,676
    I don't know if this or any other asset does this, but I would be looking for something inexpensive that helps the dev and/or players pick matching colors.
     
  7. DomDom

    DomDom

    Joined:
    Oct 18, 2013
    Posts:
    33
    I just created a PaletteUI script which can be added to a canvas, it adds an Image Component which shows the palette. That can be used to select a pre-made palette during runtime like any other UI component.

    UI_Sprite_small.gif

    Next step create that for Collections which will be similar to the Part in the video.

    Yes, white that exaple you'd simply have to switch the number of which palette to use and the whole sprite structur (in the that case the "spaceship") will change.

    Yeah, I feel you on that one! :D I want to do something like this, how awesome would it be to login to colorlovers and use your own palettes to your characters!
    But that requires some in detph programing with the html, login and account handling and the whole visualization of the data can be quite time consuming. I have to check out if colorlovers as an API, otherwise it could become hard...

    I'm going to have a closer look on that one somewhere in the future, but for now I will be improving the color assignment on GameObjects. I'm implementing a script which will list all the components with a color so they can be assigned and will be in sync with just a mouse click.
     
  8. DomDom

    DomDom

    Joined:
    Oct 18, 2013
    Posts:
    33
    Hi hopeful

    By now the Color Palettes Asset doesn't give any help to which colors you should pick. There are plenty of website which can help with that:
    http://paletton.com/
    http://www.0to255.com/
    http://webdesignledger.com/tools/10-super-useful-tools-for-choosing-the-right-color-palette

    http://www.colourlovers.com/
    http://pltts.me
    (Import from colourlovers.com and pltts.me are supported)

    What you can do is create Palettes and schemes online and copy past the hex values into the Palette:

    Palette_Vintage.jpg
     
  9. Kiori

    Kiori

    Joined:
    Jun 25, 2014
    Posts:
    161
    Oh no thats too complex, i didn't mean it like that, what i meant was you create your palette, download it to your phone in a html format, or whatnot. then the game loads it.

    But yeah maybe i'm overdoing this. :D

    Now that i think of it, if I do this in the future i think i might implement a script that allows the user to pick a color in game, one for each position in the palette, then export it in some xml or text format, so they can share it around. Or maybe even i'll write a side program that generates these... crazy ideas.
    But that's tomorrow, my needs for now are much simpler.


    Just o make sure i was clear my need in the project is to have a series of pre-set colors, player will choose one of these colors by clicking on them(ideally, through your asset) and they will change the color of a single sprite(gameobject), so the palette would be all the possible colors the sprite could have, like ideal colors that actually look good.
    Also i'm making it so the player can pick any color at will, with a color picker script i found on the forums.
    Basically it makes the unity color picker available for the end user.

    You can find it here btw:
    http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/
    its called colorpicker.
    If you could integrate something like that into the asset it might -also be a selling point, its something to consider.
    It would be nice to have it all in one package. And also it would be much better since your asset makes the hex values actually available, which is great for people that actually know colors.

    Keep us posted on your progress. ;)
     
  10. DomDom

    DomDom

    Joined:
    Oct 18, 2013
    Posts:
    33
    Actually in the first version of this asset I saved the Data in a textfile in JSON. So I'll re-add that at some point.

    I'm working on a example to make that easily possible.

    For now (version 1.0.x) my focus is to give game designers a great way to setup palettes and apply the colors to GameObjects, so less coding is need for the normal use cases. But I will take that in consideration for a later version, thank you for your Input. Creating a Palette during runtime and import & export them would be great. It gives a lot of freedom to the players.

    I also thought about creating ways to help creating a palette, for example from a Image. Or giving the possibility of picking colors with different algorithms like analogous or achromatic to create color harmonies.
     
    Last edited: Mar 25, 2015
    Kiori likes this.
  11. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    Hi, DomDom,

    This asset looks quite interesting,
    I have some questions here:

    1. how does it adjust VertexColor in a mesh?
    upload_2016-4-11_20-51-28.png
    Assume I've one tree mesh with multiple colors here.
    Can I remap the colors in this mesh altogether with the palette?
    Like "Hue adjustment" / "Gradient Map" / "LUT" in Photoshop?
    upload_2016-4-11_21-2-1.png

    2. Can I switch multiple GameObject's color with one click?
    Say I have 100 different trees in the scene,
    Can I switch their palette altogether with one click of change of palette?
     
    Last edited: Apr 11, 2016
  12. B_Datcu

    B_Datcu

    Joined:
    Jan 25, 2017
    Posts:
    1
    Hello. I have a question. i saw that this works with sprite renderers. would it be safe to assume it would also work on mesh renderers? currently using meshes from my sprites due to some animation needs and i thought about randomizing colors for some cloths and found this and looks right up my alley.
     
  13. DomDom

    DomDom

    Joined:
    Oct 18, 2013
    Posts:
    33
    Hi There to answer the first question:
    The palettes are a way to store and edit the colors. As for applying them to a complex vertext setup you would have to implemented that. I made an example of how to apply colors to all vertext colors of an mesh. But when it comes to "how to change / apply" them, that's something which is be different from mesh to mesh, so you have to define that.

    For the second question:
    That's possible if you change the colors of a palette itself or use the PaletteCollectionData and then switch through them. There is an example in the "Sprites_example" scene for the Collections of Palettes and how to switch through them during Runtime.

    However it doesn't work out of the box with all the example scripts provided.

    Am I correct in assuming that you're focus is on switchting it during runtime?

    If you want to do it in a scene while in the Editor you can use this script:
    https://gist.github.com/DomDomHaas/518d60d388bc593b2ffa5975abb9172b
    Together with this Editorscript (make sure to save in the "Editor" folder of ColorPalettes):
    https://gist.github.com/DomDomHaas/971351d3be4bf5e7a7a184eaf5a196fa

    Thanks for bringing that up, I'll take up as a feature request (Switch all Palettes at once in Editor & during Runtime).
     
    Last edited: Feb 16, 2017
  14. DomDom

    DomDom

    Joined:
    Oct 18, 2013
    Posts:
    33
    Hey Hello

    There is an example in the "Sprites_example" scene, which shows how the colors can be applied to an GameObject with multiple sprites. It basically changes the "color" attribute of the SpriteRenderer.

    Am I correct in assuing that you're using sprites as a texture for the meshes?

    So in the case you're using the mesh renderer together with materials, that it just a matter of changing the materials color. But that means you have to use a different materials for the different parts of a character (ex. the body and the cloths).

    What this assets doesn't do is randomizing colors! It's actually more the opposite, it's a tool to easier figure out nice comibinations of colors with trying the directly in the editor.
     
  15. AcidmanRPGz

    AcidmanRPGz

    Joined:
    Feb 14, 2020
    Posts:
    10
    Can this limit the colour palette in real time, as if it were original DOOM?
     
  16. DomDom

    DomDom

    Joined:
    Oct 18, 2013
    Posts:
    33
    Hi There, I've just got the notification via email now... one year later lol... was up with unity forums :)
    Sorry for that.

    The color palettes extension is basically a collection of colors with some ways to assign them to game objects, but no implementation is done for any effects. So it doesn't have that out of the box, but If you can code it wouldn't be too hard to transfer the colors from a color palette into an effect or it's texture.

    cheers