public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    {
#if UNITY_EDITOR
        if (!string.IsNullOrEmpty(eventName))
#else
        if (!cachedParameters && !string.IsNullOrEmpty(eventName))
#endif
        {
            FMOD.Studio.EventDescription eventDescription;
            FMODUnity.RuntimeManager.StudioSystem.getEvent(eventName, out eventDescription);
            for (int i = 0; i < parameters.Length; i++)
            {
                FMOD.Studio.PARAMETER_DESCRIPTION parameterDescription;
                eventDescription.getParameterDescriptionByName(parameters[i].Name, out parameterDescription);
                parameters[i].ID = parameterDescription.id;
            }
            cachedParameters = true;
        }

        var playable = ScriptPlayable <FMODEventPlayableBehavior> .Create(graph, template);

        behavior = playable.GetBehaviour();

        behavior.TrackTargetObject = TrackTargetObject;
        behavior.eventName         = eventName;
        behavior.stopType          = stopType;
        behavior.parameters        = parameters;
        behavior.OwningClip        = OwningClip;

        return(playable);
    }
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
#if UNITY_EDITOR
        /*
         * Process frame is called from OnGUI() when auditioning.
         * Check playing to avoid retriggering sounds while scrubbing or repainting.
         * Check IsQuitting to avoid accessing the RuntimeManager during the Play-In-Editor to Editor transition.
         */
        bool playing = playable.GetGraph().IsPlaying();
        if (!playing)
        {
            return;
        }
        /* When auditioning manually update the StudioSystem in place of the RuntimeManager. */
        if (!Application.isPlaying)
        {
            FMODUnity.RuntimeManager.StudioSystem.update();
        }
#endif //UNITY_EDITOR

        int   inputCount = playable.GetInputCount();
        float time       = (float)playable.GetGraph().GetRootPlayable(0).GetTime();

        for (int i = 0; i < inputCount; i++)
        {
            ScriptPlayable <FMODEventPlayableBehavior> inputPlayable = (ScriptPlayable <FMODEventPlayableBehavior>)playable.GetInput(i);
            FMODEventPlayableBehavior input = inputPlayable.GetBehaviour();

            input.UpdateBehaviour(time);
        }
    }
示例#3
0
    public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    {
        var playable = ScriptPlayable <FMODEventPlayableBehavior> .Create(graph, template);

        FMODEventPlayableBehavior behavior = playable.GetBehaviour();

        behavior.TrackTargetObject = TrackTargetObject;
        behavior.eventName         = eventName;
        behavior.stopType          = stopType;
        behavior.parameters        = parameters;
        behavior.OwningClip        = OwningClip;

        return(playable);
    }