Exemplo n.º 1
0
    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    {
        if (Application.isPlaying)
        {
            PlayableOutput playableOutput = graph.GetOutput(0);

            if (playableOutput.IsOutputValid())
            {
                ScriptPlayable <TimeNotificationBehaviour> scriptPlayable =
                    (ScriptPlayable <TimeNotificationBehaviour>)playableOutput.GetSourcePlayable().GetInput(0);



                TimeNotificationBehaviour timeNotificationBehaviour = scriptPlayable.GetBehaviour();

                var simpleMarkers = this.GetMarkers().OfType <SimpleMarker>();

                m_Receiver = new ReceiverExample();

                playableOutput.AddNotificationReceiver(m_Receiver);

                foreach (var marker in simpleMarkers)
                {
                    scriptPlayable.GetBehaviour().AddNotification(marker.time, marker);
                }
            }
            else
            {
                playableOutput = ScriptPlayableOutput.Create(graph, "NotificationOutput");

                m_Receiver = new ReceiverExample();

                //why also here and in "outputs"
                playableOutput.AddNotificationReceiver(m_Receiver);

                //Create a TimeNotificationBehaviour
                var timeNotificationPlayable = ScriptPlayable <TimeNotificationBehaviour> .Create(graph);

                playableOutput.SetSourcePlayable(graph.GetRootPlayable(0));
                timeNotificationPlayable.GetBehaviour().timeSource = playableOutput.GetSourcePlayable();
                playableOutput.GetSourcePlayable().SetInputCount(playableOutput.GetSourcePlayable().GetInputCount() + 1);
                graph.Connect(timeNotificationPlayable, 0, playableOutput.GetSourcePlayable(), playableOutput.GetSourcePlayable().GetInputCount() - 1);

                var simpleMarkers = this.GetMarkers().OfType <SimpleMarker>();


                foreach (var marker in simpleMarkers)
                {
                    timeNotificationPlayable.GetBehaviour().AddNotification(marker.time, marker);
                }
            }
        }

        return(base.CreateTrackMixer(graph, go, inputCount));
    }
    public override Type GetContentType()
    {
        PlayableOutput p = PlayableOutput.Null;

        try
        {
            p = ((PlayableOutput)content);
        }
        catch
        {
            // Ignore.
        }
        return(!p.IsOutputValid() ? null : p.GetPlayableOutputType());
    }
Exemplo n.º 3
0
        public override Type GetContentType()
        {
            PlayableOutput po = PlayableOutput.Null;

            try
            {
                po = (PlayableOutput)content;
            }
            catch
            {
                // Ignore.
            }

            return(po.IsOutputValid() ? po.GetPlayableOutputType() : null);
        }
    private List <Node> GetInputsFromPlayableOutputNode(PlayableOutput h)
    {
        var inputs = new List <Node>();

        if (h.IsOutputValid())
        {
            Playable playable = h.GetSourcePlayable();
            if (playable.IsValid())
            {
                Node node = CreateNodeFromPlayable(playable, 1);
                inputs.Add(node);
            }
        }
        return(inputs);
    }