Method that counts the frames of a C#Augmented Reality scene

Asked

Viewed 95 times

2

I am doing a work of Augmented Reality using Unity and Vuforia and I need to capture how many frames the scene I develop is using, I do not master much of C#, but by my research apparently Unity has no getFrame() method as Artoolkit makes available, someone could help me?

  • 1

    When you say you need to capture how many frames a scene is using, do you want to know the total number of frames accumulated in the complete execution of the scene, or how many frames are produced per second? Well, in both cases the path is the same, in the function Update(), it is called every new frame created, and only change the implementation according to what you want. example fps = 1.0/Time.deltaTime; https://youtu.be/0rD4OuPxsuk?t=10m19s

  • 1

    @Nils, create an answer with that content. :)

1 answer

2


One way to find these values in Unity is to use the method Update() , it is inside the tool and is called each time a frame is created. To know the total number of frames that were generated, we can create a variable and add 1 to each method call.

int frame; //total de frames criados

Update(){
  frame++;
}

And to know the fps we can take the inverse of the time variation between each call

float deltaTime = 0.0f;
float fps = 0.0f;

void Update()
{
    deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
    fps = 1.0f / deltaTime;
}

You can use these variable values and work as you like.

About the Update function https://youtu.be/0rD4OuPxsuk?t=10m19s

Some FPS implementations in Unity: http://wiki.unity3d.com/index.php?title=FramesPerSecond

Browser other questions tagged

You are not signed in. Login or sign up in order to post.