Search Unity

How to solve High CPU usage in background?

Discussion in 'BlackBerry' started by ARY-PRODUCTION, Sep 2, 2014.

  1. ARY-PRODUCTION

    ARY-PRODUCTION

    Joined:
    Aug 15, 2014
    Posts:
    5
    I have developed only GUI application in Unity4.5.2f1 ,
    but I noticed high cpu usage when my app in background.

    Specifically,if in my code...

    Code (CSharp):
    1.     void Update(){
    2.         if(!paused){
    3.             //brabrabra...
    4.         }
    5.     }
    6.     void OnGUI(){
    7.         if(!paused){
    8.             //brabrabra
    9.         }
    10.     }
    11.     void OnApplicationPause(bool pauseStatus){
    12.         if(pauseStatus){
    13.             paused=true;
    14.             Time.timeScale=0;
    15.         }else{
    16.             paused=false;
    17.             Time.timeScale=1;
    18.         }
    19.     }
    20.  
    I could check that OnApplicationPause is worked,
    but CPU usage is around 45% !!!
    This app drained my battery.

    Ofcause I checked out "Run in background",
    if check in this,CPU usage up to over 60%.

    Any suggestions?
     
  2. ARY-PRODUCTION

    ARY-PRODUCTION

    Joined:
    Aug 15, 2014
    Posts:
    5
    It solved by myself ,thanks.
     
  3. leewang2502

    leewang2502

    Joined:
    Jan 19, 2015
    Posts:
    8
    Dear ary Production, how to solve this?