Custom color for any object

I have in my map an object layer called “playerstarts”. Each playerstart has a custom value called “team” which can be 1(red) or 2(blue). Every object is the same color however. It would be great for any with team 1 to be red in color, etc.

Currently I can make new layers to make things have different colors but it would really be great if each object could have its own color assigned to it. This would make managing my objects much easier.

Hope to see this in a future update :slight_smile:

Note that in addition to per-layer color, you can also set a color for each object type in the Preferences, maybe that helps?

In any case I don’t think adding a per-object color override is a bad idea.

1 Like

Thanks bjorn, that helps for now, my map looks better already :joy:

Per-object color override would be awesome since…
A) custom colors per object would be saved in each individual map.
B) Over time preferences>object types would eventually become a large unmanageable mess :scream:

Right, I didn’t save the colors in the map because that way you’d have to set up the colors manually all the time, whereas having them in the preferences you set it up only once and you can even change your mind about the colors easily later. There’s the option to export the color definitions to XML to share it with others.

My assumption here is that you will actually have only a limited amount of different object types of course. I think of types like “exit”, “spawn area”, “teleporter”, “npc”, “checkpoint”, etc. Even in your example you only mentioned two colors.

So while I don’t think individual colors would be a bad feature, I haven’t rushed to add it because I thought the other coloring mechanisms were more appropriate in most cases.

1 Like

I can see that changing each objects color might be a bit time consuming.

I mentioned 2 colors in my example but I have many different object types that will eventually be added to my maps.

Anyway, for now changing the settings in prefs will suffice :slightly_smiling:

Hi again Bjorn :slight_smile:
So it would really be good if you could have object type colors saved in a map file. I find when I export (to lua) that object types are not exported. so I have to have separate tables with corresponding colors in my source code.

Also, when I give maps to other team members… if their Tiled is not configured exactly as mine… the object colors we have decided on are not present.

So I personally think it would be great to be able to save those somehow in the map and have them exported as well :slight_smile:

Nice to hear from you again after all this time. :wink:

The main thing that should help right now is to change the location of your objecttypes.xml file to be inside of your repository, so that all your team members can choose to use that one and you guys will stay in sync. You can do this via the “File” menu in the object types editor.

For exporting, I think there could be an option to embed these object types as discussed at issue Default object properties derived from type properties are not included into Lua export file · Issue #1313 · mapeditor/tiled · GitHub.

1 Like

Regarding this, in general, I think it should be solved by introducing a “project” file that covers all such relevant configuration. It would give a clear separation between settings that are user-specific and those that are project-specific like the object types.

I’d rather not solve the issue by moving all “project” settings into the map file.

I was going to ask where the heck that file was but I finally found objecttypes.xml in some obscure windows folder :smiley:

I can work around this all but really my list of object types now exceeds one hundred and only about a 1/4 of them are related to my current project.

Even being able to save them as different names and having a list where you could select which one to use would be pretty good :wink:

So, you can already save that file in a different place and switch between files when you switch projects. It’s just not as convenient as it could be. Like I said before, I think having a Tiled project file would resolve this. Since recently the idea has a proper issue on GitHub:

https://github.com/bjorn/tiled/issues/1665

Just want to chime in here, I came across an instance where per-object colors would be preferred over object types - basically I have some objects that to the game engine are all one Type, but I want them to have unique colors each. Currently working around this by telling my engine to ignore the “Type” value of this layer so that I can make each object a separate color.

This thread is two years old so I don’t know whether this issue was addressed after it was posted or whether this is an old feature, but you can assign custom Color properties to objects.

TBH I always figured the object type colours were more for differentiating different types of objects in the editor, so when it came to assigning them colours, I always did so with custom properties, which can have a default assigned for each type in the Object Types Editor while also being easily overridable :'D

Maybe I should clarify- I’m trying to change the color of rectangle objects in the editor so I can tell them apart visually, not add a color property to the rectabgle.

No worries, it was clear from your post, which is why I mentioned that the custom colour doesn’t display in Tiled.

If you need to tell them apart visually while editing your level (as opposed to in-engine, where you can do it via the custom property), then it sounds like they should be different object types, even if they have otherwise similar/identical properties. As I mentioned, the object colours in Tiled seem to me to be primarily meant for ease of visual identification during editing, not for in-game purposes.

1 Like

Unfortunately it is the case that you can only set the color for an objects type and you are not able to set the color of individual objects.

More inflexible is that you cannot embed this information inside a tiled map on a per map basis and your object types list starts to get very bloated after a few projects, and you cannot delete the ones not applicable to a current project… because opening a file from a previous project will cause all colors to be incorrect.

Thanks @AxiomVerge and @Rabbit for the additional feedback. I definitely think it makes sense to support per-object colors in Tiled, since indeed per-type or per-object-layer (which is also an option) is not always what people are looking for. It’s a feature that should be quite easy to add, so I will try to get around to that soon.

As for storing the object types in a map file, this has other disadvantages so what I’m really looking to do is to associate this stuff with a project file, as I mentioned in my previous comment. Due to other priorities this will take a bit longer to get around to, but I do plan to work on that within a few months.

1 Like

Thanks, that’s cool :slight_smile:

To be able to easily distinguish shapes, and markers in the editor, while editing would benefit from per object colors.

I feel like it’s a nicer flow than to create a different layer to distinguish colors.
Anyways, I’m just wondering where this is at :slight_smile:

One more vote for being able to color code shapes and markers. Just so that they’re easier to see while editing complex maps :smile:

Any update on this???