View Single Post
10-17-11, 02:51 PM   #17
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I revised my code and found the final bug.

Reseting the camdistancescale vales etc is needed before reseting the model otherwise it will not reload properly if you change from a gnome to a dwarf etc.

I originally thought that clearing the model would wipe the model attributes but that is not the case. The attributes have to be set before the model rendering.

lua Code:
  1. local Update = function(self, event, unit)
  2.     if(not unit or not UnitIsUnit(self.unit, unit)) then return end
  3.  
  4.     local portrait = self.Portrait
  5.     if(portrait.PreUpdate) then portrait:PreUpdate(unit) end
  6.  
  7.     if(portrait:IsObjectType'Model') then
  8.         local guid = UnitGUID(unit)
  9.         if(not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit)) then
  10.             portrait:SetCamDistanceScale(0.25)
  11.             portrait:SetPortraitZoom(0)
  12.             portrait:SetPosition(0,0,0.5)
  13.             portrait:ClearModel()
  14.             portrait:SetModel('interface\\buttons\\talktomequestionmark.m2')
  15.             portrait.guid = nil
  16.         elseif(portrait.guid ~= guid or event == 'UNIT_MODEL_CHANGED') then
  17.             portrait:SetCamDistanceScale(1)
  18.             portrait:SetPortraitZoom(1)
  19.             portrait:SetPosition(0,0,0)
  20.             portrait:ClearModel()
  21.             portrait:SetUnit(unit)
  22.             portrait.guid = guid
  23.         end
  24.     else
  25.         SetPortraitTexture(portrait, unit)
  26.     end
  27.  
  28.     if(portrait.PostUpdate) then
  29.         return portrait:PostUpdate(unit)
  30.     end
  31. end
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-18-11 at 01:12 AM.
  Reply With Quote