public void SetSpeaker(int index) { if (index >= Participants.Length) { Debug.LogError("Trying to make participant #" + index + " the speaker but there are only " + (Participants.Length - 1) + " participants"); return; } DialogParticipant newParticipant = Participants[index]; if (newParticipant == null) { Debug.LogError("Speaker of " + index + "is null"); return; } ShutUpCurrentSpeaker(); CurrentSpeaker = newParticipant; CurrentSpeaker.SetTalking(true); if (DialogSoundSource != null) { DialogSoundSource.transform.parent = CurrentSpeaker.GetHeadTransform(); DialogSoundSource.transform.localPosition = Vector3.zero; } }
public void ShutUpCurrentSpeaker() { if (CurrentSpeaker != null) { CurrentSpeaker.SetTalking(false); } if (DialogSoundSource != null) { DialogSoundSource.transform.parent = null; } CurrentSpeaker = null; }