How do I make character rigs and animations adapt to the environment?

In Unity, I know I can import character animations from external software (I use blender). When animations are played in unity, it plays exactly how it was animated in Blender. How do I make characters’ animations change in unity due to the environment. For example, a character has a walking animation and is walking on a slope and then stops on a slope. Its idle animation (and walking animation) would have the character’s feet in line as if it was standing/walking on flat ground. How would I make the character’s feet and legs be at an angle as if the character was standing on a slope? Do I have to make an exact animation for the character walking on the slope or is there some way in unity to do what I want to achieve? (If I need to mention, I prefer c# over javascript)

Research IK for the purposes you are looking to achieve.
(Inverse Kinematics)

There are also some quality character controllers on the asset store which could provide some very helpful information on this subject. Consider researching some of them.