All the script stoped the update func when i lock the computer
Hi guys; our company has an project which is about going to finish。But recently we found a problem. the unity version we used is 4.3.4.we found that when we lock the windows for a while and unlock it , the game begain at the time we locked the computer.And in the building setting inspector,we made the RunInBackground toggle checked. we write an test script as blew, when we locked the windows ,the count stopped counting.that means the update func has stopped working.we test this code at unity 4.1.2 it works well. but 4.3.4-4.6.4 does not work.we also tested it in unity 5.1.2 and it works..but if the whole project upgrade to UNITY5 ,the work we should do is huge. so,is anyone has the same problem? and how can i fix it with no big change(or upgrade)?
using UnityEngine;
using System.Collections;
public class Test1 : MonoBehaviour {
int[] t = new int[10];
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Debug.LogError("Update");
t[0]++;
}
void LateUpdate()
{
Debug.LogError("LateUpdate");
t[1]++;
}
void OnDisable()
{
Debug.LogError("OnDisable");
}
void OnEnable()
{
Debug.LogError("OnEnable");
}
void FixedUpdate()
{
Debug.LogError("FixedUpdate");
}
void OnApplicationPause(bool pause)
{
Debug.LogError("OnApplicationPause (" + pause + ")");
}
void OnGUI()
{
Debug.LogError("OnGUI");
t[2]++;
GUILayout.Label(t[0]+", " + t[1] + ", " + t[2] + ": \t(" + Time.realtimeSinceStartup + ") \t(" + Time.time + ")");
GUILayout.Label("Mouse Position: " + Input.mousePosition);
GUILayout.Label("Screnn Size: " + Screen.width + " * " + Screen.height);
}
}
Answer by RudyTheDev · Sep 22, 2015 at 10:55 AM
"Run in background" in Windows means running while the game window is not the foreground/focused window. It doesn't mean running while Windows is sleeping or has been locked or the OS is otherwise pausing or preventing applications from executing. Windows native lock suspends applications and there is nothing (simple) you can do to prevent that. All applications get suspended, not just Unity.
Your answer
Follow this Question
Related Questions
BCE0005 Unknown identifier: 'FirstPersonController' Help please 1 Answer
New at Unity, Issues following Sams Teach Yourself 0 Answers
Scripts worked but since 3 days its not working, please help. 0 Answers
How to attach a basic first person camera to a capsule? 1 Answer
My jump scripit wont work. i have been tryingtt o make it work for an eternity. please help. 1 Answer