Set shader constant for label (SOLVED)

There is no label.set_constant function, so how would I set a shader constant on a label component?

Ah, dang! There was a post recently about the setting a shader constant on a gui and the lack of a gui.set_constant(). It seems like label is another component without a set_constant() function. @Mathias_Westerdahl, we need a new ticket for label.set_constant() right?

1 Like

I didn’t add a label.set_constant function, since the “new” way of setting properties is via go.set(). It was modeled after the functionality of the sprite component:

function init(self)
	go.set("#sprite", "tint", vmath.vector4(1,0,0,1))
	go.set("#label", "tint", vmath.vector4(1,0,0,1))
end

(And, after adding an actual label material with a tint in it):
03

2 Likes

Oh, ok, that’s good to know! go.set() for a gui component doesn’t work though.

Exactly, so we created a ticket for the gui. However, that task might be big since the gui doesn’t have properties right now

2 Likes

Is there already a way to get metrics from labels too?

1 Like

Sadly, no. I seem to have missed that (I could have sworn I added it :/). Added DEF-3087 for that.

2 Likes

Metrics for labels!!! Yes!!! I so needed that! :heart_eyes: We have some ugly workarounds in place for keeping GUI and game object positions in sync in a place where we needed metrics.

3 Likes

Released in Defold 1.2.120

2 Likes