Example #1
0
 public void Reset()
 {
     _eventName            = "";
     EventAction           = EventAction.PlaySound;
     eventStatus           = EventStatus.Not_Handled;
     parentGameObject      = null;
     _parameter            = null;
     _delay                = 0f;
     _delayTimer           = 0f;
     _initialiseParameters = null;
     _onEventNotify        = null;
     _eventCategory        = null;
     _priority             = 0;
 }
Example #2
0
 public void Copy(Event fromEvent)
 {
     _eventName            = fromEvent._eventName;
     EventAction           = fromEvent.EventAction;
     eventStatus           = fromEvent.eventStatus;
     parentGameObject      = fromEvent.parentGameObject;
     _parameter            = fromEvent._parameter;
     _delay                = fromEvent._delay;
     _delayTimer           = fromEvent._delayTimer;
     _initialiseParameters = fromEvent._initialiseParameters;
     _onEventNotify        = fromEvent._onEventNotify;
     _eventCategory        = fromEvent._eventCategory;
     _priority             = fromEvent._priority;
 }
Example #3
0
 public bool PostEvent(int eventID, EventAction eventAction = EventAction.PlaySound, GameObject parentGameObject = null, object parameter = null, OnEventNotify onEventNotify = null, InitialiseParameters initialiseParameters = null, bool addToQueue = false)
 {
     if (_enable && EventManager.Instance != null)
     {
         return(EventManager.Instance.PostEvent(eventID, eventAction, parameter, parentGameObject, initialiseParameters, addToQueue, onEventNotify));
     }
     return(false);
 }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        // Example 1: Posting an event
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            /////////////////////////////////////////////////////////////
            // This event by default will send the PlaySound EventAction.
            // The gameObject used is the one that has the FabricManager

            Fabric.EventManager.Instance.PostEvent("Simple", gameObject);
        }
        // Example 2: Posting an event with a gameObject
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            /////////////////////////////////////////////////////////////
            // This event by default will send the PlaySound EventAction.
            // The gameObject passed is used to track position and associated with an instance if max instances property is set

            Fabric.EventManager.Instance.PostEvent("Simple", gameObject);
        }
        // Example 3: Posting an event with a PlaySound action and a gameObject
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            Fabric.EventManager.Instance.PostEvent("Simple", Fabric.EventAction.PlaySound, null, gameObject);
        }
        // Example 4: Posting a stop sound event action
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            Fabric.EventManager.Instance.PostEvent("Simple", Fabric.EventAction.StopSound, null, gameObject);
        }
        // Example 5: Posting a timeline SetParameter value
        else if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            Fabric.EventManager.Instance.SetParameter("Timeline", "Parameter", 0.5f, gameObject);
        }
        // Example 6: Posting a SetDSPParameter value
        else if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            Fabric.EventManager.Instance.SetDSPParameter("Event", Fabric.DSPType.LowPass, "CutoffFrequency", 5000, 5, 0.5f, gameObject);
        }
        // Example 7: Adding dynamic mixer preset
        else if (Input.GetKeyDown(KeyCode.Alpha7))
        {
            // The event name must be "DynamicMixer"
            Fabric.EventManager.Instance.PostEvent("DynamicMixer", Fabric.EventAction.AddPreset, "MuteAll", null);
        }
        // Example 8: Removing dynamic mixer preset
        else if (Input.GetKeyDown(KeyCode.Alpha8))
        {
            // The event name must be "DynamicMixer"
            Fabric.EventManager.Instance.PostEvent("DynamicMixer", Fabric.EventAction.RemovePreset, "MuteAll", null);
        }
        // Example 9: Get component by name, setting volume, querying if component is playing and if not play it
        else if (Input.GetKeyDown(KeyCode.Alpha9))
        {
            Fabric.Component component = Fabric.FabricManager.Instance.GetComponentByName("Audio_Fabric_SFX_Test");

            if (component != null)
            {
                component.Volume = 0.5f;

                if (component.IsPlaying() == false)
                {
                    component.Play(gameObject);
                }
            }
        }
        // Loading prefab that has Fabric components into the Fabric hiearchy with a target path
        else if (Input.GetKeyDown(KeyCode.A))
        {
            Fabric.FabricManager.Instance.LoadAsset("NameOfPrefab", "Audio_SFX");
        }
        // Unloading component from the Fabric hiearchy
        else if (Input.GetKeyDown(KeyCode.B))
        {
            Fabric.FabricManager.Instance.UnloadAsset("Audio_SFX");
        }
        // Initialise default component parameters (ideal for setting parameters in animation systems)
        else if (Input.GetKeyDown(KeyCode.C))
        {
            Fabric.InitialiseParameters parameters = new Fabric.InitialiseParameters();

            parameters._pitch.Value = 2.0f;

            Fabric.EventManager.Instance.PostEvent("Simple", Fabric.EventAction.PlaySound, null, gameObject, parameters);
        }
        // Check if an event is playing
        else if (Input.GetKeyDown(KeyCode.D))
        {
            if (Fabric.EventManager.Instance.IsEventActive("Simple", gameObject))
            {
                Debug.Log("Event Simple is Active");
            }
            else
            {
                Debug.Log("Event Simple is Inactive");
            }
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            Fabric.Component[] components = Fabric.FabricManager.Instance.GetComponentsByName("Audio_Simple", gameObject);

            if (components != null && components.Length > 0)
            {
                components[0].Volume = 0.5f;

                if (components[0].IsPlaying() == true)
                {
                    Debug.Log("Component is playing");
                }
            }
        }
    }
Example #5
0
 public bool PostEvent(int eventID, EventAction eventAction, object parameter, GameObject parentGameObject, InitialiseParameters initialiseParameters, bool addToQueue, OnEventNotify onEventNotify)
 {
     if (parentGameObject != null)
     {
         newEvent.parentGameObject = parentGameObject;
     }
     else
     {
         newEvent.parentGameObject = null;
     }
     newEvent._eventID              = eventID;
     newEvent.EventAction           = eventAction;
     newEvent._parameter            = parameter;
     newEvent._initialiseParameters = initialiseParameters;
     newEvent._onEventNotify        = onEventNotify;
     return(PostEventID(newEvent, addToQueue));
 }
Example #6
0
 public bool PostEvent(int eventID, GameObject parentGameObject, InitialiseParameters initialiseParameters)
 {
     return(PostEvent(eventID, EventAction.PlaySound, null, parentGameObject, initialiseParameters, addToQueue: false, null));
 }
Example #7
0
 public bool PostEventNotify(string eventName, GameObject parentGameObject, InitialiseParameters initialiseParameters, OnEventNotify onEventNotify)
 {
     return(PostEvent(eventName, EventAction.PlaySound, null, parentGameObject, initialiseParameters, addToQueue: false, onEventNotify));
 }
Example #8
0
 public bool PostEvent(string eventName, EventAction eventAction, object parameter, GameObject parentGameObject, InitialiseParameters initialiseParameters, bool addToQueue)
 {
     return(PostEvent(eventName, eventAction, parameter, parentGameObject, initialiseParameters, addToQueue, null));
 }