NanamiPlates_Scanner = {} local initializedChildren = 0 local cachedWorldChildren = {} local function CheckRegionForBorder(r) if r and r.GetObjectType and r:GetObjectType() == "Texture" and r.GetTexture then return r:GetTexture() == "Interface\\Tooltips\\Nameplate-Border" end return false end function NanamiPlates_Scanner.IsNamePlate(frame) if not frame then return nil end local objType = frame:GetObjectType() if objType ~= "Frame" and objType ~= "Button" then return nil end local r1, r2, r3, r4, r5, r6 = frame:GetRegions() if CheckRegionForBorder(r1) then return true end if CheckRegionForBorder(r2) then return true end if CheckRegionForBorder(r3) then return true end if CheckRegionForBorder(r4) then return true end if CheckRegionForBorder(r5) then return true end if CheckRegionForBorder(r6) then return true end return nil end function NanamiPlates_Scanner.ScanForNewNameplates(registry, callback) local parentcount = WorldFrame:GetNumChildren() if initializedChildren >= parentcount then return false end cachedWorldChildren = { WorldFrame:GetChildren() } local foundNew = false for i = initializedChildren + 1, parentcount do local plate = cachedWorldChildren[i] if plate and not registry[plate] then if NanamiPlates_Scanner.IsNamePlate(plate) then callback(plate) foundNew = true end end end initializedChildren = parentcount return foundNew end function NanamiPlates_Scanner.Reset() initializedChildren = 0 for k in pairs(cachedWorldChildren) do cachedWorldChildren[k] = nil end end function NanamiPlates_Scanner.GetInitializedCount() return initializedChildren end NanamiPlates.Scanner = NanamiPlates_Scanner