Skip to content

Instantly share code, notes, and snippets.

@tatmos
Created August 7, 2013 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatmos/6179078 to your computer and use it in GitHub Desktop.
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をチェックしておきます。
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