Beispiel #1
0
 /// <summary>
 /// Post all actions in this event in accordance to the data specified in the inspector, but overrides another place to fire the sound from
 /// </summary>
 /// <param name="controllingObject">The controlling game object and the future parent of the audio files</param>
 /// <param name="eventList">All the events to post as added in the inspector</param>
 /// <param name="postAt">The new position to play at</param>
 public static void PostEventAtPosition(GameObject controllingObject, InAudioEvent eventList, Vector3 postAt)
 {
     if (instance != null && controllingObject != null && eventList != null && eventList.Events != null)
     {
         int count = eventList.Events.Count;
         for (int i = 0; i < count; i++)
         {
             EventHookListData eventData = eventList.Events[i];
             if (eventData != null && eventData.Event != null)
             {
                 instance.OnPostEvent(controllingObject, eventData.Event, postAt);
             }
         }
     }
     else
     {
         if (instance == null)
         {
             InDebug.InAudioInstanceMissing(controllingObject);
         }
         else if (controllingObject == null)
         {
             InDebug.MissingControllingObject();
         }
         else if (eventList == null || eventList.Events == null)
         {
             InDebug.MissingEventList(controllingObject);
         }
     }
 }
Beispiel #2
0
        public static bool HandleEventDrag(InAudioEvent audioEvent)
        {
            if (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform)
            {
                bool canDropObject = true;
                int  clipCount     = DragAndDrop.objectReferences.Count(obj =>
                {
                    var inEvent = obj as InAudioEventNode;
                    if (inEvent == null)
                    {
                        return(false);
                    }
                    return(inEvent.Type == EventNodeType.Event);
                });

                if (clipCount != DragAndDrop.objectReferences.Length || clipCount == 0)
                {
                    canDropObject = false;
                }

                if (canDropObject)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
                    if (Event.current.type != EventType.DragPerform)
                    {
                        Event.current.Use();
                    }

                    if (Event.current.type == EventType.DragPerform)
                    {
                        audioEvent.Add(DragAndDrop.objectReferences[0] as InAudioEventNode, EventHookListData.PostEventAt.AttachedTo);
                        GUI.changed = true;
                        Event.current.Use();
                        return(true);
                    }
                }
                else
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.None;
                }
            }
            return(false);
        }
Beispiel #3
0
 /// <summary>
 /// Post all actions in this event in accordance to the data specified in the inspector, but overrides which object is it attached to.
 /// </summary>
 /// <param name="controllingObject">The controlling game object and the future parent of the audio files</param>
 /// <param name="eventList">All the events to post as added in the inspector</param>
 /// <param name="attachedToOther">The object to attach the events to</param>
 public static void PostEventAttachedTo(GameObject controllingObject, InAudioEvent eventList, GameObject attachedToOther)
 {
     if (instance != null && controllingObject != null && eventList != null && eventList.Events != null)
     {
         int     count    = eventList.Events.Count;
         Vector3 position = controllingObject.transform.position;
         for (int i = 0; i < count; i++)
         {
             EventHookListData eventData = eventList.Events[i];
             if (eventData != null && eventData.Event != null)
             {
                 if (eventData.PostAt == EventHookListData.PostEventAt.AttachedTo)
                 {
                     instance.OnPostEvent(controllingObject, eventData.Event, attachedToOther);
                 }
                 else //if post at position
                 {
                     instance.OnPostEvent(controllingObject, eventData.Event, position);
                 }
             }
         }
     }
     else
     {
         if (instance == null)
         {
             InDebug.InAudioInstanceMissing(controllingObject);
         }
         else if (controllingObject == null)
         {
             InDebug.MissingControllingObject();
         }
         else if (eventList == null || eventList.Events == null)
         {
             InDebug.MissingEventList(controllingObject);
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// Post all actions in this event in accordance to the data specified in the inspector, but overrides another place to fire the sound from
 /// </summary>
 /// <param name="controllingObject">The controlling game object and the future parent of the audio files</param>
 /// <param name="eventList">All the events to post as added in the inspector</param>
 /// <param name="postAt">The new position to play at</param>
 public static void PostEventAtPosition(GameObject controllingObject, InAudioEvent eventList, Vector3 postAt)
 {
     if (instance != null && controllingObject != null && eventList != null && eventList.Events != null)
     {
         int count = eventList.Events.Count;
         for (int i = 0; i < count; i++)
         {
             EventHookListData eventData = eventList.Events[i];
             if (eventData != null && eventData.Event != null)
             {
                 instance.OnPostEvent(controllingObject, eventData.Event, postAt);
             }
         }
     }
     else
     {
         if (instance == null)
             InDebug.InAudioInstanceMissing(controllingObject);
         else if (controllingObject == null)
         {
             InDebug.MissingControllingObject();
         }
         else if (eventList == null || eventList.Events == null)
         {
             InDebug.MissingEventList(controllingObject);
         }
     }
 }
Beispiel #5
0
    /// <summary>
    /// Post all actions in this event in accordance to the data specified in the inspector, but overrides which object is it attached to.
    /// </summary>
    /// <param name="controllingObject">The controlling game object and the future parent of the audio files</param>
    /// <param name="eventList">All the events to post as added in the inspector</param>
    /// <param name="attachedToOther">The object to attach the events to</param>
    public static void PostEventAttachedTo(GameObject controllingObject, InAudioEvent eventList, GameObject attachedToOther)
    {
        if (instance != null && controllingObject != null && eventList != null && eventList.Events != null)
        {
            int count = eventList.Events.Count;
            Vector3 position = controllingObject.transform.position;
            for (int i = 0; i < count; i++)
            {
                EventHookListData eventData = eventList.Events[i];
                if (eventData != null && eventData.Event != null)
                {
                    if (eventData.PostAt == EventHookListData.PostEventAt.AttachedTo)
                        instance.OnPostEvent(controllingObject, eventData.Event, attachedToOther);
                    else //if post at position
                        instance.OnPostEvent(controllingObject, eventData.Event, position);
                }
            }

        }
        else
        {
            if (instance == null)
                InDebug.InAudioInstanceMissing(controllingObject);
            else if (controllingObject == null)
            {
                InDebug.MissingControllingObject();
            }
            else if (eventList == null || eventList.Events == null)
            {
                InDebug.MissingEventList(controllingObject);
            }
        }
    }