Unity3D Tutorial : Application Class Part1 - runInBackground

Unity3D 2012. 6. 13. 14:09
반응형


http://file:///Applications/Unity/Documentation/ScriptReference/Application-runInBackground.html


기본 false (어플리케이션이 백그라운드로 갔을떄 모든 실행을 멈춘다) 포커스가 

static var runInBackground : boolean

Description

Should the player be running when the application is in the background?

Default is false (application pauses when it is in background).

http://www.youtube.com/watch?v=BB6srB4tDTk&feature=BFa&list=PL5072DB212534A13D

백그라운드에서도 어플리케이션이 돌아가야 할 경우 true값으로 준다.(기본false)

using UnityEngine;

using System.Collections;


public class ApplicationClassDemo : MonoBehaviour {

private int counter;

private float delay;

private bool tick;

public void Awake() {

print("Awake");

Application.runInBackground = true;

}

// Use this for initialization

public void Start () {

print("Start");

counter = 0;

delay = 1.0f;

tick = false;

}


// Update is called once per frame

public void Update () {

print("Update");

if(!tick)

StartCoroutine("Pause");

}

public void OnGUI() {

print("Update");

GUI.Label(new Rect(10, 10, 100, 20), counter.ToString());

}

private IEnumerator Pause() {

print("Pause");

tick = true;

yield return new WaitForSeconds(delay);

counter++;

tick = false;

}

}




반응형
: