(Questions are at the bottom)
This is in response/reference to another question I had that was closed:
I ended up writing a little library thing that enables me to draw boxes and rounded boxes (and soon text and polygons) on textures and then update them every time I call a certain function. For example (in this picture), the white boxes grow larger upwards as time goes on. By this I mean…

I’ve optimized this fairly well so that it only has to Apply the pixels once every time I call the update function (It makes a base texture and then stores all drawing instructions for other shapes in an array so that when I need to update it, it redraws all the new things with new values and then applys it).
Unfortunately, this still doesn’t seem to be enough. Here’s the problem
- Update rate:0.01sec | FPS: ~60
- Update rate:0.1sec | FPS: ~80
- Update rate:0.5sec | FPS: ~90
- Update rate:1sec | FPS: ~95
To make it look smooth, it needs a smaller update rate. 0.1 seconds is what I usually go with but it isn’t ideal (0.01 is sooo smooth). The FPS loss only grows when I have more than one panel. Even if I make the rate something say 1 second, the fps is high but there is visual lag when making multiple panels.
My questions:
How can I optimize this any more? As I said in my other question that got closed, I was able to do something like this in Garrys Mod with Lua and it ran much faster and was much more complex. I even remember duplicating it multiple times and my fps drop was minimal.
Should I just throw this away and switch to using vertices with a custom shader? How would I go about drawing text? Rounded boxes? It just seems like a hacky way to do what I want especially as these panels grow in complexity. I’m not even sure this would have the functionality I need either…
Are your textures as low-resolution as they appear in the image (about 32x32 pixels)? If so, there should be no problem at all. If not, then I suggest either making them so, or as an extension of the answers to the previously-closed question, don't use pixel manipulation, instead model that as a grey rectangle with a stretched yellow or white rectangle on top of it. In my experience, pixel-manipulation is rarely a useful way to do anything (excluding shader-based RenderTexture manipulation, which is awesomely powerful).
– Wazin very general terms are you famliar with 2DToolkit ? it is very widely used for 2D, and does everything in 1 drawcall
– FattieHaha, ohh, I didn't think about the texture resolution, It's at 128x128. That's probably a problem. Ill try messing with that a bit. The padding between the side walls of the bars is 3 pixels on all sides. Ill try and make the resolution smaller. Sad though because That's pretty limiting. And as for the 2D toolkit, this is a 3D game and Im just drawing displays to the player in 2D (3D panel with 2D graphics on it). I assume that everything I'm drawing does it in one draw call as well. Thanks for the info though but I'll stick to writing this one myself.
– cobertos@Fattie, drop the LOUD, even though yes, pixel twiddling is almost never useful. It's always best here to answer both the question the asker thinks they are asking ("how do I twiddle pixels faster?"), and the question they should be asking ("how do I draw boxes faster?"). The latter is what they need (to use stretched boxes, not pixel twiddling), while the latter may help someone else who stumbles across this answer but whose application is not amenable to simply stretching boxes. Unity Answers is a knowledge base as well as a source of one-off answers.
– Wazwaz, for a year I tried to GIVE MORE INFO in questions, but lately I am trying to really FOCUS ON THE CORE PROBLEM .. .it's a difficulty issue it's not a big deal, just a bit confusing you led with discussion about the texture size, whereas that is irrelevant here - it's just that Cob. is using SetPixels probably irrelevantly
– Fattie