Ejemplo n.º 1
0
 void Update()
 {
     if (Input.GetKeyUp(KeyCode.Space))
     {
         director.Stop();
         director.time = 0d;
         director.Play();
     }
     if (Input.GetKeyUp(KeyCode.F1))
     {
         var output             = ScriptPlayableOutput.Create(director.playableGraph, "");
         JumpSignalEmmiter sign = ScriptableObject.CreateInstance <JumpSignalEmmiter>();
         sign.jumpTime = 0;
         output.PushNotification(Playable.Null, sign);
     }
     if (Input.GetKeyUp(KeyCode.F3))
     {
         director.Pause();
         backward = true;
     }
     if (Input.GetKeyUp(KeyCode.F4))
     {
         backward = false;
         director.Play();
     }
     if (backward)
     {
         director.time = director.time - Time.deltaTime;
         director.Evaluate();
     }
 }
    private static PlayableGraph CreatePlayableGraph(string name)
    {
        var graph = PlayableGraph.Create(name);

        ScriptPlayableOutput.Create(graph, "output");
        return(graph);
    }
Ejemplo n.º 3
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));
    }
Ejemplo n.º 4
0
 void Update()
 {
     if (Input.GetKeyUp(KeyCode.F1))
     {
         var output = ScriptPlayableOutput.Create(director.playableGraph, "");
         output.AddNotificationReceiver(this);
         JumpSignalEmmiter sign = ScriptableObject.CreateInstance <JumpSignalEmmiter>();
         sign.jumpTime = 0;
         output.PushNotification(Playable.Null, sign);
     }
 }
    void Start()
    {
        m_Graph = PlayableGraph.Create("NotificationGraph");
        var output = ScriptPlayableOutput.Create(m_Graph, "NotificationOutput");

        //Create and register a receiver
        m_Receiver = new ReceiverExample();
        output.AddNotificationReceiver(m_Receiver);

        //Push a notification on the output
        output.PushNotification(Playable.Null, new MyNotification());

        m_Graph.Play();
    }
Ejemplo n.º 6
0
        private void CreateTrackOutput(PlayableGraph graph, TrackAsset track, Playable playable, int port)
        {
            if (!track.isSubTrack)
            {
                IEnumerable <PlayableBinding> outputs = track.outputs;
                foreach (PlayableBinding binding in outputs)
                {
                    switch (binding.streamType)
                    {
                    case DataStreamType.Animation:
                    {
                        AnimationPlayableOutput animationPlayableOutput = AnimationPlayableOutput.Create(graph, binding.streamName, null);
                        TimelinePlayable.SetPlayableOutputParameters <AnimationPlayableOutput>(animationPlayableOutput, playable, port, binding);
                        this.EvaluateWeightsForAnimationPlayableOutput(track, animationPlayableOutput);
                        break;
                    }

                    case DataStreamType.Audio:
                    {
                        AudioPlayableOutput output = AudioPlayableOutput.Create(graph, binding.streamName, null);
                        TimelinePlayable.SetPlayableOutputParameters <AudioPlayableOutput>(output, playable, port, binding);
                        break;
                    }

                    case DataStreamType.Texture:
                        goto IL_B8;

                    case DataStreamType.None:
                    {
                        ScriptPlayableOutput output2 = ScriptPlayableOutput.Create(graph, binding.streamName);
                        TimelinePlayable.SetPlayableOutputParameters <ScriptPlayableOutput>(output2, playable, port, binding);
                        break;
                    }

                    default:
                        goto IL_B8;
                    }
                    continue;
IL_B8:
                    throw new NotImplementedException("Unsupported stream type");
                }
            }
        }
    void Start()
    {
        m_Graph = PlayableGraph.Create("NotificationGraph");
        var output = ScriptPlayableOutput.Create(m_Graph, "NotificationOutput");

        //Create and register a receiver
        m_Receiver = new ReceiverExample();
        output.AddNotificationReceiver(m_Receiver);

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

        output.SetSourcePlayable(timeNotificationPlayable);

        //Add a notification on the time notification behaviour
        var notificationBehaviour = timeNotificationPlayable.GetBehaviour();

        notificationBehaviour.AddNotification(2.0, new MyNotification());

        m_Graph.Play();
    }
Ejemplo n.º 8
0
    public static int Create_s(IntPtr l)
    {
        int result;

        try
        {
            PlayableGraph graph;
            LuaObject.checkValueType <PlayableGraph>(l, 1, out graph);
            string name;
            LuaObject.checkType(l, 2, out name);
            ScriptPlayableOutput scriptPlayableOutput = ScriptPlayableOutput.Create(graph, name);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, scriptPlayableOutput);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Ejemplo n.º 9
0
 private void CreateTrackOutput(PlayableGraph graph, TrackAsset track, Playable playable, int port)
 {
     if (!track.isSubTrack)
     {
         IEnumerable <PlayableBinding> outputs = track.get_outputs();
         foreach (PlayableBinding current in outputs)
         {
             if (current.get_streamType() == null)
             {
                 AnimationPlayableOutput animationPlayableOutput = AnimationPlayableOutput.Create(graph, current.get_streamName(), null);
                 PlayableOutputExtensions.SetReferenceObject <AnimationPlayableOutput>(animationPlayableOutput, current.get_sourceObject());
                 PlayableOutputExtensions.SetSourcePlayable <AnimationPlayableOutput, Playable>(animationPlayableOutput, playable);
                 PlayableOutputExtensions.SetSourceInputPort <AnimationPlayableOutput>(animationPlayableOutput, port);
                 this.m_EvaluateCallbacks.Add(new AnimationOutputWeightProcessor(animationPlayableOutput));
             }
             else if (current.get_streamType() == 1)
             {
                 AudioPlayableOutput audioPlayableOutput = AudioPlayableOutput.Create(graph, current.get_streamName(), null);
                 PlayableOutputExtensions.SetReferenceObject <AudioPlayableOutput>(audioPlayableOutput, current.get_sourceObject());
                 PlayableOutputExtensions.SetSourcePlayable <AudioPlayableOutput, Playable>(audioPlayableOutput, playable);
                 PlayableOutputExtensions.SetSourceInputPort <AudioPlayableOutput>(audioPlayableOutput, port);
             }
             else
             {
                 if (current.get_streamType() != 3)
                 {
                     throw new NotImplementedException("Unsupported stream type");
                 }
                 ScriptPlayableOutput scriptPlayableOutput = ScriptPlayableOutput.Create(graph, current.get_streamName());
                 PlayableOutputExtensions.SetReferenceObject <ScriptPlayableOutput>(scriptPlayableOutput, current.get_sourceObject());
                 PlayableOutputExtensions.SetSourcePlayable <ScriptPlayableOutput, Playable>(scriptPlayableOutput, playable);
                 PlayableOutputExtensions.SetSourceInputPort <ScriptPlayableOutput>(scriptPlayableOutput, port);
             }
         }
     }
 }
Ejemplo n.º 10
0
        private void InitialiseBindings(AnimancerPlayable root)
        {
            if (_HasInitialisedBindings || _Bindings == null || root == null)
            {
                return;
            }

            _HasInitialisedBindings = true;

            var bindingCount = _Bindings.Count;

            if (bindingCount == 0)
            {
                return;
            }

            var output = _Asset.outputs.GetEnumerator();
            var graph  = root._Graph;

            for (int i = 0; i < bindingCount; i++)
            {
                if (!output.MoveNext())
                {
                    return;
                }

                var binding = _Bindings[i];
                if (binding == null)
                {
                    continue;
                }

                var name = output.Current.streamName;

#if UNITY_2018_2_OR_NEWER
                var type = output.Current.outputTargetType;
#else
                var type = output.Current.sourceBindingType;
                if (output.Current.streamType == DataStreamType.Animation)
                {
                    type = typeof(Animator);
                }
#endif

#if UNITY_ASSERTIONS
                if (type != null && !type.IsAssignableFrom(binding.GetType()))
                {
                    Debug.LogError(string.Concat(
                                       "Binding Type Mismatch: bindings[", i.ToString(), "] is '",
                                       binding.ToString(), "' but should be a ", type.FullName,
                                       " for ", name));
                    continue;
                }
#endif

                var playable = _Playable.GetInput(i);

                if (type == typeof(Animator))
                {
                    var playableOutput = AnimationPlayableOutput.Create(graph, name, (Animator)binding);
                    playableOutput.SetSourcePlayable(playable);
                }
                else if (type == typeof(AudioSource))
                {
                    var playableOutput = AudioPlayableOutput.Create(graph, name, (AudioSource)binding);
                    playableOutput.SetSourcePlayable(playable);
                }
                else// ActivationTrack, SignalTrack, ControlTrack, PlayableTrack.
                {
                    var playableOutput = ScriptPlayableOutput.Create(graph, name);
                    playableOutput.SetUserData(binding);
                    playableOutput.SetSourcePlayable(playable);
                }
            }
        }