• vgui "Material" glitched ?
    4 replies, posted
Hi, I use a vgui"material" but when I open the menu with the Material, it looks glitched because it is actualising every time. If someone can help me.
Post your code
Here is the code : [CODE]local carre_blanc = vgui.Create( "Material", fenetre_principal ) carre_blanc:SetPos( 5, 30 ) -- Set the position of the label carre_blanc:SetSize(440,460) carre_blanc:SetMaterial("models/props_combine/Combine_Citadel001") carre_blanc.AutoSize = false[/CODE] Oh, and by the way, the Material become more Bright or Dark, is there anything to fix it always Bright ?
Pretty sure you're supposed to use [CODE] carre_blanc.Material = IMaterial -- NOT 'carre_blanc:SetMaterial("path string")' [/CODE] And by IMaterial I mean this - [url]http://wiki.garrysmod.com/page/Category:IMaterial[/url] Don't think it accepts strings/paths You can use the Material function to create the IMaterial though - [url]http://wiki.garrysmod.com/page/Global/Material[/url]
The texture you are using is a VertexLitGeneric, not an UnlitGeneric. Do this: [code]local Mat = self:GetMaterial() local strImage = Mat:GetName() if ( string.find( Mat:GetShader(), "VertexLitGeneric" ) || string.find( Mat:GetShader(), "Cable" ) ) then local t = Mat:GetString( "$basetexture" ) if ( t ) then local params = {} params[ "$basetexture" ] = t params[ "$vertexcolor" ] = 1 params[ "$vertexalpha" ] = 1 Mat = CreateMaterial( strImage .. "_DImage", "UnlitGeneric", params ) end end self:SetMaterial( Mat )[/code] Alternately, use DImage instead of Material for the control and just call SetImage( path ) instead of SetMaterial( path ).
Sorry, you need to Log In to post a reply to this thread.