public override void OnChildInspectorGUI() { //Save trigger mask to know when it chages triggerList = m_AkAmbient.triggerList; base.OnChildInspectorGUI(); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); serializedObject.Update(); GUILayout.BeginVertical("Box"); MultiPositionTypeLabel type = m_AkAmbient.multiPositionTypeLabel; EditorGUILayout.PropertyField(multiPositionType, new GUIContent("Position Type: ")); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing); currentAttSphereOp = (AttenuationSphereOptions)EditorGUILayout.EnumPopup("Show Attenuation Sphere: ", currentAttSphereOp); GUILayout.EndVertical(); //Save multi-position type to know if it has changed MultiPositionTypeLabel multiPosType = m_AkAmbient.multiPositionTypeLabel; serializedObject.ApplyModifiedProperties(); if (m_AkAmbient.multiPositionTypeLabel == MultiPositionTypeLabel.MultiPosition_Mode) { //Here we make sure all AkAmbients that are in multi-position mode and that have the same event also have the same trigger UpdateTriggers(multiPosType); } if (GUI.changed) { if (type != m_AkAmbient.multiPositionTypeLabel) { if (m_AkAmbient.multiPositionTypeLabel != MultiPositionTypeLabel.Large_Mode) { m_AkAmbient.multiPositionArray.Clear(); // TODO: I need a good method to update the array in edit mode //m_AkAmbient.BuildMultiDirectionArray(); } } } }
private void UpdateTriggers(MultiPositionTypeLabel in_multiPosType) { //if we just switched to MultiPosition_Mode if (in_multiPosType != m_AkAmbient.multiPositionTypeLabel) { //Get all AkAmbients in the scene var akAmbients = FindObjectsOfType <AkAmbient>(); //Find the first AkAmbient that is in multiPosition_Mode and that has the same event as the current AkAmbient for (var i = 0; i < akAmbients.Length; i++) { if (akAmbients[i] != m_AkAmbient && akAmbients[i].multiPositionTypeLabel == MultiPositionTypeLabel.MultiPosition_Mode && akAmbients[i].eventID == m_AkAmbient.eventID) { //if the current AkAmbient doesn't have the same trigger as the others, we ask the user which one he wants to keep if (!HasSameTriggers(akAmbients[i].triggerList)) { if (UnityEditor.EditorUtility.DisplayDialog("AkAmbient Trigger Mismatch", "All ambients in multi-position mode with the same event must have the same triggers.\n" + "Which triggers would you like to keep?", "Current AkAmbient Triggers", "Other AkAmbients Triggers")) { SetMultiPosTrigger(akAmbients); } else { m_AkAmbient.triggerList = akAmbients[i].triggerList; } } break; } } } //if the trigger changed or there was an undo/redo operation, we update the triggers of all the AkAmbients in the same group as the current one else if (!HasSameTriggers(triggerList) || UnityEngine.Event.current.type == UnityEngine.EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed") { var akAmbients = FindObjectsOfType <AkAmbient>(); SetMultiPosTrigger(akAmbients); } }
void UpdateTriggers(MultiPositionTypeLabel in_multiPosType) { //if we just switched to MultiPosition_Mode if(in_multiPosType != m_AkAmbient.multiPositionTypeLabel) { //Get all AkAmbients in the scene AkAmbient[] akAmbients = FindObjectsOfType(typeof(AkAmbient)) as AkAmbient[]; //Find the first AkAmbient that is in multiPosition_Mode and that has the same event as the current AkAmbient for(int i = 0; i < akAmbients.Length; i++) { if(akAmbients[i] != m_AkAmbient && akAmbients[i].multiPositionTypeLabel == MultiPositionTypeLabel.MultiPosition_Mode && akAmbients[i].eventID == m_AkAmbient.eventID) { //if the current AkAmbient doesn't have the same trigger as the others, we ask the user which one he wants to keep if (!HasSameTriggers(akAmbients[i].triggerList)) { if ( EditorUtility.DisplayDialog ( "AkAmbient Trigger Mismatch", "All ambients in multi-position mode with the same event must have the same triggers.\n" + "Which triggers would you like to keep?", "Current AkAmbient Triggers", "Other AkAmbients Triggers" ) ) { SetMultiPosTrigger(akAmbients); } else { m_AkAmbient.triggerList = akAmbients[i].triggerList; } } break; } } } //if the trigger changed or there was an undo/redo operation, we update the triggers of all the AkAmbients in the same group as the current one else if (!HasSameTriggers(triggerList) || (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")) { AkAmbient[] akAmbients = FindObjectsOfType(typeof(AkAmbient)) as AkAmbient[]; SetMultiPosTrigger(akAmbients); } }