1. #1

    Blizzard UI Target/Focus transperent name bar

    Greetings!

    Can anyone, please, help with small issue that I have. I am trying to make the background behind Target/Focus/Arena/Boss frame Names transperent or solid black, same as the default Player frame.

    Before posting here I did some research on Google and found some related scripts on AJ, PG and some other websites, but none of those solutions worked for me, they are literaly doing noting.

    Here are some of those scripts that I have already tryed:

    Code:
    local frame = CreateFrame("FRAME")
    frame:RegisterEvent("GROUP_ROSTER_UPDATE")
    frame:RegisterEvent("PLAYER_TARGET_CHANGED")
    frame:RegisterEvent("PLAYER_FOCUS_CHANGED")
    frame:RegisterEvent("UNIT_FACTION")
    frame:RegisterEvent("PLAYER_ENTERING_WORLD")
    
    frame:SetScript("OnEvent", eventHandler)
    
    for _, BarTextures in pairs({
    TargetFrameNameBackground,
    FocusFrameNameBackground,
    Boss1TargetFrameNameBackground,
    Boss2TargetFrameNameBackground,
    Boss3TargetFrameNameBackground,
    Boss4TargetFrameNameBackground,
    ArenaEnemyFrame1,
    ArenaEnemyFrame2,
    ArenaEnemyFrame3,
    ArenaEnemyFrame4,
    ArenaEnemyFrame5,
    }) do
    	BarTextures:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Background")
    end
    
    for _, region in pairs({
    TargetFrameNameBackground,
    FocusFrameNameBackground,
    Boss1TargetFrameNameBackground,
    Boss2TargetFrameNameBackground,
    Boss3TargetFrameNameBackground,
    Boss4TargetFrameNameBackground,
    ArenaEnemyFrame1,
    ArenaEnemyFrame2,
    ArenaEnemyFrame3,
    ArenaEnemyFrame4,
    ArenaEnemyFrame5,
    }) do
    	region:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Background")
    end
    Code:
    local frame = CreateFrame("FRAME")
    frame:RegisterEvent("GROUP_ROSTER_UPDATE")
    frame:RegisterEvent("PLAYER_TARGET_CHANGED")
    frame:RegisterEvent("PLAYER_FOCUS_CHANGED")
    frame:RegisterEvent("UNIT_FACTION")
    
    local function eventHandler(self, event, ...)
     if UnitIsPlayer("target") then
     TargetFrameNameBackground:SetVertexColor(0.0, 0.0, 0.0, 0.5)
     end
     if UnitIsPlayer("focus") then
     FocusFrameNameBackground:SetVertexColor(0.0, 0.0, 0.0, 0.5)
     end
    end
    
    frame:SetScript("OnEvent", eventHandler)
    
    for _, BarTextures in pairs({TargetFrameNameBackground, FocusFrameNameBackground}) do
     BarTextures:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Background")
    end
    Code:
    hooksecurefunc('TargetFrame_CheckFaction', function(self)
     if ( not UnitPlayerControlled(self.unit) 
     and UnitIsTapped(self.unit) 
     and not UnitIsTappedByPlayer(self.unit) 
     and not UnitIsTappedByAllThreatList(self.unit) ) then
     self.nameBackground:SetVertexColor(0.0, 0.0, 0.0, 0.5);
     if ( self.portrait ) then
     self.portrait:SetVertexColor(0.5, 0.5, 0.5);
     end
     else
     self.nameBackground:SetVertexColor(0.0, 0.0, 0.0, 0.5);
     if ( self.portrait ) then
     self.portrait:SetVertexColor(1.0, 1.0, 1.0);
     end
     end 
    end)
    Code:
    UnitSelectionColor = function(unit)
    if not UnitExists(unit) then return 1,1,1,1 end
    
    local color = UnitIsPlayer(unit) and RAID_CLASS_COLORS[select(2, 
    UnitClass(unit))] or FACTION_BAR_COLORS[UnitReaction(unit, 'player')]
    if color then
    if not UnitIsConnected(unit) then
    return .5, .5, .5, 1
    else
    return 0, 0, 0, 0.5
    end
    else
    if UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) then
    return .5, .5, .5, 1
    end
    end
    end
    I did try those scripts on fresh installation of World of Warcraft client without any other AddOns or user scripts.

  2. #2
    This is what I do to make a solid black background for a frame.

    Code:
    frame:SetFrameStrata("BACKGROUND")
    frame:SetBackdrop({
    	bgFile = "Interface/Tooltips/UI-Tooltip-Background",
    })
    frame:SetBackdropColor(0, 0, 0, 1)

    If you want to add a border to the frame, simply do the following:
    Code:
    frame:SetFrameStrata("BACKGROUND")
    frame:SetBackdrop({
    	bgFile = "Interface/Tooltips/UI-Tooltip-Background",
    	edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
    	edgeSize = 16,
    	insets = { left = 4, right = 4, top = 4, bottom = 4 }
    })
    frame:SetBackdropColor(0, 0, 0, 1)
    EDIT: Additional info

    The key difference is that I'm setting the backdrop, and then it's color. You are creating a texture and applying the colour to that, which isn't wrong, it'll just work differently.

    Also, looking through the code very quickly, make sure that you call SetPoint and SetSize for any frame you create, or it will not be visible. Example:
    Code:
    -- Make a 100 x 100 frame appear at the center of the screen
    frame:SetSize(100,100)
    frame:SetPoint("CENTER", CENTER,"TOP",0,0)
    Last edited by Nathima; 2015-08-05 at 10:50 PM. Reason: Additional info

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •