WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Model Frame does not show again after hiding (https://www.wowinterface.com/forums/showthread.php?t=56485)

selfaddicted 08-02-18 11:30 AM

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?

d87 08-02-18 12:41 PM

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()


MunkDev 08-02-18 01:40 PM

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.

selfaddicted 08-02-18 07:59 PM

Thank you all you guys!!!! I should have asked on this forum earlier. lol
Thanks!!!!


All times are GMT -6. The time now is 04:56 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI