Page 1 of 1

Unset custom color property

Posted: Tue Feb 02, 2016 9:50 am
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.

Re: Unset custom color property

Posted: Tue Feb 02, 2016 4:00 pm
by iforce2d
This might help:
viewtopic.php?f=7&t=457

Re: Unset custom color property

Posted: Tue Feb 02, 2016 4:01 pm
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.

Re: Unset custom color property

Posted: Tue Feb 02, 2016 4:22 pm
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.

Re: Unset custom color property

Posted: Thu Feb 04, 2016 3:10 am
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.