示例#1
0
    GameObject PlayEffect(AudioClip src, string gameObjectName)
    {
        // Debug.Log("Sfx check0");
        if (src == null)
        {
            return(null);
        }
        // Debug.Log("Sfx check1");
        GameObject         gO  = new GameObject(gameObjectName);
        AudioSource        sfx = gO.AddComponent(typeof(AudioSource)) as AudioSource;
        DelayedSelfDestroy dsd = gO.AddComponent(typeof(DelayedSelfDestroy)) as DelayedSelfDestroy;

        dsd.delayedSeconds = src.length;
        sfx.volume         = effectVolume;
        sfx.clip           = src;
        sfx.Play();
        return(gO);
    }
示例#2
0
 void Start()
 {
     dsd = this.gameObject.GetComponent <DelayedSelfDestroy>();
     dsd.SetStarted(false);
 }