Пример #1
0
        public static IAnimationChannel[] ExtractAnimationChannelFromRigComponent(RigComponent rigComponent)
        {
            var channels = new List <IAnimationChannel>();

            for (int i = 0; i < rigComponent.TranslationChannels.Length; i++)
            {
                var channel = new LocalTranslationChannel {
                    Id = rigComponent.TranslationChannels[i].Id, DefaultValue = rigComponent.TranslationChannels[i].DefaultValue
                };
                channels.Add(channel);
            }

            for (int i = 0; i < rigComponent.RotationChannels.Length; i++)
            {
                var channel = new LocalRotationChannel {
                    Id = rigComponent.RotationChannels[i].Id, DefaultValue = rigComponent.RotationChannels[i].DefaultValue
                };
                channels.Add(channel);
            }

            for (int i = 0; i < rigComponent.ScaleChannels.Length; i++)
            {
                var channel = new LocalScaleChannel {
                    Id = rigComponent.ScaleChannels[i].Id, DefaultValue = rigComponent.ScaleChannels[i].DefaultValue
                };
                channels.Add(channel);
            }

            for (int i = 0; i < rigComponent.FloatChannels.Length; i++)
            {
                var channel = new Unity.Animation.FloatChannel {
                    Id = rigComponent.FloatChannels[i].Id, DefaultValue = rigComponent.FloatChannels[i].DefaultValue
                };
                channels.Add(channel);
            }

            for (int i = 0; i < rigComponent.IntChannels.Length; i++)
            {
                var channel = new Unity.Animation.IntChannel {
                    Id = rigComponent.IntChannels[i].Id, DefaultValue = rigComponent.IntChannels[i].DefaultValue
                };
                channels.Add(channel);
            }

            return(channels.ToArray());
        }
        public static IAnimationChannel[] ExtractAnimationChannelsFromClips(BlobAssetReference <Clip>[] clips)
        {
            var animationChannels = new List <IAnimationChannel>();

            for (var i = 0; i < clips.Length; ++i)
            {
                var     clip         = clips[i];
                ref var clipBindings = ref clip.Value.Bindings;

                // Translations.
                for (var j = 0; j < clipBindings.TranslationBindings.Length; ++j)
                {
                    var channel = new LocalTranslationChannel {
                        Id = clipBindings.TranslationBindings[j]
                    };
                    if (!animationChannels.Contains(channel))
                    {
                        animationChannels.Add(channel);
                    }
                }

                // Rotations.
                for (var j = 0; j < clipBindings.RotationBindings.Length; ++j)
                {
                    var channel = new LocalRotationChannel {
                        Id = clipBindings.RotationBindings[j]
                    };
                    if (!animationChannels.Contains(channel))
                    {
                        animationChannels.Add(channel);
                    }
                }

                // Scales.
                for (var j = 0; j < clipBindings.ScaleBindings.Length; ++j)
                {
                    var channel = new LocalScaleChannel {
                        Id = clipBindings.ScaleBindings[j]
                    };
                    if (!animationChannels.Contains(channel))
                    {
                        animationChannels.Add(channel);
                    }
                }

                // Floats.
                for (var j = 0; j < clipBindings.FloatBindings.Length; ++j)
                {
                    var channel = new FloatChannel {
                        Id = clipBindings.FloatBindings[j]
                    };
                    if (!animationChannels.Contains(channel))
                    {
                        animationChannels.Add(channel);
                    }
                }

                // Intergers.
                for (var j = 0; j < clipBindings.IntBindings.Length; ++j)
                {
                    var channel = new IntChannel {
                        Id = clipBindings.IntBindings[j]
                    };
                    if (!animationChannels.Contains(channel))
                    {
                        animationChannels.Add(channel);
                    }
                }
            }