View Single Post
11-07-22, 07:08 PM   #3
Elanthis
A Murloc Raider
Join Date: Nov 2022
Posts: 6
Thank you for your reply.

Originally Posted by SDPhantom View Post
Appears texture:SetTexCoord() doesn't work on StatusBars as they keep overwriting it on render.
I can confirm this (maybe I should have had my simple test bar actually track something when I first tested with it). Even when putting SetTexCoord() inside the same function that updates the status bar value, it barely works (only when the value's stopped changing for a few seconds).

Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("PLAYER_LOGIN")
  3. f:SetScript("OnEvent", function(self, event, ...)
  4.     local tex = f:CreateTexture()
  5.     tex:SetAtlas("UI-HUD-UnitFrame-Player-PortraitOff-Bar-Health-Status")
  6.     tex:SetTexCoord(0.1, 0.9, 0, 1)
  7.     ElanthisStatusBar = CreateFrame("StatusBar")
  8.     ElanthisStatusBar:SetPoint("CENTER", UIParent, "CENTER", 0, -30)
  9.     ElanthisStatusBar:SetSize(126, 12)
  10.     ElanthisStatusBar:SetStatusBarTexture(tex)
  11.  
  12.     ElanthisStatusBar:RegisterEvent("UNIT_POWER_FREQUENT")
  13.     ElanthisStatusBar:SetScript("OnEvent", function(self, event, ...)
  14.         local unitID = ...
  15.         if not UnitIsPlayer(unitID) then return end
  16.         local maxPower = UnitPowerMax(unitID)
  17.         local currentPower = UnitPower(unitID)
  18.         self:SetMinMaxValues(0, maxPower)
  19.         self:SetValue(currentPower)
  20.         -- tex:SetTexCoord(0.1, 0.9, 0, 1)
  21.     end)
  22. end)

Originally Posted by SDPhantom View Post
Generally, texture:SetTexCoord() doesn't work on atlas' either, but using C_Texture.GetAtlasInfo() to set by texture file and trimming the supplied texcoord isn't yielding useful results either as it normally would.
I tried that earlier (sorry, I should have said so) and yea, it seems to be specific to the SetTexCoord() method as a whole.


Do you by chance know if it's possible to define new atlas members from Blizzards atlas' (so I can crop the bar textures "right at the source")?

Else it is probably easier to make up my own texture file with the desired bar texture.
  Reply With Quote