don't create new color array every frame

This commit is contained in:
in0finite 2019-08-30 03:13:31 +02:00
parent a384877191
commit 0eedc21fb2
2 changed files with 6 additions and 2 deletions

View file

@ -13,6 +13,7 @@ namespace SanAndreasUnity.Utilities {
private static float fpsRed = 23.0f;*/
private float fpsDeltaTime = 0.0f;
private Texture2D fpsTexture = null;
private Color[] colors = null;
private float[] fpsHistory = new float[fpsTextureWidth];
private int fpsIndex = 0;
@ -24,6 +25,8 @@ namespace SanAndreasUnity.Utilities {
fpsTexture = new Texture2D(fpsTextureWidth, fpsTextureHeight, TextureFormat.RGBA32, false, true);
colors = new Color[fpsTexture.width * fpsTexture.height];
}
void Update () {
@ -54,8 +57,7 @@ namespace SanAndreasUnity.Utilities {
if (fpsTexture == null) return;
// Show FPS history
Color[] colors = new Color[fpsTexture.width * fpsTexture.height];
for (int i = 0; i < (fpsTexture.width * fpsTexture.height); i++)
colors[i] = new Color(0.0f, 0.0f, 0.0f, 0.66f); // Half-transparent background for FPS graph

View file

@ -27,6 +27,8 @@
- Check what is causing huge FPS drops - it wasn't present before ; possibly it is GC ;
- When doing apply on a texture, don't keep texture data in memory (or specify what to do with parameter)
- Play sounds: horn ; empty weapon clip ; ped damage ; footsteps in run and sprint states ;
- Optimize Console.Update() - don't do trim excess for every log message