Created
August 7, 2013 22:00
-
-
Save tatmos/6179196 to your computer and use it in GitHub Desktop.
Unity x ADX2LE 【効能】アプリケーションのフォーカスが外れたり復帰時に、自動的にサウンドのポーズやポーズ解除します。
【使いどころ】バックグラウンドで音が進行してしまうと都合が悪い時に使う。
【使い方】AtomSourceのついたオブジェクトに貼付ける。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class BackgroundStop : MonoBehaviour { | |
CriAtomSource atomSource; | |
// Use this for initialization | |
void Start () { | |
atomSource = gameObject.GetComponent<CriAtomSource>(); | |
} | |
// Update is called once per frame | |
void Update () { | |
} | |
void OnApplicationPause(bool pause) | |
{ | |
if(atomSource != null){ | |
atomSource.Pause(pause); | |
} | |
} | |
void OnApplicationFocus(bool focusFlag) | |
{ | |
if(atomSource != null){ | |
atomSource.Pause(!focusFlag); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment