I have a small addon that modifies the unit nameplates. I can't however figure out how to make the castbar fixed size. It somehow changes size on some occasions, mostly when a castbar becomes visible mid-cast or when a cast changes to a channel. Could someone help with this please? The code can be found on github.

Disclaimer: This is all just my observations/theory. I have no other evidence to back it up.

It seems there is some form of throttling/cut off point when recursion would occur in the "OnSizeChanged" script e.g. calling SetHeight() from within it. This prevents the bar height from being updated until a later point (in this particular case it seems your next "OnShow"). By placing a GetHeight() call in the script handler you seem to be able to force the update to occur immediately. This will of course allow the recursion to occur, but you have a statement in there to break it.

@zork: Unfortunately just hooking OnShow won't work for this implentation. Your nameplates and therefore castbars are hidden and shown every frame so the OnShow handler is run on every frame the cast bar is active. (I found that out the annoying way when I implemented my own like that)

As for a nicer solution than what I posted before, why not just set the two TOPLEFT and TOPRIGHT anchors and instead of setting the height of the bar set a BOTTOM anchor with the correct offset?

@zork
That's why I'm curious why my code does not work. I also thought that OnShow should be sufficient but found out it isn't, that's why I hooked OnSizeChanged too. But somehow it still changes sizes and stays like that either with a visible lag (and changes then to the set height) or until the next cast or all the time for that given nameplate. So it somehow seems that my code behaves differently for the different nameplates and I just don't find any explanation for that.

However your approach is different than mine. I don't understand why you create "double" nameplates and re-parent stuff to them. You have a lot of overhead to it as you re-anchor all your double plates every second. What is the benefit of that?

@Oppugno
Doesn't make much sense but I'll try it

@Reslike
The reason for the size change is that the castbar gets re-anchored every OnShow (at least that's the earliest point where I can catch it) relative to the castbar border (that's castbarOverlay in my code). There is a single point set - "BOTTOMRIGHT", castbarOverlay, "BOTTOMRIGHT", xOffset, yOffset (don't know the values of the offsets off the top of my head). castbarOverlay itself is anchored to the center of the nameplate and don't seem to be movable (tried that and all SetPoint calls appear to get ignored). I need ClearAllPoints() before re-anchoring. Don't know why this should cause a problem, but well the nameplates code is C-side and hidden. I actually had tried to just replace the "BOTTOMRIGHT" anchor for the sake of optimization (thus sparing the ClearAllPoints() call) but this didn't prevent the strange resizing either.

@Oppugno
Hmm. I need to check back on that aswell. But I think if you are having the hookscript handlers on oldPlate and oldPlate.castbar and only show/hide the newPlate each frame that will not trigger the onshow scripts of oldPlate and oldPlate.castbar. Thus it should be ok. But I'm not sure. Gonna test it.

Basically you move all your visible nameplate elements to a new nameplate object and you hide that nameplate object each frame before applying a setpoint. So basically the object points change while being hidden. The fps gain is incredible.

Currently the best practice for doing nameplates is doing sth like this:
[...]
Basically you move all your visible nameplate elements to a new nameplate object and you hide that nameplate object each frame before applying a setpoint. So basically the object points change while being hidden. The fps gain is incredible.

Elv UI integrated that concept into the new nameplates aswell.

I read the thread but it didn't make much sense to me as I hadn't noticed any lag. I'll do a molten core run and try to verify your results.