public static InAudioEventNode CreateNode(InAudioEventNode parent, EventNodeType type, string name) { var node = CreateNode(parent, type); node.Name = name; return(node); }
private void OnPostEvent(GameObject controllingObject, InAudioEventNode postEvent, Vector3 postAt) { bool areAnyDelayed = false; if (postEvent.Delay > 0) { StartCoroutine(DelayedEvent(controllingObject, postEvent, postAt)); } else { areAnyDelayed = PostUndelayedActions(controllingObject, postEvent, postAt); } if (areAnyDelayed) { for (int i = 0; i < postEvent.ActionList.Count; ++i) { var eventData = postEvent.ActionList[i]; if (eventData != null && eventData.Delay > 0) { StartCoroutine(PostDelayedActions(controllingObject, eventData, postAt)); } } } }
private static void NewEventArea(InAudioEventNode audioevent) { var defaultAlignment = GUI.skin.label.alignment; EditorGUILayout.BeginHorizontal(); GUI.skin.label.alignment = TextAnchor.MiddleLeft; EditorGUILayout.LabelField(""); EditorGUILayout.EndHorizontal(); Rect lastArea = GUILayoutUtility.GetLastRect(); lastArea.height *= 1.5f; if (GUI.Button(lastArea, "Click or drag here to add event action")) { ShowCreationContext(audioevent); } var dragging = DragAndDrop.objectReferences; OnDragging.OnDraggingObject(dragging, lastArea, objects => AudioEventWorker.CanDropObjects(audioevent, dragging), objects => AudioEventWorker.OnDrop(audioevent, dragging)); GUI.skin.label.alignment = defaultAlignment; }
public void Add(InAudioEventNode audioEvent, EventHookListData.PostEventAt postAt) { var data = new EventHookListData(audioEvent); data.PostAt = postAt; Events.Add(data); }
private void OnPostEventAtPosition(GameObject controllingObject, InAudioEventNode audioEvent, Vector3 position) { if (instance != null && controllingObject != null && audioEvent != null) { instance.OnPostEvent(controllingObject, audioEvent, position); } }
public void Load(bool forceReload = false) { if (AudioRoot == null || BankLinkRoot == null || BusRoot == null || EventRoot == null || forceReload) { Component[] audioData; Component[] eventData; Component[] busData; Component[] bankLinkData; SaveAndLoad.LoadManagerData(out audioData, out eventData, out busData, out bankLinkData); BusRoot = CheckData <InAudioBus>(busData); AudioRoot = CheckData <InAudioNode>(audioData); EventRoot = CheckData <InAudioEventNode>(eventData); BankLinkTree = CheckData <InAudioBankLink>(bankLinkData); /*if (BusRoot != null) * BusRootGO = BusRoot.gameObject; * if (AudioRoot != null) * AudioRootGO = AudioRoot.gameObject; * if (EventRoot != null) * EventRootGO = EventRoot.gameObject; * if (BankLinkTree != null) * BankLinkRootGO = BankLinkTree.gameObject;*/ } }
public static T AddEventAction <T>(InAudioEventNode audioevent, EventActionTypes enumType) where T : AudioEventAction { var eventAction = audioevent.gameObject.AddComponentUndo <T>(); audioevent._actionList.Add(eventAction); eventAction._eventActionType = enumType; return(eventAction); }
public static InAudioEventNode CreateNode(InAudioEventNode parent, EventNodeType type) { var child = CreateEvent(parent.gameObject, parent, GUIDCreator.Create(), type); child.FoldedOut = true; return(child); }
public static InAudioEventNode CreateNode(InAudioEventNode parent, GameObject go, EventNodeType type) { var child = CreateEvent(go, parent, GUIDCreator.Create(), type); child.EditorSettings.IsFoldedOut = true; return(child); }
public static bool OnDrop(InAudioEventNode audioevent, Object[] objects) { InUndoHelper.DoInGroup(() => { //if (audioevent.Type == EventNodeType.Folder) //{ // UndoHelper.RecordObjectInOld(audioevent, "Created event"); // audioevent = CreateNode(audioevent, EventNodeType.Event); //} if (objects[0] as InAudioEventNode) { var movingEvent = objects[0] as InAudioEventNode; if (movingEvent.gameObject != audioevent.gameObject) { if (EditorUtility.DisplayDialog("Move?", "Warning, this will break all external references to this and all child nodes!\n" + "Move node from\"" + movingEvent.gameObject.name + "\" to \"" + audioevent.gameObject.name + "\"?", "Ok", "Cancel")) { InUndoHelper.DoInGroup(() => { CopyTo(movingEvent, audioevent); DeleteNodeNoGroup(movingEvent); }); } } else { InUndoHelper.RecordObjectFull(new Object[] { audioevent, movingEvent, movingEvent._parent }, "Event Move"); NodeWorker.ReasignNodeParent(movingEvent, audioevent); audioevent.EditorSettings.IsFoldedOut = true; } } var audioNode = objects[0] as InAudioNode; if (audioNode != null && audioNode.IsPlayable) { InUndoHelper.RecordObjectFull(audioevent, "Adding of Audio Action"); var action = AddEventAction <InEventAudioAction>(audioevent, EventActionTypes.Play); action.Node = audioNode; } var musicGroup = objects[0] as InMusicGroup; if (musicGroup != null) { InUndoHelper.RecordObjectFull(audioevent, "Adding of Music Action"); var action = AddEventAction <InEventMusicControl>(audioevent, EventActionTypes.PlayMusic); action.MusicGroup = musicGroup; } Event.current.UseEvent(); }); return(true); }
public static void DeleteNode(InAudioEventNode node) { InUndoHelper.DoInGroup(() => { InUndoHelper.RegisterUndo(node._parent, "Event Deletion"); node._parent._children.Remove(node); DeleteNodeRec(node); }); }
private static InAudioEventNode CreateFolder(GameObject go, int guid, InAudioEventNode parent) { var node = go.AddComponentUndo <InAudioEventNode>(); node._type = EventNodeType.Folder; node._guid = guid; node.Name = parent.Name + " Child"; node.AssignParent(parent); return(node); }
public static AudioEventAction AddEventAction(InAudioEventNode audioevent, Type eventActionType, EventActionTypes enumType) { InUndoHelper.RecordObject(audioevent, "Event Action Creation"); var eventAction = audioevent.gameObject.AddComponentUndo(eventActionType) as AudioEventAction; audioevent._actionList.Add(eventAction); eventAction._eventActionType = enumType; return(eventAction); }
public static InAudioEventNode DeleteActionAtIndex(InAudioEventNode audioevent, int index) { InUndoHelper.RecordObject(audioevent, "Event Action Creation"); InUndoHelper.Destroy(audioevent._actionList[index]); audioevent._actionList.RemoveAt(index); return(audioevent); }
public static InAudioEventNode Duplicate(InAudioEventNode audioEvent) { return(NodeWorker.DuplicateHierarchy(audioEvent, (@oldNode, newNode) => { newNode._actionList.Clear(); for (int i = 0; i < oldNode._actionList.Count; i++) { newNode._actionList.Add(NodeWorker.CopyComponent(oldNode._actionList[i])); } })); }
private static InAudioEventNode CreateEvent(GameObject go, InAudioEventNode parent, int guid, EventNodeType type) { var node = go.AddComponentUndo <InAudioEventNode>(); node._type = type; node._guid = guid; node.Name = parent.Name + " Child"; InUndoHelper.RecordObject(parent, "Parrent asign"); node.AssignParent(parent); return(node); }
private void BuildEventSet(InAudioEventNode audioevent, Dictionary<int, InAudioEventNode> events) { if (audioevent.IsRootOrFolder) { events[audioevent._guid] = audioevent; } for (int i = 0; i < audioevent._children.Count; ++i) { BuildEventSet(audioevent._children[i], events); } }
void BuildEventSet(InAudioEventNode audioevent, Dictionary <int, InAudioEventNode> events) { if (audioevent.Type != EventNodeType.Folder && audioevent.Type != EventNodeType.Root) { events[audioevent.GUID] = audioevent; } for (int i = 0; i < audioevent.Children.Count; ++i) { BuildEventSet(audioevent.Children[i], events); } }
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 DeleteNodeRec(InAudioEventNode node) { for (int i = 0; i < node._actionList.Count; i++) { InUndoHelper.Destroy(node._actionList[i]); } for (int i = 0; i < node._children.Count; ++i) { DeleteNodeRec(node._children[i]); } InUndoHelper.Destroy(node); }
public static bool CanDropObjects(InAudioEventNode audioEvent, Object[] objects) { if (objects.Length == 0 || audioEvent == null) { return(false); } if (audioEvent._type == EventNodeType.Event) { var nonEventDrop = CanDropNonEvent(objects); return(nonEventDrop); } else if (audioEvent._type == EventNodeType.Folder || audioEvent._type == EventNodeType.Root) { var draggingEvent = objects[0] as InAudioEventNode; if (draggingEvent != null) { if (draggingEvent._type == EventNodeType.Event) { return(true); } if ((draggingEvent._type == EventNodeType.Folder && !NodeWorker.IsChildOf(draggingEvent, audioEvent)) || draggingEvent._type == EventNodeType.EventGroup) { return(true); } } else { var nonEventDrop = CanDropNonEvent(objects) && !audioEvent.IsRootOrFolder; return(nonEventDrop); } } else if (audioEvent._type == EventNodeType.EventGroup) { var draggingEvent = objects[0] as InAudioEventNode; if (draggingEvent == null) { return(false); } if (draggingEvent._type == EventNodeType.Event) { return(true); } } return(false); }
/// <summary> /// Find an Audio Event by id so it can be posted directly /// </summary> /// <param name="id">The ID of the event to post. The ID is found in the InAudio Event window</param> /// <returns>The found audio event. Returns null if not found</returns> public static InAudioEventNode FindEventByID(int id) { InAudioEventNode postEvent = null; if (instance != null) { instance.runtimeData.Events.TryGetValue(id, out postEvent); } else { InDebug.LogWarning("InAudio: Could not try to find event with id " + id + " as no InAudio instance was found"); } return(postEvent); }
private static void ShowCreationContext(InAudioEventNode audioevent) { var menu = new GenericMenu(); List <EventActionExtension.ActionMeta> actionList = EventActionExtension.GetList(); foreach (EventActionExtension.ActionMeta currentType in actionList) { Type newType = AudioEventAction.ActionEnumToType(currentType.ActionType); var enumType = currentType.ActionType; menu.AddItem(new GUIContent(currentType.Name), false, f => AudioEventWorker.AddEventAction(audioevent, newType, enumType), currentType); } menu.ShowAsContext(); }
public void Load(bool forceReload = false) { if (AudioRoot == null || BankLinkRoot == null || EventRoot == null || MusicRoot == null || forceReload) { Component[] audioData; Component[] eventData; Component[] bankLinkData; Component[] musicData; SaveAndLoad.LoadManagerData(out audioData, out eventData, out musicData, out bankLinkData); AudioRoot = CheckData <InAudioNode>(audioData); EventRoot = CheckData <InAudioEventNode>(eventData); BankLinkTree = CheckData <InAudioBankLink>(bankLinkData); MusicTree = CheckData <InMusicNode>(musicData); } }
private static void ShowChangeContext(InAudioEventNode audioEvent, AudioEventAction action) { var menu = new GenericMenu(); List <EventActionExtension.ActionMeta> actionList = EventActionExtension.GetList(); foreach (EventActionExtension.ActionMeta currentType in actionList) { var enumType = currentType.ActionType; menu.AddItem( new GUIContent(currentType.Name), false, f => ChangeAction(audioEvent, action, enumType), currentType.ActionType ); } menu.ShowAsContext(); }
public static void ReplaceActionDestructiveAt(InAudioEventNode audioEvent, EventActionTypes enumType, int toRemoveAndInsertAt) { //A reel mess this function. //It adds a new component of the specied type, replaces the current at the toRemoveAndInsertAt index, and then deletes the old one float delay = audioEvent._actionList[toRemoveAndInsertAt].Delay; Object target = audioEvent._actionList[toRemoveAndInsertAt].Target; var newActionType = AudioEventAction.ActionEnumToType(enumType); InUndoHelper.Destroy(audioEvent._actionList[toRemoveAndInsertAt]); //UndoHelper.RecordObject(audioEvent, "Event Action Creation"); audioEvent._actionList.RemoveAt(toRemoveAndInsertAt); var added = AddEventAction(audioEvent, newActionType, enumType); added.Delay = delay; added.Target = target; //Attempt to set the new value, will only work if it is the same type audioEvent._actionList.Insert(toRemoveAndInsertAt, added); audioEvent._actionList.RemoveLast(); }
/// <summary> /// Post all actions in this event attached to this another game object than the one controlling it /// </summary> /// <param name="controllingObject">The controlling object of the played sources</param> /// <param name="postEvent">The event to post the actions of</param> /// <param name="attachedToOther">The audio source to attach any audio sources to</param> public static void PostEventAttachedTo(GameObject controllingObject, InAudioEventNode postEvent, GameObject attachedToOther) { if (instance != null && controllingObject != null && postEvent != null) { instance.OnPostEvent(controllingObject, postEvent, attachedToOther); } else { if (instance == null) { InDebug.InAudioInstanceMissing(controllingObject); } else if (controllingObject == null) { InDebug.MissingControllingObject(); } else if (postEvent == null) { InDebug.MissingEvent(controllingObject); } } }
private bool PostUndelayedActions(GameObject controllingObject, InAudioEventNode postEvent, Vector3 postAt) { bool areAnyDelayed = false; for (int i = 0; i < postEvent.ActionList.Count; ++i) { var eventData = postEvent.ActionList[i]; if (eventData == null) { continue; } if (eventData.Delay > 0) { areAnyDelayed = true; } else { HandleEventAction(controllingObject, eventData, null, postAt); } } return(areAnyDelayed); }
/// <summary> /// Post all actions in this event at this position with this game object as the controller /// </summary> /// <param name="controllingObject">The controlling object of the played audio files</param> /// <param name="postEvent">The event to post the actions of</param> /// <param name="position">The position in world space of the sound</param> public static void PostEventAtPosition(GameObject controllingObject, InAudioEventNode postEvent, Vector3 position) { if (instance != null && controllingObject != null && postEvent != null) { instance.OnPostEventAtPosition(controllingObject, postEvent, position); } else { if (instance == null) { InDebug.InAudioInstanceMissing(controllingObject); } else if (controllingObject == null) { InDebug.MissingControllingObject(); } else if (postEvent == null) { InDebug.MissingEvent(controllingObject); } } }
private static void ChangeAction(InAudioEventNode audioEvent, AudioEventAction action, EventActionTypes newEnumType) { for (int i = 0; i < audioEvent._actionList.Count; ++i) { if (audioEvent._actionList[i] == action) { Type oldType = AudioEventAction.ActionEnumToType(action._eventActionType); Type newType = AudioEventAction.ActionEnumToType(newEnumType); if (oldType != newType) { InUndoHelper.DoInGroup(() => AudioEventWorker.ReplaceActionDestructiveAt(audioEvent, newEnumType, i)); } else { InUndoHelper.RecordObject(action, "Change Event Action Type"); action._eventActionType = newEnumType; } break; } } }
private void OnPostEvent(GameObject controllingObject, InAudioEventNode postEvent, Vector3 postAt) { bool areAnyDelayed = false; if (postEvent.Delay > 0) { StartCoroutine(DelayedEvent(controllingObject, postEvent, postAt)); } else { areAnyDelayed = PostUndelayedActions(controllingObject, postEvent, postAt); } if (areAnyDelayed) { for (int i = 0; i < postEvent._actionList.Count; ++i) { var eventData = postEvent._actionList[i]; if (eventData != null && eventData.Delay > 0) StartCoroutine(PostDelayedActions(controllingObject, eventData, postAt)); } } }
private void OnPostEventAtPosition(GameObject controllingObject, InAudioEventNode audioEvent, Vector3 position) { if (instance != null && controllingObject != null && audioEvent != null) instance.OnPostEvent(controllingObject, audioEvent, position); }
private IEnumerator DelayedEvent(GameObject controllingObject, InAudioEventNode postEvent, GameObject attachedToOther) { yield return new WaitForSeconds(postEvent.Delay); PostUndelayedActions(controllingObject, postEvent, attachedToOther); }
public void Find(InAudioEventNode toFind) { audioEventCreatorGUI.Find(toFind); }
public static bool EventFoldout(InAudioEventNode node, bool isSelected, out bool clicked) { clicked = false; if (noMargain == null) { noMargain = new GUIStyle(); noMargain.margin = new RectOffset(0, 0, 0, 0); } Rect fullArea = EditorGUILayout.BeginHorizontal(); Rect area = EditorGUILayout.BeginHorizontal(); if(isSelected) GUI.DrawTexture(area, EditorResources.Instance.GetBackground()); if (node._type != EventNodeType.Event) GUILayout.Space(EditorGUI.indentLevel * 16); else GUILayout.Space(EditorGUI.indentLevel * 24); if (node._type != EventNodeType.Event) { Texture picture; if (node.IsFoldedOut || node._children.Count == 0) picture = EditorResources.Instance.Minus; else picture = EditorResources.Instance.Plus; if (GUILayout.Button(picture, GUIStyle.none, GUILayout.Height(EditorResources.Instance.Minus.height), GUILayout.Width(EditorResources.Instance.Minus.width))) { node.IsFoldedOut = !node.IsFoldedOut; Event.current.UseEvent(); } TreeNodeDrawerHelper.DrawIcon(GUILayoutUtility.GetLastRect(), EditorResources.Instance.Folder, noMargain); } GUILayout.Space(30); EditorGUILayout.LabelField(""); EditorGUILayout.EndHorizontal(); Rect labelArea = GUILayoutUtility.GetLastRect(); if (node._type != EventNodeType.Event)//As Events are smaller labelArea.y += 6; if (node._type != EventNodeType.Event) { labelArea.x += 60; } else { labelArea.x += 30; } EditorGUI.LabelField(labelArea, node.Name); EditorGUILayout.EndHorizontal(); if (Event.current.ClickedWithin(fullArea)) { clicked = true; } return node.IsFoldedOut; }
/// <summary> /// Post all actions in this event attached to this another game object than the one controlling it /// </summary> /// <param name="controllingObject">The controlling object of the played sources</param> /// <param name="postEvent">The event to post the actions of</param> /// <param name="attachedToOther">The audio source to attach any audio sources to</param> public static void PostEventAttachedTo(GameObject controllingObject, InAudioEventNode postEvent, GameObject attachedToOther) { if (instance != null && controllingObject != null && postEvent != null) instance.OnPostEvent(controllingObject, postEvent, attachedToOther); else { if (instance == null) InDebug.InAudioInstanceMissing(controllingObject); else if (controllingObject == null) { InDebug.MissingControllingObject(); } else if (postEvent == null) { InDebug.MissingEvent(controllingObject); } } }
private static void ShowChangeContext(InAudioEventNode audioEvent, AudioEventAction action) { var menu = new GenericMenu(); List<EventActionExtension.ActionMeta> actionList = EventActionExtension.GetList(); foreach (EventActionExtension.ActionMeta currentType in actionList) { var enumType = currentType.ActionType; menu.AddItem( new GUIContent(currentType.Name), false, f => ChangeAction(audioEvent, action, enumType), currentType.ActionType ); } menu.ShowAsContext(); }
public static bool Draw(InAudioEventNode audioevent) { if (ListAdapter == null) { ListAdapter = new EventActionListAdapter(); ListAdapter.DrawEvent = DrawItem; ListAdapter.ClickedInArea = ClickedInArea; } if (lastEvent != audioevent) { ListAdapter.Event = audioevent; audioEventAction = null; if (audioevent._actionList.Count > 0) { audioEventAction = audioevent._actionList[0]; } } EditorGUILayout.BeginVertical(); lastEvent = audioevent; InUndoHelper.GUIUndo(audioevent, "Name Change", ref audioevent.Name, () => EditorGUILayout.TextField("Name", audioevent.Name)); bool repaint = false; if (audioevent._type == EventNodeType.Event) { EditorGUIHelper.DrawID(audioevent._guid); if (Application.isPlaying) { eventObjectTarget = EditorGUILayout.ObjectField("Event preview target", eventObjectTarget, typeof(GameObject), true) as GameObject; if (eventObjectTarget != null ) { bool prefab = PrefabUtility.GetPrefabParent(eventObjectTarget) == null && PrefabUtility.GetPrefabObject(eventObjectTarget) != null; if (!prefab) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Post event")) { InAudio.PostEvent(eventObjectTarget, audioevent); } if (GUILayout.Button("Stop All Sounds/Music in Event")) { InAudio.StopAll(eventObjectTarget); foreach (var eventAction in audioevent._actionList) { var music = eventAction.Target as InMusicGroup; if (music != null) { InAudio.Music.Stop(music); } } } EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("Cannot post events on Prefab", MessageType.Error); } } EditorGUILayout.Separator(); } InUndoHelper.GUIUndo(audioevent, "Delay", ref audioevent.Delay, () => Mathf.Max(EditorGUILayout.FloatField("Delay", audioevent.Delay), 0)); NewEventArea(audioevent); EditorGUILayout.Separator(); EditorGUILayout.Separator(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); repaint = DrawContent(); EditorGUILayout.EndScrollView(); DrawSelected(audioEventAction); } else if (audioevent._type == EventNodeType.Folder) { if (audioevent.PlacedExternaly) { EditorGUILayout.Separator(); GUI.enabled = false; EditorGUILayout.ObjectField("Placed on", audioevent.gameObject, typeof(GameObject), false); GUI.enabled = true; EditorGUILayout.Separator(); } } EditorGUILayout.EndVertical(); if (toRemove != null) { InUndoHelper.DoInGroup(() => { //Remove the required piece int index = audioevent._actionList.FindIndex(toRemove); AudioEventWorker.DeleteActionAtIndex(audioevent, index); }); toRemove = null; } else //Remove all actions that does not excist. { audioevent._actionList.RemoveAll(p => p == null); } return repaint; }
public void UpdateEvents(InAudioEventNode root) { Events = new Dictionary<int, InAudioEventNode>(); BuildEventSet(root, Events); }
public EventHookListData(InAudioEventNode audioEvent) { Event = audioEvent; }
private bool PostUndelayedActions(GameObject controllingObject, InAudioEventNode postEvent, Vector3 postAt) { bool areAnyDelayed = false; for (int i = 0; i < postEvent._actionList.Count; ++i) { var eventData = postEvent._actionList[i]; if (eventData == null) continue; if (eventData.Delay > 0) { areAnyDelayed = true; } else HandleEventAction(controllingObject, eventData, null, postAt); } return areAnyDelayed; }
private IEnumerator DelayedEvent(GameObject controllingObject, InAudioEventNode postEvent, Vector3 postAt) { yield return new WaitForSeconds(postEvent.Delay); PostUndelayedActions(controllingObject, postEvent, postAt); }
/// <summary> /// Post all actions in this event at this position with this game object as the controller /// </summary> /// <param name="controllingObject">The controlling object of the played audio files</param> /// <param name="postEvent">The event to post the actions of</param> /// <param name="position">The position in world space of the sound</param> public static void PostEventAtPosition(GameObject controllingObject, InAudioEventNode postEvent, Vector3 position) { if (instance != null && controllingObject != null && postEvent != null) instance.OnPostEventAtPosition(controllingObject, postEvent, position); else { if (instance == null) InDebug.InAudioInstanceMissing(controllingObject); else if (controllingObject == null) { InDebug.MissingControllingObject(); } else if (postEvent == null) { InDebug.MissingEvent(controllingObject); } } }
private static void ShowCreationContext(InAudioEventNode audioevent) { var menu = new GenericMenu(); List<EventActionExtension.ActionMeta> actionList = EventActionExtension.GetList(); foreach (EventActionExtension.ActionMeta currentType in actionList) { Type newType = AudioEventAction.ActionEnumToType(currentType.ActionType); var enumType = currentType.ActionType; menu.AddItem(new GUIContent(currentType.Name), false, f => AudioEventWorker.AddEventAction(audioevent, newType, enumType), currentType); } menu.ShowAsContext(); }