void Start() { if (SoundMaterial == null || SoundMaterial.AudioSets.Count == 0) { return; } if (AutoCreateSources) { if (!ImpactAudio.isActiveAndEnabled) { ImpactAudio = getAudioCopy(ImpactAudio, gameObject); } baseImpactVol = ImpactAudio.volume; baseImpactPitch = ImpactAudio.pitch; audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>(); AudioContainers = new List <PhysSoundAudioContainer>(); foreach (PhysSoundAudioSet audSet in SoundMaterial.AudioSets) { PhysSoundAudioContainer audCont = new PhysSoundAudioContainer(audSet.Key); audCont.SlideAudio = getAudioCopy(ImpactAudio, this.gameObject); audCont.Initialize(SoundMaterial.GetAudioSet(audCont.KeyIndex).Slide); audioContainersDic.Add(audCont.KeyIndex, audCont); AudioContainers.Add(audCont); } ImpactAudio.loop = false; } else { if (ImpactAudio) { ImpactAudio.loop = false; baseImpactVol = ImpactAudio.volume; baseImpactPitch = ImpactAudio.pitch; } if (AudioContainers.Count > 0) { audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>(); foreach (PhysSoundAudioContainer audCont in AudioContainers) { if (!SoundMaterial.HasAudioSet(audCont.KeyIndex)) { Debug.LogError("PhysSound Object " + gameObject.name + " has an audio container for an invalid Material Type! Select this object in the hierarchy to update its audio container list."); continue; } audCont.Initialize(SoundMaterial.GetAudioSet(audCont.KeyIndex).Slide); audioContainersDic.Add(audCont.KeyIndex, audCont); } } } }
void Start() { if (SoundMaterial == null || SoundMaterial.AudioSets.Count == 0) return; if (AutoCreateSources) { if (!ImpactAudio.isActiveAndEnabled) { ImpactAudio = getAudioCopy(ImpactAudio, gameObject); } baseImpactVol = ImpactAudio.volume; baseImpactPitch = ImpactAudio.pitch; audioContainersDic = new Dictionary<int, PhysSoundAudioContainer>(); AudioContainers = new List<PhysSoundAudioContainer>(); foreach (PhysSoundAudioSet audSet in SoundMaterial.AudioSets) { PhysSoundAudioContainer audCont = new PhysSoundAudioContainer(audSet.Key); audCont.SlideAudio = getAudioCopy(ImpactAudio, this.gameObject); audCont.Initialize(SoundMaterial.GetAudioSet(audCont.KeyIndex).Slide); audioContainersDic.Add(audCont.KeyIndex, audCont); AudioContainers.Add(audCont); } ImpactAudio.loop = false; } else { if (ImpactAudio) { ImpactAudio.loop = false; baseImpactVol = ImpactAudio.volume; baseImpactPitch = ImpactAudio.pitch; } if (AudioContainers.Count > 0) { audioContainersDic = new Dictionary<int, PhysSoundAudioContainer>(); foreach (PhysSoundAudioContainer audCont in AudioContainers) { if (!SoundMaterial.HasAudioSet(audCont.KeyIndex)) { Debug.LogError("PhysSound Object " + gameObject.name + " has an audio container for an invalid Material Type! Select this object in the hierarchy to update its audio container list."); continue; } audCont.Initialize(SoundMaterial.GetAudioSet(audCont.KeyIndex).Slide); audioContainersDic.Add(audCont.KeyIndex, audCont); } } } }
/// <summary> /// Initializes the PhysSoundObject. Use this if you adding a PhysSoundObject component to an object at runtime. /// </summary> public override void Initialize() { _r = GetComponent <Rigidbody>(); _r2D = GetComponent <Rigidbody2D>(); if (AutoCreateSources) { baseImpactVol = ImpactAudio.volume; baseImpactPitch = ImpactAudio.pitch; _audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>(); AudioContainers = new List <PhysSoundAudioContainer>(); foreach (PhysSoundAudioSet audSet in SoundMaterial.AudioSets) { if (audSet.Slide == null) { continue; } PhysSoundAudioContainer audCont = new PhysSoundAudioContainer(audSet.Key); audCont.SlideAudio = PhysSoundTempAudioPool.GetAudioSourceCopy(ImpactAudio, this.gameObject); audCont.Initialize(this); _audioContainersDic.Add(audCont.KeyIndex, audCont); AudioContainers.Add(audCont); } ImpactAudio.loop = false; } else { if (ImpactAudio) { ImpactAudio.loop = false; baseImpactVol = ImpactAudio.volume; baseImpactPitch = ImpactAudio.pitch; } if (AudioContainers.Count > 0) { _audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>(); foreach (PhysSoundAudioContainer audCont in AudioContainers) { if (!SoundMaterial.HasAudioSet(audCont.KeyIndex)) { Debug.LogError("PhysSound Object " + gameObject.name + " has an audio container for an invalid Material Type! Select this object in the hierarchy to update its audio container list."); continue; } if (PlayClipAtPoint) { audCont.Initialize(this, ImpactAudio); } else { audCont.Initialize(this); } _audioContainersDic.Add(audCont.KeyIndex, audCont); } } } if (PlayClipAtPoint) { PhysSoundTempAudioPool.Create(); } else if (ImpactAudio != null && !ImpactAudio.isActiveAndEnabled) { ImpactAudio = PhysSoundTempAudioPool.GetAudioSourceCopy(ImpactAudio, gameObject); } }
// Token: 0x06003FD5 RID: 16341 RVA: 0x0014098C File Offset: 0x0013ED8C private void Start() { if (this.SoundMaterial == null) { return; } this.r = base.GetComponent <Rigidbody>(); this.r2D = base.GetComponent <Rigidbody2D>(); if (this.AutoCreateSources) { if (!this.ImpactAudio.isActiveAndEnabled && !this.PlayClipAtPoint) { this.ImpactAudio = PhysSoundTempAudioPool.GetAudioSourceCopy(this.ImpactAudio, base.gameObject); } this.baseImpactVol = this.ImpactAudio.volume; this.baseImpactPitch = this.ImpactAudio.pitch; this.audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>(); this.AudioContainers = new List <PhysSoundAudioContainer>(); foreach (PhysSoundAudioSet physSoundAudioSet in this.SoundMaterial.AudioSets) { if (!(physSoundAudioSet.Slide == null)) { PhysSoundAudioContainer physSoundAudioContainer = new PhysSoundAudioContainer(physSoundAudioSet.Key); physSoundAudioContainer.SlideAudio = PhysSoundTempAudioPool.GetAudioSourceCopy(this.ImpactAudio, base.gameObject); physSoundAudioContainer.Initialize(this.SoundMaterial); this.audioContainersDic.Add(physSoundAudioContainer.KeyIndex, physSoundAudioContainer); this.AudioContainers.Add(physSoundAudioContainer); } } this.ImpactAudio.loop = false; } else { if (this.ImpactAudio) { this.ImpactAudio.loop = false; this.baseImpactVol = this.ImpactAudio.volume; this.baseImpactPitch = this.ImpactAudio.pitch; } if (this.AudioContainers.Count > 0) { this.audioContainersDic = new Dictionary <int, PhysSoundAudioContainer>(); foreach (PhysSoundAudioContainer physSoundAudioContainer2 in this.AudioContainers) { if (!this.SoundMaterial.HasAudioSet(physSoundAudioContainer2.KeyIndex)) { Debug.LogError("PhysSound Object " + base.gameObject.name + " has an audio container for an invalid Material Type! Select this object in the hierarchy to update its audio container list."); } else { physSoundAudioContainer2.Initialize(this.SoundMaterial); this.audioContainersDic.Add(physSoundAudioContainer2.KeyIndex, physSoundAudioContainer2); } } } } if (this.PlayClipAtPoint) { PhysSoundTempAudioPool.Create(); } }
public override void OnInspectorGUI() { obj = target as PhysSoundObject; mat = serializedObject.FindProperty("SoundMaterial"); impactAudio = serializedObject.FindProperty("ImpactAudio"); autoCreate = serializedObject.FindProperty("AutoCreateSources"); serializedObject.Update(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("PhysSound Material:", EditorStyles.boldLabel); EditorGUILayout.PropertyField(mat, true); if (obj.SoundMaterial == null) { EditorGUILayout.HelpBox("No PhysSound Material is assigned!", MessageType.Warning); serializedObject.ApplyModifiedProperties(); return; } if (obj.SoundMaterial.AudioSets.Count > 0) { //EditorGUILayout.Separator(); GUILayout.Box("", GUILayout.MaxWidth(Screen.width - 25f), GUILayout.Height(dividerHeight)); EditorGUILayout.LabelField("Audio Sources:", EditorStyles.boldLabel); EditorGUILayout.PropertyField(autoCreate); if (obj.AutoCreateSources) { EditorGUILayout.PropertyField(impactAudio, new GUIContent("Template Audio"), true); } else { EditorGUILayout.PropertyField(impactAudio, true); EditorGUILayout.Separator(); //Update the audio container list with new objects foreach (PhysSoundAudioSet audSet in obj.SoundMaterial.AudioSets) { if (!obj.HasAudioContainer(audSet.Key)) { obj.AddAudioContainer(audSet.Key); } } //Remove any audio containers that don't match with the material. for (int i = 0; i < obj.AudioContainers.Count; i++) { PhysSoundAudioContainer audCont = obj.AudioContainers[i]; if (!obj.SoundMaterial.HasAudioSet(audCont.KeyIndex)) { obj.RemoveAudioContainer(audCont.KeyIndex); i--; } audCont.SlideAudio = EditorGUILayout.ObjectField(PhysSoundTypeList.GetKey(audCont.KeyIndex) + " Slide Audio", audCont.SlideAudio, typeof(AudioSource), true) as AudioSource; } } } EditorGUILayout.Separator(); EditorUtility.SetDirty(obj); serializedObject.ApplyModifiedProperties(); }