public MusicEvent(string name, GameEvents.E_State state, AudioClip clip, float fadeoutTime, float fadeInTime, float volume) { Name = name; State = state; Clip = clip; FadeOutTime = fadeoutTime; FadeInTime = fadeInTime; Volume = volume; }
public void EventHandler(string name, GameEvents.E_State state) { foreach (MusicEvent musicEvent in MusicEvents) { if (musicEvent.Name == name && musicEvent.State == state) { SetNewMusic(musicEvent.Clip, musicEvent.Volume, musicEvent.FadeOutTime, musicEvent.FadeInTime); return; } } }
void OnInspectorGuiEx() { GameBlackboard gb = target as GameBlackboard; const float kFrameWidth = 80; EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GUILayout.Space(5); GUILayout.BeginVertical(); // Column headers GUILayout.BeginHorizontal(); GUILayout.Label("Name", "OL Title"); GUILayout.Label("State", "OL Title", GUILayout.Width(kFrameWidth)); GUILayout.EndHorizontal(); GUIStyle gs = "OL TextField"; GameEvents events = gb.GameEvents; GUILayout.BeginVertical("OL box NoExpand"); for (int i = 0; i < events.Count; i++) { EditorGUILayout.BeginHorizontal(); GUILayout.Label(events.Names[i], gs, GUILayout.MinWidth(30)); GameEvents.E_State s = (GameEvents.E_State)EditorGUILayout.EnumPopup(events.GetState(events.Names[i]), GUILayout.Width(kFrameWidth)); if (s != events.GetState(events.Names[i])) { events.Update(events.Names[i], s); } EditorGUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); EditorGUILayout.Space(); }
public override void OnInspectorGUI() { GameBlackboard gb = target as GameBlackboard; if (Application.isPlaying) { OnInspectorGuiEx(); return; } const float kFrameWidth = 80; const float kDeleteWidth = 17; GUILayout.BeginVertical("OL box NoExpand"); GUILayout.BeginHorizontal(); GUILayout.Label("Game Events", "OL Title"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Name", "OL Title"); GUILayout.Label("State", "OL Title", GUILayout.Width(kFrameWidth)); GUILayout.Label(GUIContent.none, "OL Title", GUILayout.Width(kDeleteWidth)); GUILayout.EndHorizontal(); GUIStyle gs = "OL TextField"; GameEvents events = gb.GameEvents; Dictionary <string, GameEvents.E_State> updatedEvents = new Dictionary <string, GameEvents.E_State>(); for (int i = 0; i < events.Count; i++) { EditorGUILayout.BeginHorizontal(); string key = EditorGUILayout.TextField(events.Names[i], gs, GUILayout.MinWidth(30)); GameEvents.E_State state = (GameEvents.E_State)EditorGUILayout.EnumPopup(events.GetState(events.Names[i]), GUILayout.Width(kFrameWidth)); if (GUILayout.Button(GUIContent.none, "OL Minus", GUILayout.Width(kDeleteWidth)) == false) { try { updatedEvents.Add(key, state); } catch { updatedEvents.Add(events.Names[i], events.GetState(events.Names[i])); } } EditorGUILayout.EndHorizontal(); } GUILayout.Space(5); GUILayout.BeginHorizontal(); if (GUILayout.Button(GUIContent.none, "OL Plus", GUILayout.Width(kDeleteWidth))) { updatedEvents.Add("_NewEvent" + events.Count, GameEvents.E_State.False); } if (GUI.changed || events.Count != updatedEvents.Count) { //gb.ClearAllGameEvents(); events.Clear(); foreach (KeyValuePair <string, GameEvents.E_State> pair in updatedEvents) { events.Add(pair.Key, pair.Value); } EditorUtility.SetDirty(gb); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }