DButton.SetImage() Avatar image?

Hey!

Can i somehow use DButton and use SetImage for setting it to avatar image? Or should i make own vgui element?

[editline]22nd May 2015[/editline]

If you recommend vgui, can you show me example how i would create button in custom vgui?

Take a look at the example here.



local Avatar = vgui.Create( "AvatarImage" ) //You might want to parent it to something
Avatar:SetSize( 64, 64 )
Avatar:SetPos( 4, 4 )
Avatar:SetPlayer( LocalPlayer(), 64 ) //The 64 here is the size of it


The player that is shown on the avatar can be anyone, just change LocalPlayer() to some valid player data. Also, the avatar is meant to look better with sizes 16, 32, 64, 84, 128 and 184, but you can make it any size.

Like the example above shows use the “AvatarImage” element.

If you’d like to be able to click on the avatar image and have it act as a button then create a DButton with the same dimensions as the avatar image, position it in the same place as the avatar image and then override the button’s paint function to make it transparent. Should act like what you want