Quantcast Model Frame does not show again after hiding - WoWInterface
Thread Tools Display Modes
08-02-18, 11:30 AM   #1
selfaddicted
A Defias Bandit
Join Date: Aug 2018
Posts: 2
Model Frame does not show again after hiding

As the title says, I could make a playermodel frame which shows a spell animation like Weakauras does when logged in. But after I hide it, I can't show it again until reloadui

Code:
local function CreateAniFrame(parent, path, size, pos, zxy)

  local model = CreateFrame("Playermodel", nil, parent)
  model:SetSize(unpack(size))
  model:SetPoint("CENTER", parent, "CENTER", pos[1], pos[2])
  model:SetModel(path)
  model:SetPosition(unpack(zxy))

end
FYI, it's not a unit portrait or something, it's about spell effect animation. Could anyone give me some clues or some references to fix the issue?
  Reply With Quote
08-02-18, 12:41 PM   #2
d87
A Flamescale Wyrmkin
 
d87's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 125
that's an old bug, you have to set model again after hiding

Code:
local Redraw = function(self)
    if not self.model_path then return end

    self:SetModelScale(1)
    self:SetPosition(0,0,0)

    if type(self.model_path) == "number" then
        self:SetDisplayInfo(self.model_path)
    else
        self:SetModel(self.model_path)
    end
    self:SetModelScale(self.model_scale)
    self:SetPosition(self.ox, self.oy, self.oz)
end

local ResetTransformations = function(self)
    self:SetModelScale(1)
    self:SetPosition(0,0,0)
end

local pmf = CreateFrame("PlayerModel", nil, UIParent )
    pmf.model_scale = 1
    pmf.ox = 0
    pmf.oy = 0
    pmf.oz = 0
    pmf.model_path = "..."

    pmf:SetScript("OnHide", ResetTransformations)
    pmf:SetScript("OnShow", Redraw)
    pmf.Redraw = Redraw
    pmf.ResetTransformations = ResetTransformations
    pmf:Redraw()
  Reply With Quote
08-02-18, 01:40 PM   #3
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 417
Think this is easier in terms of resetting the model.
Lua Code:
  1. model:ClearModel()
Anyway, I've had this issue too in Immersion, and noticed that if you're setting model properties while the frame is hidden, they won't take if transitioning from :SetUnit and :SetDisplayInfo to :SetModel. To ensure your solution works, clear the model and set up the properties again after the model frame is visible, using an OnShow script.
__________________
  Reply With Quote
08-02-18, 07:59 PM   #4
selfaddicted
A Defias Bandit
Join Date: Aug 2018
Posts: 2
Thank you all you guys!!!! I should have asked on this forum earlier. lol
Thanks!!!!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Model Frame does not show again after hiding

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off