Created
August 7, 2013 21:47
-
-
Save tatmos/6179078 to your computer and use it in GitHub Desktop.
Unity x ADX2LE 【効能】再生が終わったら自動消滅するスクリプト。
【使いどころ】シーン変更中に音を途切れないように鳴らして、シーン変化時の間を演出したり、 AtomSource付きゲームオブジェクトをPrefab化して単純にInstatiateして音を鳴らして消えるといった作りができます。
【使い方】AtomSourceに貼付けるだけ。
【使い方2】実行時にPrefabをドロップして簡単再生。
【補足】シーンをまたぐ場合はCriWareLibraryInitializerとCRIWAREはDont Destroy On Loadをチェックしておきます。
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 System.Collections; | |
public class IfPlayEndDestroy : MonoBehaviour { | |
CriAtomSource atomSource = null; | |
// Use this for initialization | |
void Start () { | |
// error | |
if(GameObject.Find("CRIWARE") == null){ | |
Debug.LogWarning("CRIWARE is Null!"); | |
return; | |
} | |
atomSource = gameObject.GetComponent<CriAtomSource>(); | |
GameObject.DontDestroyOnLoad(this.gameObject); | |
} | |
// Update is called once per frame | |
void Update () { | |
if(atomSource.status == CriAtomSource.Status.PlayEnd){ | |
GameObject.Destroy(this.gameObject); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment