Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075919 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:11:25 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Unity in built measures/variables for game performance/speed?
Pages: [1]
Print
Author Topic: Unity in built measures/variables for game performance/speed?  (Read 564 times)
Mittens
Level 10
*****


.


View Profile WWW Email
« on: May 21, 2012, 01:02:11 AM »

Hey forum,
I've just added many interchangable graphics levels to littleDragon and now I'm wanting to rig them up to change based on the games performance.

So I'm wondering if unity has in built measures/variables for game performance/speed?

something like Application.ProcessorLoad or Application.FPS perhaps ?

thanks,
-Jackson
Logged

bateleur
Level 10
*****



View Profile
« Reply #1 on: May 21, 2012, 09:02:54 AM »

I'm not aware of such a feature, but if you monitor the (changing) value of Time.deltaTime in the Update() method of anything in your game that should tell you what you need to know. I'd recommend averaging over a large number of cycles to avoid basing your performance setting on an atypical spike.
Logged

Hima
Level 4
****


OM NOM NOM


View Profile WWW Email
« Reply #2 on: May 21, 2012, 08:32:29 PM »

There is a Application.framerate, but it is for capping the game's framerate so I don't think you can use that.

I remember there are scripts that can measure the time spent on some parts of the code, as well as an FPS calculation script. You can probably use information you get from these scripts to adjust your game based on performance. They should be in Unity forum, in Scripts section.

If I were you I would put this as an option for player to adjust by themselves though.
Logged

Mittens
Level 10
*****


.


View Profile WWW Email
« Reply #3 on: May 22, 2012, 05:20:55 AM »

yeah, I think I may have to eventually add in an override graphics choice in the game options, ugh, work work.

I ended up just using the average deltaTime for the game to process 100 frames, the system seems to work pretty well but I need to give it more stages of degrading graphics (at the moment it only has high, medium, low)
Logged

pushxtonotdie
Level 0
*


View Profile Email
« Reply #4 on: May 23, 2012, 10:37:24 AM »

Here is a C# version of an FPS counter that I've been using for the past couple days and it works pretty well. Its based off code here:

http://answers.unity3d.com/questions/64331/accurate-frames-per-second-count.html

This code uses the NGUI UILabel class so most likely you'll have to pull that out if you're using the built-in gui. I think you'd be better off buying NGUI tho.  Smiley

Code:
using UnityEngine;

public class FPSGUI : MonoBehaviour
{
UILabel label;
double frameCount = 0;
float nextUpdate = 0.0f;
float fps = 0.0f;
float updateRate = 4.0f;  // 4 updates per sec.

void Start ()
{
label = GetComponent<UILabel>();
InvokeRepeating("updateFPS", 1.0f, 1.0f);
}

void updateFPS()
{
label.text = "FPS:"+fps;
}


void Update()
{
    frameCount++;
    if (Time.time > nextUpdate)
    {
        nextUpdate = Time.time + (1.0f/updateRate);
        fps = (float)frameCount * updateRate;
        frameCount = 0;
    }
}
}
Logged
EdgeOfProphecy
Level 2
**



View Profile WWW Email
« Reply #5 on: May 24, 2012, 01:19:36 PM »

Hey forum,
I've just added many interchangable graphics levels to littleDragon and now I'm wanting to rig them up to change based on the games performance.

So I'm wondering if unity has in built measures/variables for game performance/speed?

something like Application.ProcessorLoad or Application.FPS perhaps ?

thanks,
-Jackson

Just concentrate on overall FPS, it will be your best indicator of system-wide performance.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic