public static InAudioNodeBaseData AddDataClass(InAudioNode node) { switch (node._type) { case AudioNodeType.Root: node._nodeData = node.gameObject.AddComponentUndo<InFolderData>(); break; case AudioNodeType.Audio: node._nodeData = node.gameObject.AddComponentUndo<InAudioData>(); break; case AudioNodeType.Random: var randomData = node.gameObject.AddComponentUndo<RandomData>(); node._nodeData = randomData; for (int i = 0; i < node._children.Count; ++i) randomData.weights.Add(50); break; case AudioNodeType.Sequence: node._nodeData = node.gameObject.AddComponentUndo<InSequenceData>(); break; case AudioNodeType.Multi: node._nodeData = node.gameObject.AddComponentUndo<MultiData>(); break; case AudioNodeType.Track: node._nodeData = node.gameObject.AddComponentUndo<InTrackData>(); break; case AudioNodeType.Folder: var folderData = node.gameObject.AddComponentUndo<InFolderData>(); //folderData.BankLink = node.GetBank(); node._nodeData = folderData; break; } return node._nodeData; }
public InPlayer PlayConnectedTo(GameObject controllingObject, InAudioNode audioNode, GameObject attachedTo, AudioParameters audioParameters, float fade = 0f, LeanTweenType fadeType = LeanTweenType.notUsed) { if (audioNode.IsRootOrFolder) { Debug.LogWarning("InAudio: Cannot play \""+audioNode.GetName+"\" as it is a folder"); return null; } List<InstanceInfo> currentInstances = audioNode.CurrentInstances; if (!AllowedStealing(audioNode, currentInstances)) { return null; } var runtimePlayer = InAudioInstanceFinder.RuntimePlayerControllerPool.GetObject(); if (runtimePlayer == null) { Debug.LogWarning("InAudio: A pooled objected was not initialized. Try to restart play mode. If the problem persists, please submit a bug report."); } currentInstances.Add(new InstanceInfo(AudioSettings.dspTime, runtimePlayer)); runtimePlayer.transform.parent = attachedTo.transform; runtimePlayer.transform.localPosition = new Vector3(); Play(controllingObject, audioNode, runtimePlayer, fade, fadeType, audioParameters); return runtimePlayer; }
public void StopAll(InAudioNode node, float fadeOutTime, LeanTweenType type) { if (node.IsRootOrFolder) { Debug.LogWarning("InAudio: Cannot stop audio on \"" + node.GetName + "\" as it is a folder"); } foreach (var audioNode in GOAudioNodes) { var infoList = audioNode.Value; if (infoList != null) { int count = infoList.InfoList.Count; for (int i = 0; i < count; i++) { if (infoList.InfoList[i].Node == node) { infoList.InfoList[i].Player.Stop(); } } } } }
public static void Draw(InAudioNode node) { node.ScrollPosition = GUILayout.BeginScrollView(node.ScrollPosition); InUndoHelper.GUIUndo(node, "Name Change", ref node.Name, () => EditorGUILayout.TextField("Name", node.Name)); NodeTypeDataDrawer.Draw(node); GUILayout.EndScrollView(); }
private static BankTuple CreateTuple(InAudioNode node, AudioClip clip) { BankTuple tuple = new BankTuple(); tuple.Node = node; tuple.Clip = clip; return(tuple); }
/// <summary> /// Play an audio node directly /// </summary> /// <param name="gameObject">The game object to attach to and be controlled by</param> /// <param name="audioNode">The node to play</param> /// <param name="parameters">Parameters to set initial values directly</param> /// <returns>A controller for the playing node</returns> public static InPlayer Play(GameObject gameObject, InAudioNode audioNode, AudioParameters parameters = null) { if (instance != null && gameObject != null && audioNode != null) return instance._inAudioEventWorker.PlayConnectedTo(gameObject, audioNode, gameObject, parameters); else InDebug.MissingArguments("Play", gameObject, audioNode); return null; }
public static InAudioNode FindParentBeforeFolder(InAudioNode node) { if (node.Parent.Type == AudioNodeType.Folder || node.Parent.Type == AudioNodeType.Root) { return(node); } return(FindParentBeforeFolder(node.Parent)); }
/// <summary> /// Play an audio node directly, at this position in world space /// </summary> /// <param name="gameObject">The game object to attach to and be controlled by</param> /// <param name="audioNode">The node to play</param> /// <param name="position">The world position to play at</param> /// <returns>A controller for the playing node</returns> public static InPlayer PlayAtPosition(GameObject gameObject, InAudioNode audioNode, Vector3 position) { if (instance != null && gameObject != null && audioNode != null) { return(instance._inAudioEventWorker.PlayAtPosition(gameObject, audioNode, position)); } return(null); }
/// <summary> /// Play an audio node directly, attached to another game object /// </summary> /// <param name="gameObject">The game object to attach to and be controlled by</param> /// <param name="audioNode">The node to play</param> /// <param name="attachedTo">The object to be attached to</param> /// <returns>A controller for the playing node</returns> public static InPlayer PlayAttachedTo(GameObject gameObject, InAudioNode audioNode, GameObject attachedTo) { if (instance != null && gameObject != null && audioNode != null) { return(instance._inAudioEventWorker.PlayAttachedTo(gameObject, audioNode, attachedTo)); } return(null); }
public static void AssignToNodes(InAudioNode node, Action <InAudioNode> assignFunc) { assignFunc(node); for (int i = 0; i < node.Children.Count; ++i) { AssignToNodes(node.Children[i], assignFunc); } }
public static Object[] NodeUndo(InAudioNode node) { return(new Object[] { node, node._nodeData }); }
public static void DrawBus(InAudioNode node) { if (!node.IsRoot) { bool overrideParent = EditorGUILayout.Toggle("Override Parent Bus", node.OverrideParentBus); if (overrideParent != node.OverrideParentBus) { UndoHelper.RecordObjectFull(new Object[] { node.NodeData, node }, "Override parent bus"); node.OverrideParentBus = overrideParent; } if (!node.OverrideParentBus) { GUI.enabled = false; } } EditorGUILayout.BeginHorizontal(); // if (node.GetBus() != null) { var usedBus = node.GetBus(); if (usedBus != null) { EditorGUILayout.TextField("Used Bus", usedBus.Name); } else { EditorGUILayout.TextField("Used Bus", "Missing bus"); } } else { GUILayout.Label("Missing node"); } if (GUILayout.Button("Find")) { SearchHelper.SearchFor(node.Bus); } GUI.enabled = true; GUILayout.Button("Drag bus here to assign"); var buttonArea = GUILayoutUtility.GetLastRect(); var bus = HandleBusDrag(buttonArea); if (bus != null) { UndoHelper.RecordObjectFull(node, "Assign bus"); node.Bus = bus; node.OverrideParentBus = true; Event.current.Use(); } EditorGUILayout.EndHorizontal(); }
public void Find(InAudioNode toFind) { if (InAudioInstanceFinder.Instance != null) audioCreatorGUI.Find(toFind); else { Debug.LogError("InAudio: Cannot open window without having the manager in the scene"); } }
public static void Draw(InAudioNode node) { node.ScrollPosition = GUILayout.BeginScrollView(node.ScrollPosition); InUndoHelper.GUIUndo(node, "Name Change", ref node.Name, () => EditorGUILayout.TextField("Name", node.Name)); Rect area = GUILayoutUtility.GetLastRect(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); InAudioData audioData = node._nodeData as InAudioData; EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); var clip = (AudioClip)EditorGUILayout.ObjectField(audioData._clip, typeof(AudioClip), false); Rect buttonArea = area; if (Application.isPlaying) { buttonArea.x += buttonArea.width - 100; buttonArea.width = 70; GUI.enabled = false; EditorGUI.LabelField(buttonArea, "Is Loaded"); buttonArea.x += 70; buttonArea.width = 10; EditorGUI.Toggle(buttonArea, audioData.IsLoaded); GUI.enabled = true; } AudioSource source = InAudioInstanceFinder.Instance.GetComponent<AudioSource>(); AudioPreview(node, source, audioData); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); if (clip != audioData._clip) //Assign new clip { InUndoHelper.RecordObjectFull(audioData, "Changed " + node.Name + " Clip"); audioData._clip = clip; EditorUtility.SetDirty(node._nodeData.gameObject); } EditorGUILayout.EndHorizontal(); if (clip != null) { DrawImportSettings(clip); } NodeTypeDataDrawer.Draw(node); GUILayout.EndScrollView(); }
private static void DeleteNodeRec(InAudioNode node) { for (int i = 0; i < node._children.Count; i++) { DeleteNodeRec(node._children[i]); } InUndoHelper.Destroy(node._nodeData); InUndoHelper.Destroy(node); }
public static void ChangeBankOverride(InAudioNode node) { var all = GetAllBanks(); InUndoHelper.RecordObject(all.ToArray().AddObj(node._nodeData), "Changed Bank"); InFolderData data = (node._nodeData as InFolderData); data.OverrideParentBank = !data.OverrideParentBank; RebuildBanks(); }
public static void ChangeAudioNodeBank(InAudioNode node, InAudioBankLink newBank) { var all = GetAllBanks(); InUndoHelper.RecordObject(all.ToArray().AddObj(node._nodeData), "Changed Bank"); InFolderData data = (node._nodeData as InFolderData); data.BankLink = newBank; RebuildBanks(); }
public static void ChangeBankOverride(InAudioNode node, InAudioBankLink rootBank, InAudioNode root) { var all = TreeWalker.FindAll(rootBank, link => link.Type == AudioBankTypes.Link ? link.LazyBankFetch : null); UndoHelper.RecordObject(all.ToArray().AddObj(node.NodeData), "Changed Bank"); InFolderData data = (node.NodeData as InFolderData); data.OverrideParentBank = !data.OverrideParentBank; RebuildBanks(rootBank, root); }
private static bool Predicate(InAudioNode inAudioNode) { /* if (!TreeWalker.IsParentOf(inAudioNode, activeNode)) * { * return true; * } * return false; */ return(false); }
private IEnumerator StartPlay(InAudioNode current, DSPTime endTime) { yield return(StartCoroutine(NextNode(current, endTime, 0))); yield return(new WaitForSeconds((float)(endTime.CurrentEndTime - AudioSettings.dspTime))); endTime.Player = null; dspPool.ReleaseObject(endTime); StopFast(); }
private void Load(bool forceReload) { if (!Loaded || forceReload) { AudioRoot = LoadData <InAudioNode>(FolderSettings.AudioLoadData); EventRoot = LoadData <InAudioEventNode>(FolderSettings.EventLoadData); MusicRoot = LoadData <InMusicNode>(FolderSettings.MusicLoadData); SettingsRoot = LoadData <InSettingsNode>(FolderSettings.SettingsLoadData); roots = new Component[] { AudioRoot, EventTree, MusicRoot, SettingsRoot }; } }
private static void AddNodesToBank(InAudioNode audioNode) { if (audioNode._type == AudioNodeType.Audio) { var nodeData = audioNode._nodeData as InAudioData; if (nodeData != null) { AddNodeToBank(audioNode); } } }
public static void RemoveNodeFromBank(InAudioNode node) { var bankLink = node.GetBank(); if (bankLink != null) { InUndoHelper.RecordObjectFull(bankLink, "Node from bank removal"); var bank = bankLink._bankData; bank.RemoveAll(b => b.AudioNode == node); } }
public static Object[] NodeUndo(InAudioNode node) { var bank = node.GetBank(); return(new Object[] { node, node._nodeData, bank }); }
public static Object[] NodeUndo(InAudioNode node) { var bank = node.GetBank(); return(new Object[] { node, node.NodeData, bank != null ? bank.LazyBankFetch : null }); }
public static void RemoveNodeFromBank(InAudioNode node) { var bankLink = node.GetBank(); if (bankLink != null) { var bank = bankLink.LazyBankFetch; UndoHelper.RecordObjectFull(bank, "Node from bank removal"); bank.Clips.RemoveAll(p => p.Node == node); } }
private static void AddNodesToBank(InAudioNode audioNode) { if (audioNode.Type == AudioNodeType.Audio) { var nodeData = audioNode.NodeData as InAudioData; if (nodeData != null) { AddNodeToBank(audioNode, nodeData.EditorClip); } } }
public void Find(InAudioNode toFind) { if (InAudioInstanceFinder.Instance != null) { audioCreatorGUI.Find(toFind); } else { Debug.LogError("InAudio: Cannot open window without having the manager in the scene"); } }
private static void NodeDuplicate(InAudioNode oldNode, InAudioNode newNode, GameObject gameObject) { Type type = oldNode._nodeData.GetType(); newNode._nodeData = gameObject.AddComponentUndo(type) as InAudioNodeBaseData; EditorUtility.CopySerialized(oldNode._nodeData, newNode._nodeData); if (newNode._type == AudioNodeType.Audio) { AudioBankWorker.AddNodeToBank(newNode); } }
public static InAudioNode CreateChild(GameObject go, InAudioNode parent, AudioNodeType newNodeType) { InUndoHelper.RecordObject(InUndoHelper.Array(parent).Concat(parent.GetAuxData()).ToArray(), "Undo Node Creation"); OnRandomNode(parent); var child = CreateNode(go, parent, GUIDCreator.Create(), newNodeType); parent.EditorSettings.IsFoldedOut = true; child.Name = parent.Name + " Child"; AddDataClass(child); return(child); }
public static AudioRolloffMode ApplyRolloffData(InAudioNode current, InAudioNodeData data, AudioSource workOn) { workOn.rolloffMode = data.RolloffMode; workOn.maxDistance = data.MaxDistance; workOn.minDistance = data.MinDistance; if (data.RolloffMode == AudioRolloffMode.Custom) { workOn.maxDistance = float.MaxValue;//Set to max so we can use our own animation curve } return data.RolloffMode; }
private static bool AllowedStealing(InAudioNode audioNode, List <InstanceInfo> currentInstances) { var data = (InAudioNodeData)audioNode.NodeData; if (data.LimitInstances && currentInstances.Count >= data.MaxInstances) { InPlayer player = null; var stealType = data.InstanceStealingTypes; if (stealType == InstanceStealingTypes.NoStealing) { return(false); } int index = 0; InstanceInfo foundInfo; if (stealType == InstanceStealingTypes.Newest) { double newestTime = 0; for (int i = 0; i < currentInstances.Count; i++) { InstanceInfo instanceInfo = currentInstances[i]; if (instanceInfo.Timestamp > newestTime) { newestTime = instanceInfo.Timestamp; index = i; } } } else if (stealType == InstanceStealingTypes.Oldest) { double oldestTime = Double.MaxValue; for (int i = 0; i < currentInstances.Count; i++) { InstanceInfo instanceInfo = currentInstances[i]; if (instanceInfo.Timestamp < oldestTime) { oldestTime = instanceInfo.Timestamp; index = i; } } } foundInfo = currentInstances[index]; player = foundInfo.Player; currentInstances.SwapRemoveAt(ref index); if (player != null) { player.Stop(); } } return(true); }
public static AudioRolloffMode CalcAttentutation(InAudioNode root, InAudioNode current, AudioSource workOn) { var data = (InAudioNodeData)current._nodeData; if (current == root || data.OverrideAttenuation) { return ApplyRolloffData(current, data, workOn); } else { return CalcAttentutation(root, current._parent, workOn); } }
private RuntimeInfo PreparePlay(GameObject controllingObject, InAudioNode audioNode, InPlayer player) { ObjectAudioList tupleList = GetValue(GOAudioNodes, controllingObject); RuntimeInfo runtimeInfo = new RuntimeInfo(); tupleList.InfoList.Add(runtimeInfo); runtimeInfo.Node = audioNode; runtimeInfo.Player = player; runtimeInfo.PlacedIn = tupleList; return(runtimeInfo); }
public static AudioRolloffMode ApplyRolloffData(InAudioNode current, InAudioNodeData data, AudioSource workOn) { workOn.rolloffMode = data.RolloffMode; workOn.maxDistance = data.MaxDistance; workOn.minDistance = data.MinDistance; if (data.RolloffMode == AudioRolloffMode.Custom) { workOn.maxDistance = float.MaxValue;//Set to max so we can use our own animation curve } return(data.RolloffMode); }
public static void Draw(InAudioNode node) { //node.ScrollPosition = GUILayout.BeginScrollView(node.ScrollPosition); EditorGUILayout.BeginVertical(); var trackData = (node._nodeData as InTrackData); NodeTypeDataDrawer.DrawName(node); //UndoHelper.GUIUndo(trackData, "Track length", ref trackData.TrackLength, () => EditorGUILayout.FloatField("Track length", trackData.TrackLength)); selectedArea = GUILayout.SelectionGrid(selectedArea, new [] { "Track", "Standard Settings" }, 2); EditorGUILayout.HelpBox("Hold control to drag a child node onto a track.", MessageType.None); if (selectedArea == 1) { NodeTypeDataDrawer.Draw(node); } else { EditorGUILayout.BeginVertical(); ScrollArea = EditorGUILayout.BeginScrollView(ScrollArea, false, false); EditorGUILayout.BeginVertical(); foreach (var layer in trackData.Layers) { DrawItem(node, layer); } if (GUILayout.Button("Add Layer", GUILayout.Width(150))) { InUndoHelper.RecordObjectFull(trackData, "Add layer"); trackData.Layers.Add(new InLayerData()); } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); if (toRemove != null) { if (trackData.Layers.Remove(toRemove)) { GUI.FocusControl("none"); InUndoHelper.RegisterUndo(trackData, "Removed Layer"); } } //GUILayout.EndScrollView(); }
public static void AddNodeToBank(InAudioNode node) { var bank = node.GetBank(); if (bank != null) { bank._bankData.Add(CreateBankDataItem(node)); EditorUtility.SetDirty(bank); } else { Debug.LogError("InAudio: Could not add node to bank as bank could not be found"); } }
private InAudioNode GetRolloffNode(InAudioNode current) { var data = current._nodeData as InAudioNodeData; if (data.OverrideAttenuation || current._parent.IsRootOrFolder) { return(current); } else { return(GetRolloffNode(current._parent)); } }
public static InAudioNode CreateNode(GameObject go, InAudioNode parent, int guid, AudioNodeType type) { var node = go.AddComponentUndo<InAudioNode>(); node._guid = guid; node._type = type; node.Name = parent.Name + " Child"; node.MixerGroup = parent.MixerGroup; node.AssignParent(parent); return node; }
public static AudioRolloffMode CalcAttentutation(InAudioNode root, InAudioNode current, AudioSource workOn) { var data = (InAudioNodeData)current._nodeData; if (current == root || data.OverrideAttenuation) { return(ApplyRolloffData(current, data, workOn)); } else { return(CalcAttentutation(root, current._parent, workOn)); } }
public void MissingArgumentsForNode(string functionName, InAudioNode node) { if (!InAudio.DoesExist) { InAudioInstanceMissing(); } else if (node == null) { Debug.LogWarning("InAudio: Missing arguments on " + functionName); } else { Debug.LogWarning("InAudio: Missing arguments on " + functionName); } }
public InPlayer PlayAtPosition(GameObject controllingObject, InAudioNode audioNode, Vector3 position, AudioParameters audioParameters, float fade = 0f, LeanTweenType fadeType = LeanTweenType.notUsed) { if (audioNode.IsRootOrFolder) { Debug.LogWarning("InAudio: Cannot play \"" + audioNode.GetName + "\" as it is a folder"); return null; } List<InstanceInfo> currentInstances = audioNode.CurrentInstances; if (!AllowedStealing(audioNode, currentInstances)) return null; var runtimePlayer = InAudioInstanceFinder.RuntimePlayerControllerPool.GetObject(); runtimePlayer.transform.position = position; currentInstances.Add(new InstanceInfo(AudioSettings.dspTime, runtimePlayer)); Play(controllingObject, audioNode, runtimePlayer, fade, fadeType, audioParameters); return runtimePlayer; }
public void MissingArguments(string functionName, GameObject gameObject, InAudioNode node) { if (!InAudio.DoesExist) { InAudioInstanceMissing(); } else if (gameObject == null && node == null) { Debug.LogWarning("InAudio: Missing arguments on " + functionName); } else if (gameObject == null) { Debug.LogWarning("InAudio: Missing arguments on " + functionName + " playing node " + node.GetName); } else { Debug.LogWarning("InAudio: Missing arguments on " + functionName + " on game object " + gameObject.name); } }
public static void AudioTreeInitialVolume(InAudioNode node, float parentVolume) { var folderData = node._nodeData as InFolderData; var children = node._children; int childCount = children.Count; if (folderData != null) { folderData.runtimeVolume = folderData.VolumeMin; folderData.hiearchyVolume = folderData.runtimeVolume * parentVolume; for (int i = 0; i < childCount; i++) { AudioTreeUpdate(children[i], folderData.hiearchyVolume); } } }
public static void DrawMixer(InAudioNode node) { var serialized = new SerializedObject(node); serialized.Update(); if (!node.IsRoot) { bool overrideParent = EditorGUILayout.Toggle("Override Parent Mixer Group", node.OverrideParentMixerGroup); if (overrideParent != node.OverrideParentMixerGroup) { InUndoHelper.RecordObjectFull(new Object[] {node._nodeData, node}, "Override parent mixer group"); node.OverrideParentMixerGroup = overrideParent; } if (!node.OverrideParentMixerGroup) GUI.enabled = false; } EditorGUILayout.BeginHorizontal(); if (node.IsRoot) { EditorGUILayout.PropertyField(serialized.FindProperty("MixerGroup"), new GUIContent("Mixer Group")); } else if (node.OverrideParentMixerGroup) { EditorGUILayout.PropertyField(serialized.FindProperty("MixerGroup"), new GUIContent("Mixer Group")); } else { EditorGUILayout.PropertyField(new SerializedObject(node.GetParentMixerGroup()).FindProperty("MixerGroup"), new GUIContent("Parent Mixer Group")); } GUI.enabled = node.GetMixerGroup() != null; if (GUILayout.Button("Find", GUILayout.Width(40))) { SearchHelper.SearchFor(node.MixerGroup); } EditorGUILayout.EndHorizontal(); serialized.ApplyModifiedProperties(); GUI.enabled = true; }
public static void AudioTreeUpdate(InAudioNode node, float parentVolume) { var folderData = node._nodeData as InFolderData; var children = node._children; int childCount = children.Count; if (folderData != null) { #if UNITY_EDITOR bool checkPlayer = Application.isPlaying; if (!Application.isPlaying) { folderData.runtimeVolume = folderData.VolumeMin; } #else bool checkPlayer = true; #endif float volume = folderData.runtimeVolume * parentVolume; folderData.hiearchyVolume = volume; for (int i = 0; i < childCount; i++) { AudioTreeUpdate(children[i], volume); } if (checkPlayer) { for (int i = 0; i < folderData.runtimePlayers.Count; i++) { var player = folderData.runtimePlayers[i]; player.internalSetFolderVolume(folderData.hiearchyVolume); player.internalUpdate(); } } } }
/// <summary> /// Sets the volume for all instances of this audio node on the object. /// </summary> /// <param name="gameObject"></param> /// <param name="audioNode"></param> /// <param name="volume"></param> public static void SetVolumeForNode(GameObject gameObject, InAudioNode audioNode, float volume) { if (instance != null && gameObject != null && audioNode != null) { if (!audioNode.IsRootOrFolder) { instance._inAudioEventWorker.SetVolumeForNode(gameObject, audioNode, volume); } else { Debug.LogWarning("InAudio: Cannot change volume for audio folders here, use SetVolumeForAudioFolder() instead."); } } else { InDebug.MissingArguments("SetVolumeForNode", gameObject, audioNode); } }
public static void SetVolumeForAudioFolder(InAudioNode folderNode, float volume) { if (instance != null && folderNode != null && folderNode.IsRootOrFolder) { var data = folderNode._nodeData as InFolderData; if (data != null) { data.runtimeVolume = Mathf.Clamp01(volume); } else { Debug.LogWarning("InAudio: Cannot set folder volume node that isn't a folder"); } } else { InDebug.MissingArgumentsForNode("SetVolumeForNode", folderNode); } }
/// <summary> /// Stop all sound effects /// </summary> /// <param name="gameObject"></param> public static void StopAllOfNode(InAudioNode audioNode) { if (instance != null && audioNode != null) instance._inAudioEventWorker.StopAll(0, LeanTweenType.notUsed); else { InDebug.MissingArgumentsForNode("StopAllOfNode", audioNode); } }
/// <summary> /// Stop all sound effects /// </summary> /// <param name="gameObject"></param> public static void StopAllOfNode(InAudioNode audioNode, float fadeOutDuration, LeanTweenType leanTweenType = LeanTweenType.easeInOutQuad) { if (instance != null) instance._inAudioEventWorker.StopAll(0, leanTweenType); else { InDebug.MissingArgumentsForNode("StopAllOfNode", audioNode); } }
/// <summary> /// Stop all instances of the this audio node on the game object with a fade out time /// </summary> /// <param name="gameObject"></param> /// <param name="audioNode"></param> /// <param name="fadeOutTime"></param> public static void Stop(GameObject gameObject, InAudioNode audioNode, float fadeOutTime) { if (instance != null && gameObject != null && audioNode != null) instance._inAudioEventWorker.StopByNode(gameObject, audioNode, fadeOutTime); else { InDebug.MissingArguments("Stop (Fadeout)", gameObject, audioNode); } }
/// <summary> /// Breaks all looping instances of this node on the game object /// </summary> /// <param name="gameObject"></param> /// <param name="audioNode"></param> public static void Break(GameObject gameObject, InAudioNode audioNode) { if (instance != null && gameObject != null && audioNode != null) instance._inAudioEventWorker.Break(gameObject, audioNode); else { InDebug.MissingArguments("Break", gameObject, audioNode); } }
/// <summary> /// Play an audio node in world space with a custom fade, attached to another game object /// </summary> /// <param name="gameObject">The game object to attach to and be controlled by</param> /// <param name="audioNode">The node to play</param> /// <param name="position">The world position to play at</param> /// <param name="fadeTime">How long it should take to fade in from 0 to 1 in volume</param> /// <param name="tweeenType">The curve of fading</param> /// <param name="startVolume">The starting volume</param> /// <param name="endVolume">The end volume</param> /// <param name="parameters">Parameters to set initial values directly</param> /// <returns>A controller for the playing node</returns> public static InPlayer PlayAtPosition(GameObject gameObject, InAudioNode audioNode, Vector3 position, float fadeTime, LeanTweenType tweeenType, float startVolume, float endVolume, AudioParameters parameters = null) { if (instance == null || audioNode == null || audioNode.IsRootOrFolder) { InDebug.MissingArguments("PlayAtPosition (tween specific)", gameObject, audioNode); return null; } InPlayer player = instance._inAudioEventWorker.PlayAtPosition(gameObject, audioNode, position, parameters); player.Volume = startVolume; LTDescr tweever = LeanTween.value(gameObject, (f, o) => { (o as InPlayer).Volume = f; }, startVolume, endVolume, fadeTime); tweever.onUpdateParam = player; tweever.tweenType = tweeenType; return player; }
/// <summary> /// Play an audio node on InAudio directly so it does not get destroyed in scene transition. /// No fade in as code would not get called during scene transition. Works best with simple sound effects /// </summary> /// <param name="gameObject">The game object to attach to and be controlled by</param> /// <param name="audioNode">The node to play</param> /// <returns>A controller for the playing node</returns> /// <param name="parameters">Parameters to set initial values directly</param> public static InPlayer PlayPersistent(Vector3 position, InAudioNode audioNode, AudioParameters parameters = null) { if (instance == null || audioNode == null || audioNode.IsRootOrFolder) { InDebug.MissingArgumentsForNode("PlayPersistent", audioNode); return null; } InPlayer player = instance._inAudioEventWorker.PlayAtPosition(instance.gameObject, audioNode, position, parameters); return player; }
/// <summary> /// Play an audio node directly with a fade, following a game object and persists even if the GO is destroyed. /// </summary> /// <param name="gameObject">The game object to be controlled by and follow</param> /// <param name="audioNode">The node to play</param> /// <param name="fadeTime">How long it should take to fade in from 0 to 1 in volume</param> /// <param name="tweeenType">The curve of fading</param> /// <param name="parameters">Parameters to set initial values directly</param> /// <returns>A controller for the playing node</returns> public static InPlayer PlayFollowing(GameObject gameObject, InAudioNode audioNode, float fadeTime, LeanTweenType tweeenType, AudioParameters parameters = null) { if (instance == null || audioNode == null || audioNode.IsRootOrFolder || gameObject == null) { InDebug.MissingArguments("PlayFollowing (tween)", gameObject, audioNode); return null; } InPlayer player = instance._inAudioEventWorker.PlayFollowing(gameObject, audioNode, parameters); player.Volume = 0.0f; LTDescr tweever = LeanTween.value(gameObject, (f, o) => { (o as InPlayer).Volume = f; }, 0.0f, 1f, fadeTime); tweever.onUpdateParam = player; tweever.tweenType = tweeenType; return player; }
/// <summary> /// Play an audio node directly, at this position in world space /// </summary> /// <param name="gameObject">The game object to attach to and be controlled by</param> /// <param name="audioNode">The node to play</param> /// <param name="position">The world position to play at</param> /// <param name="parameters">Parameters to set initial values directly</param> /// <returns>A controller for the playing node</returns> public static InPlayer PlayAtPosition(GameObject gameObject, InAudioNode audioNode, Vector3 position, AudioParameters parameters = null) { if (instance != null && gameObject != null && audioNode != null) return instance._inAudioEventWorker.PlayAtPosition(gameObject, audioNode, position, parameters); else InDebug.MissingArguments("PlayAtPosition", gameObject, audioNode); return null; }
/// <summary> /// Play an audio node directly with a custom fade, following a game object and persists even if the GO is destroyed. /// </summary> /// <param name="gameObject">The game object to be controlled by and follow</param> /// <param name="audioNode">The node to play</param> /// <param name="parameters">Parameters to set initial values directly</param> /// <returns>A controller for the playing node</returns> public static InPlayer PlayFollowing(GameObject gameObject, InAudioNode audioNode, AudioParameters parameters = null) { if (instance == null || audioNode == null || audioNode.IsRootOrFolder || gameObject == null) { InDebug.MissingArguments("PlayFollowing", gameObject, audioNode); return null; } InPlayer player = instance._inAudioEventWorker.PlayFollowing(gameObject, audioNode, parameters); return player; }
private float PlayScheduled(InAudioNode startNode, InAudioNode currentNode, InAudioData audioData, double playAtDSPTime, float offset, out float nodeVolume) { float length = 0; nodeVolume = 1; if (audioData._clip != null) { var clip = audioData._clip; length = clip.ExactLength(); length -= offset; float lengthOffset = offset*clip.frequency; var source = Current.AudioSource; source.clip = clip; nodeVolume = RuntimeHelper.CalcVolume(startNode, currentNode); Current.OriginalVolume = nodeVolume; SetVolume(Current, audioParameters.Volume); source.spatialBlend = RuntimeHelper.CalcBlend(startNode, currentNode); source.pitch = RuntimeHelper.CalcPitch(startNode, currentNode) * audioParameters.Pitch; source.rolloffMode = RuntimeHelper.CalcAttentutation(startNode, currentNode, source); if (audioParameters.SetMixer) { source.outputAudioMixerGroup = audioParameters.AudioMixer; } else { source.outputAudioMixerGroup = currentNode.GetMixerGroup(); } length = RuntimeHelper.LengthFromPitch(length, source.pitch); Current.EndTime = playAtDSPTime + length; Current.StartTime = playAtDSPTime; Current.UsedNode = currentNode; source.panStereo += audioParameters.StereoPan; source.spread = _spread; source.spatialBlend *= audioParameters.SpatialBlend; source.timeSamples = (int) (lengthOffset); source.PlayScheduled(playAtDSPTime); } else { Debug.LogWarning("InAudio: Audio clip missing on audio node \"" + currentNode.Name + "\", id=" + currentNode._ID); } return length; }
public void ReceiveNode(InAudioNode node) { audioEventCreatorGUI.ReceiveNode(node); }