private void FindMixers(Playable parent, int port, Playable node)
 {
     if (node.IsValid <Playable>())
     {
         Type playableType = node.GetPlayableType();
         if (playableType == typeof(AnimationMixerPlayable) || playableType == typeof(AnimationLayerMixerPlayable))
         {
             int inputCount = node.GetInputCount <Playable>();
             for (int i = 0; i < inputCount; i++)
             {
                 this.FindMixers(node, i, node.GetInput(i));
             }
             AnimationOutputWeightProcessor.WeightInfo item = new AnimationOutputWeightProcessor.WeightInfo
             {
                 parentMixer = parent,
                 mixer       = node,
                 port        = port,
                 modulate    = (playableType == typeof(AnimationLayerMixerPlayable))
             };
             this.m_Mixers.Add(item);
         }
         else
         {
             int inputCount2 = node.GetInputCount <Playable>();
             for (int j = 0; j < inputCount2; j++)
             {
                 this.FindMixers(parent, port, node.GetInput(j));
             }
         }
     }
 }
예제 #2
0
            private static void GetPlayableBehaviours <T>(Playable root, ref List <T> playables) where T : class
            {
                int inputCount = root.GetInputCount();

                for (int i = 0; i < inputCount; i++)
                {
                    Playable node = root.GetInput(i);

                    if (node.IsValid())
                    {
                        Type playableType = node.GetPlayableType();

                        if (SystemUtils.IsTypeOf(typeof(T), playableType))
                        {
                            T playable = GetPlayableBehaviour(node, playableType) as T;

                            if (playable != null)
                            {
                                playables.Add(playable);
                            }
                        }

                        GetPlayableBehaviours(node, ref playables);
                    }
                }
            }
    public override Type GetContentType()
    {
        Playable p = Playable.Null;

        try
        {
            p = ((Playable)content);
        }
        catch
        {
            // Ignore.
        }
        return(!p.IsValid() ? null : p.GetPlayableType());
    }
예제 #4
0
        private PlayableNode CreateNodeFromPlayable(Playable h, float weight)
        {
            var type = h.GetPlayableType();

            if (type == typeof(AnimationClipPlayable))
            {
                return(new AnimationClipPlayableNode(h, weight));
            }
            if (type == typeof(AnimationLayerMixerPlayable))
            {
                return(new AnimationLayerMixerPlayableNode(h, weight));
            }
            return(new PlayableNode(h, weight));
        }
        public override Type GetContentType()
        {
            Playable p = Playable.Null;

            try
            {
                p = (Playable)content;
            }
            catch
            {
                // Ignore.
            }

            return(p.IsValid() ? p.GetPlayableType() : null);
        }
        // Recursively accumulates mixers.
        void FindMixers(Playable parent, int port, Playable node)
        {
            if (!node.IsValid())
            {
                return;
            }

            var type = node.GetPlayableType();

            if (type == typeof(AnimationMixerPlayable) || type == typeof(AnimationLayerMixerPlayable))
            {
                // use post fix traversal so children come before parents
                int subCount = node.GetInputCount();
                for (int j = 0; j < subCount; j++)
                {
                    FindMixers(node, j, node.GetInput(j));
                }

                // if we encounter a layer mixer, we assume there is nesting occuring
                //  and we modulate the weight instead of overwriting it.
                var weightInfo = new WeightInfo
                {
                    parentMixer = parent,
                    mixer       = node,
                    port        = port,
                    modulate    = (type == typeof(AnimationLayerMixerPlayable))
                };
                m_Mixers.Add(weightInfo);
            }
            else
            {
                var count = node.GetInputCount();
                for (var i = 0; i < count; i++)
                {
                    FindMixers(parent, port, node.GetInput(i));
                }
            }
        }
예제 #7
0
 public static IEnumerable <T> EnumerateBehaviours <T>(Playable playable) where T : class, IPlayableBehaviour, new()
 {
     //IL_0008: Unknown result type (might be due to invalid IL or missing references)
     //IL_0009: Unknown result type (might be due to invalid IL or missing references)
     if (PlayableExtensions.IsValid <Playable>(playable))
     {
         int inputCount = PlayableExtensions.GetInputCount <Playable>(playable);
         int num;
         for (int inputIndex = 0; inputIndex < inputCount; inputIndex = num)
         {
             Playable input = PlayableExtensions.GetInput <Playable>(playable, inputIndex);
             foreach (T item in EnumerateBehaviours <T>(input))
             {
                 yield return(item);
             }
             num = inputIndex + 1;
         }
         if (playable.GetPlayableType() == typeof(T))
         {
             yield return(((ScriptPlayable <T>)playable).GetBehaviour());
         }
     }
 }
예제 #8
0
            private static PlayableBehaviour GetTrackMixer(Playable root, TrackAsset track, Type type)
            {
                int inputCount = root.GetOutputCount();

                for (int i = 0; i < inputCount; i++)
                {
                    Playable rootInput = root.GetOutput(i);

                    if (rootInput.IsValid())
                    {
                        //If this input is a T, check it matches our track
                        if (rootInput.GetPlayableType() is ITrackMixer)
                        {
                            PlayableBehaviour playableBehaviour = GetPlayableBehaviour(rootInput, type);
                            ITrackMixer       trackMixer        = playableBehaviour as ITrackMixer;

                            if (trackMixer != null && trackMixer.GetTrackAsset() == track)
                            {
                                return(playableBehaviour);
                            }
                        }

                        //Otherwise search this playable's inputs
                        {
                            PlayableBehaviour trackMixer = GetTrackMixer(rootInput, track, type);

                            if (trackMixer != null)
                            {
                                return(trackMixer);
                            }
                        }
                    }
                }

                return(null);
            }
예제 #9
0
            private static T GetTrackMixer <T>(Playable root, TrackAsset track) where T : class, IPlayableBehaviour, ITrackMixer, new()
            {
                int inputCount = root.GetOutputCount();

                for (int i = 0; i < inputCount; i++)
                {
                    Playable rootInput = root.GetOutput(i);

                    if (rootInput.IsValid())
                    {
                        //If this input is a T, check it matches our track
                        if (rootInput.GetPlayableType() == typeof(T))
                        {
                            ScriptPlayable <T> scriptPlayable = (ScriptPlayable <T>)rootInput;
                            T trackMixer = scriptPlayable.GetBehaviour();

                            if (trackMixer.GetTrackAsset() == track)
                            {
                                return(trackMixer);
                            }
                        }

                        //Otherwise search this playable's inputs
                        {
                            T trackMixer = GetTrackMixer <T>(rootInput, track);

                            if (trackMixer != null)
                            {
                                return(trackMixer);
                            }
                        }
                    }
                }

                return(null);
            }
예제 #10
0
    public override Type GetContentType()
    {
        Playable p = GetPlayable();

        return(!p.IsValid() ? null : p.GetPlayableType());
    }
예제 #11
0
            public static bool IsPlayableOfType(Playable playable, Type type)
            {
                Type playableType = playable.GetPlayableType();

                return(SystemUtils.IsTypeOf(type, playableType));
            }