Unset custom color property

General discussion about the R.U.B.E editor
Post Reply
joolean
Posts: 19
Joined: Mon Jun 24, 2013 7:46 am

Unset custom color property

Post by joolean »

Is there a way to unset a custom color property?
With other properties you can just delete them and they won't be exported but once I've set a color, I can't see anyway to unset it.
Cheers.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Unset custom color property

Post by iforce2d »

This might help:
viewtopic.php?f=7&t=457
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Unset custom color property

Post by iforce2d »

ah, if you mean just using the GUI.... nope.
Setting the color to white with full opacity will have the same effect though.
joolean
Posts: 19
Joined: Mon Jun 24, 2013 7:46 am

Re: Unset custom color property

Post by joolean »

Sorry I did search for "unset custom color property" beforehand but only checked the discussion forum and got no results.

I did mean in the gui, but that's ok, the code you pointed to worked. Thanks.

The reason I want to clear them is so they don't get exported into my json as it's wasted space, and just setting the color to white doesn't stop it being exported.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Unset custom color property

Post by iforce2d »

Yeah I figured that was what you were trying to do. Another way to handle it would be with a property export filter, to look at the color values and ignore any default color properties:

Code: Select all

bool shouldExportProperty( body b, const string& in propertyName ) {
	if ( b.getCustomPropertyType( propertyName ) == 'color' ) {
		color c = b.getCustomColor( propertyName );
		if ( c.r + c.g + c.b + c.a == 4 )
			return false;
	}
	return true;
}
You can see some explanation of setting up these filters here: RUBE editor v1.5 updates
or search for 'export filter' in the built-in help.
Post Reply