DModelPanel not showing up

Hey, I have this DModelPanel:


local BestProp = vgui.Create( "DModelPanel", BusinessSecondPanel )
    BestProp:SetPos( 160, 140 )
    BestProp:SetSize( 340, 340 )
    BestProp:SetModel( "models/props_c17/FurnitureSink001a.mdl" )

It’s parented to an editablepanel, and it’s not working. I cut/pasted the code into another addon I have that uses just frames, and it still didn’t show up. What’s going on here? :frowning:

Thanks folks

Mind pasting the full code, aka the parent(s)?


BusinessSecondPanel = vgui.Create( "DPanel", BusinessBFrame )
    BusinessSecondPanel:SetSize( 776, 526 )
    BusinessSecondPanel:SetPos( ScrW() / 2 - 388, ScrH() / 2 - 240 )
    BusinessSecondPanel:MakePopup()
    function BusinessSecondPanel:Paint( w,h )
        draw.RoundedBox( 8,0,0,w,h, Color( 0, 100, 255, 225 ) )
        draw.RoundedBox( 0,0,75,w,5, Color( 255, 255, 255, 255 ) )
        if LocalPlayer():GetNWBool( "POwnsBusiness" ) then
            draw.DrawText( LocalPlayer():GetNWString( "PBusinessName" ), "NewTrebuchetBig", self:GetWide() / 2, 10, Color( 255, 255, 255, 255 ), 1)
            if LocalPlayer():GetNWString( "PBusinessType" ) == "retail" then
                draw.DrawText( "a retail company.", "NewTrebuchet", self:GetWide() / 2, 50, Color( 200, 200, 200, 255 ), 1 )
            elseif LocalPlayer():GetNWString( "PBusinessType" ) == "service" then
                draw.DrawText( "a service company.", "NewTrebuchet", self:GetWide() / 2, 50, Color( 200, 200, 200, 255), 1 )
            end
        end
    end

You must set the “MakePopup” function as last of all panels, like, first you create the DPanel, then you put in the DModelPanel, and then you do “DPanel:MakePopup”, try that.

Also, I would recommend using a DFrame to test, instead of DPanel.

I’m already too far into this to switch to a DFrame :v:

What do you mean - just only put in the MakePopup under the dmodelpanel?

Try this to debug it:
[lua]
function BestProp:Paint(w,h)
draw.RoundedBox(4,0,0,w,h,Color(255,255,0,255))
end
[/lua]

The big scary yellow box shows up.

Then the issue is with your ViewPos/LookAt.

This snippet will center your view. Run it after you set the model:
[lua]
local mins, maxs = BestProp.Entity:GetRenderBounds()
BestProp:SetLookAt((maxs+mins) / 2)
BestProp:SetCamPos(mins:Distance(maxs) * Vector(0, 1, .5))
[/lua]

EDIT:
And remove that previous debug code.

I added that and it’s still not showing.

Not sure then. Try another model, or look at how other addons are doing it.

Another model didn’t work.