/// <summary> Main GUI Function </summary> public override void OnInspectorGUI() { serializedObject.Update(); m_editorUtils.Initialize(); // Do not remove this! m_editorUtils.GUIHeader(); m_editorUtils.TitleNonLocalized(m_editorUtils.GetContent("SequenceDataHeader").text + serializedObject.targetObject.name); EditorGUI.BeginDisabledGroup(!Application.isPlaying); if (!Application.isPlaying || !AmbienceManager.WasSequenceAdded(target as Sequence)) { if (m_editorUtils.Button("EditorPlayButton")) { Sequence seq = target as Sequence; seq.m_forcePlay = true; AmbienceManager.AddSequence(seq); } } else { if (m_editorUtils.Button("EditorStopButton")) { Sequence seq = target as Sequence; seq.m_forcePlay = false; AmbienceManager.RemoveSequence(seq); } } EditorGUI.EndDisabledGroup(); m_editorUtils.Panel("RequirementsPanel", RequirementsPanel, true); m_editorUtils.Panel("ClipsPanel", ClipsPanel, true); m_editorUtils.Panel("OutputPanel", OutputPanel, true); m_editorUtils.Panel("RandomizationPanel", RandomizationPanel, true); m_editorUtils.Panel("ModifiersPanel", ModifiersPanel, true); m_editorUtils.Panel("EventsPanel", EventsPanel, true); m_editorUtils.Panel("SyncPanel", SyncPanel, true); //m_editorUtils.GUIFooter(); serializedObject.ApplyModifiedProperties(); }
void PlayMenuItem() { m_forcePlay = true; AmbienceManager.AddSequence(this); }
public void PlayHeartBeat() { AmbienceManager.AddSequence(Heartbeat); AmbienceManager.ActivateEvent("Heartbeat"); }
void UpdatePlayerPostProcessing() { if (tm == null) { tm = FindObjectOfType <TerrainManager>(); } if (tm == null) { return; } Biome biome = tm.GetBiome(transform.position); List <TerrainManager.BiomeStrength> biomes = tm.GetBiomes(transform.position); PostProcessVolume ppv; float remainder = 0.0f; for (int i = 0; i < biomes.Count; i++) { if (!ppVolumes.ContainsKey(biomes[i].biome)) { if (biomes[i].biome.postProcessing != null) { ppv = postProcessVolume.gameObject. AddComponent <PostProcessVolume>(); ppv.isGlobal = postProcessVolume.isGlobal; ppv.priority = postProcessVolume.priority; ppv.weight = biomes[i].strength; ppv.profile = biomes[i].biome.postProcessing; } else { ppv = null; } ppVolumes.Add(biomes[i].biome, ppv); } } List <KeyValuePair <Biome, PostProcessVolume> > ppvs = ppVolumes.ToList(); for (int i = 0; i < ppvs.Count; i++) { ppvs[i].Value.weight = 0.0f; for (int j = 0; j < biomes.Count; j++) { if (ppvs[i].Key == biomes[j].biome) { if (ppvs[i].Value != null) { ppvs[i].Value.weight = biomes[j].strength; } else { remainder += biomes[j].strength; } } } } postProcessVolume.weight = remainder; if (previousBiome != biome) { if (previousBiome != null) { for (int i = 0; i < previousBiome.globalSounds.Length; i++) { AmbienceManager.RemoveSequence(previousBiome.globalSounds[i]); } } if (biome != null) { for (int i = 0; i < biome.globalSounds.Length; i++) { Debug.Log(" BSequence Name: " + biome.globalSounds[i].name); AmbienceManager.AddSequence(biome.globalSounds[i]); } } /* * int idx = ambienceManager.m_globalSequences.Length; * Array.Resize(ref ambienceManager.m_globalSequences, idx + biome.globalSounds.Length); * foreach (var sequence in biome.globalSounds) * { * //ambienceManager.m_globalSequences[idx++] = sequence; * } */ previousBiome = biome; } }
/// <summary> Displays a list of all Sequence assets in project </summary> /// <param name="inlineHelp">Should help be displayed?</param> void SequencesPanel(bool inlineHelp) { GUIStyle playButtonNormal; GUIStyle playButtonPressed; playButtonNormal = EditorStyles.miniButtonLeft; playButtonPressed = new GUIStyle(playButtonNormal); playButtonPressed.normal = playButtonNormal.active; GUIStyle muteButtonNormal; GUIStyle muteButtonPressed; muteButtonNormal = EditorStyles.miniButtonRight; muteButtonPressed = new GUIStyle(muteButtonNormal); muteButtonPressed.normal = muteButtonNormal.active; foreach (Sequence data in AllSequences) { EditorGUILayout.BeginHorizontal(); Rect r = EditorGUILayout.GetControlRect(); if (r.yMax > m_scrollPosition.y) { if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition)) { lastClickedOn = data; } else if (Event.current.type == EventType.MouseDrag && lastClickedOn == data && r.Contains(Event.current.mousePosition)) { DragAndDrop.PrepareStartDrag(); DragAndDrop.objectReferences = new Object[] { data }; DragAndDrop.StartDrag("Sequence:" + data.name); Event.current.Use(); weStartedDrag = true; } else if (Event.current.type == EventType.DragUpdated && r.Contains(Event.current.mousePosition)) { bool found = false; for (int o = 0; o < DragAndDrop.objectReferences.Length; ++o) { if (DragAndDrop.objectReferences[o] is AudioClip) { DragAndDrop.visualMode = DragAndDropVisualMode.Link; Event.current.Use(); found = true; break; } } if (!found) { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; Event.current.Use(); } } else if (Event.current.type == EventType.DragPerform && r.Contains(Event.current.mousePosition)) { List <Sequence.ClipData> clips = new List <Sequence.ClipData>(data.m_clipData); bool foundOne = false; for (int o = 0; o < DragAndDrop.objectReferences.Length; ++o) { if (DragAndDrop.objectReferences[o] is AudioClip) { foundOne = true; clips.Add(DragAndDrop.objectReferences[o] as AudioClip); } } if (foundOne) { data.m_clipData = clips.ToArray(); } } else if ((Event.current.type == EventType.DragExited || Event.current.type == EventType.MouseUp) && lastClickedOn == data && weStartedDrag) { weStartedDrag = false; lastClickedOn = null; DragAndDrop.PrepareStartDrag(); } } EditorGUI.ObjectField(r, data, typeof(Sequence), false); EditorGUI.BeginDisabledGroup(!Application.isPlaying); if (!Application.isPlaying || !AmbienceManager.WasSequenceAdded(data)) { if (m_editorUtils.Button(EditorGUIUtility.IconContent("PlayButton"), playButtonNormal, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.ExpandWidth(false))) { data.m_forcePlay = true; AmbienceManager.AddSequence(data); } } else { if (m_editorUtils.Button(EditorGUIUtility.IconContent("PlayButton On"), playButtonPressed, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.ExpandWidth(false))) { data.m_forcePlay = false; AmbienceManager.RemoveSequence(data); } } Color startColor = GUI.color; GUIStyle buttonStyle = muteButtonNormal; if (data.m_forceMuted) { GUI.color = Color.red; buttonStyle = muteButtonPressed; } if (m_editorUtils.Button(EditorGUIUtility.IconContent("preAudioAutoPlayOff"), buttonStyle, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.ExpandWidth(false))) { if (Event.current.button == 1) { data.m_forceMuted = false; bool curMuted = true; foreach (Sequence s in AllSequences) { if (s != null && s != data) { curMuted &= s.m_forceMuted; } } foreach (Sequence s in AllSequences) { if (s != null && s != data) { s.m_forceMuted = !curMuted; } } } else { data.m_forceMuted = !data.m_forceMuted; } } GUI.color = startColor; EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); } ++EditorGUI.indentLevel; EditorGUILayout.BeginHorizontal(); if (m_editorUtils.Button("SequenceCreateButton", GUILayout.ExpandWidth(false))) { GUIContent dialogContent = m_editorUtils.GetContent("SequenceCreateDialog"); string newPath = EditorUtility.SaveFilePanelInProject(dialogContent.text, "Sequence", "asset", dialogContent.tooltip, newSequencePath); if (!string.IsNullOrEmpty(newPath)) { AssetDatabase.CreateAsset(CreateInstance <Sequence>(), newPath); Sequence newSequence = AssetDatabase.LoadAssetAtPath <Sequence>(newPath); Selection.activeInstanceID = newSequence.GetInstanceID(); } } Rect buttonRect = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.DragUpdated && buttonRect.Contains(Event.current.mousePosition)) { for (int o = 0; o < DragAndDrop.objectReferences.Length; ++o) { if (DragAndDrop.objectReferences[o] is AudioClip) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; Event.current.Use(); break; } } } else if (Event.current.type == EventType.DragPerform && buttonRect.Contains(Event.current.mousePosition)) { List <Sequence.ClipData> clips = new List <Sequence.ClipData>(); for (int o = 0; o < DragAndDrop.objectReferences.Length; ++o) { if (DragAndDrop.objectReferences[o] is AudioClip) { clips.Add(DragAndDrop.objectReferences[o] as AudioClip); } } if (clips.Count > 0) { if (Event.current.control) //create one for each { GUIContent dialogContent = m_editorUtils.GetContent("SequenceMultiCreateDialog"); string saveFolder = EditorUtility.SaveFolderPanel(dialogContent.text, "Assets", "Assets"); if (!string.IsNullOrEmpty(saveFolder)) { if (saveFolder.StartsWith(Application.dataPath)) { saveFolder = saveFolder.Substring(Application.dataPath.Length - 6); if (!saveFolder.EndsWith("/")) { saveFolder += "/"; } foreach (Sequence.ClipData clip in clips) { Sequence newSequence = CreateInstance <Sequence>(); newSequence.m_clipData = new Sequence.ClipData[] { clip }; AssetDatabase.CreateAsset(newSequence, saveFolder + clip.m_clip.name + ".asset"); } } else { GUIContent errorContent = m_editorUtils.GetContent("CreateWrongFolderError"); EditorUtility.DisplayDialog(errorContent.text, errorContent.tooltip, "Ok"); } } } else //stack all into one sequence { GUIContent dialogContent = m_editorUtils.GetContent("SequenceCreateDialog"); string savePath = EditorUtility.SaveFilePanelInProject(dialogContent.text, "Sequence", "asset", dialogContent.tooltip); if (!string.IsNullOrEmpty(savePath)) { Sequence newSequence = CreateInstance <Sequence>(); newSequence.m_clipData = clips.ToArray(); AssetDatabase.CreateAsset(newSequence, savePath); } } } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); m_editorUtils.InlineHelp("SequenceCreateButton", inlineHelp); --EditorGUI.indentLevel; }