- Home /
Why does this SUPER simple line of code take 35% or my processing power?
For my Job I am trying to create a Heartbeat program that monitors the status of interactives. In order to do this safely, I don't want clients closing out of the program, so I want to hide the window.
This is the single line of code that causes 35% of my processing power to be used when I run it. There is nothing in the scene and no other scripts.:
void OnApplicationFocus(bool hasFocus)
{
User32.ShowWindow(User32.GetActiveWindow(), 0);
}
Once you build your application, this code should immediately hide it. Now if you open Task Manager, you can see that when the application is hidden, it takes a lot of processing power. Anyone know why?
Answer by Bilelmnasser · Sep 29, 2017 at 08:36 AM
hi, unity3d doesn't recognize of being hided by windows so you need to manually hide your gameObjects to not call the draw function of unity .
But I have no objects in the scene. When the window is visible, the processing power consumed is about .5%, when it's hidden it turns into 35%.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to use low-level Windows API keyboard hook to capture Print Screen key 0 Answers
Can you access Win8 Sensor objects through c# 1 Answer
dll error when build 4 Answers