protected void CreateEventInstance(FmodEvent srcEvent, Vector3 worldPos, RaycastHit hitInfo) { FmodEventAudioSource audioSource = null; if (Event.current.alt) // if alt is on, we add the audio source as a component { GameObject dest = hitInfo.collider.gameObject; audioSource = dest.GetComponent <FmodEventAudioSource>(); if (audioSource == null || audioSource.eventClip != null) { audioSource = dest.AddComponent(typeof(FmodEventAudioSource)) as FmodEventAudioSource; } } else // else we create a GameObject to act as source { GameObject obj = GameObject.Instantiate(Resources.Load("FmodEventAudioSource"), worldPos, Quaternion.identity) as GameObject; audioSource = obj.GetComponent <FmodEventAudioSource>(); if (audioSource == null) { Debug.LogError("Prefab for FmodEventAudioSource should have component FmodEventAudioSource !"); } else { obj.name = "FmodEventSource (" + srcEvent.name + ")"; } } audioSource.SetSourceEvent(srcEvent); }
public void end(bool win = true) { Debug.Log("End"); if (win) { source.Stop(); source.SetSourceEvent(mEtap6[7]); source.Play(); } else { mEnd = true; mObjects[9].activeActionMutex(); mObjects[10].activeActionMutex(); source.Stop(); source.SetSourceEvent(mEtap6[3]); source.Play(); } mState = eState._FINISH_; }