Changing alpha of DirectButton['geom']

I’m not able change the alpha value or any value infact of an .egg file after it has been set as a geom of DirectButton.

btn = DirectButton()
test = 'test.egg'
btn['geom'] = test
test.setAlphaScale(0.5) # no effect after geom is set.

I can change the values fine before it’s set as the buttons geom

What happens if you enable transparency using btn.setTransparency(TransparencyAttrib.M_alpha) ?

Also, in your code snippet, you are setting test.setAlphaScale on a string, which has no such method. I assume the code you used in your application looks different?

Same thing, geom doesn’t udpate. The code in my application is

test = loader.loadModel('test.egg')

edit: running

print(btn['geom'])

prints test.egg to confirm that I am running setAlphaScale on the egg

That’s because it makes a copy of the NodePath you pass in. You could however try passing in geom_color=(1, 1, 1, 0.5). Otherwise you will have to either set it on the frame itself or access the underlying OnscreenGeom component and set it there.

geom_color gives me the result I was looking for. Thank you :slight_smile: