How to access the interface from the last component in the inspector

126537-capture.pngIn the State Machine script I am trying to access the IState interface from PlayerAirborneState (the last compoenent in the inspector). Here’s my code. AccessAirborneInterface, C# - rextester
This however accesses the IState interface that is implemented in the top most component that implements IState. And I know this because I ran Debug.Log(airborne); and it outputted "Player (PlayerWalkState)"126538-capture2.png
For debugging, I tried moving the airborne state component to the top and got the output “Player (PlayerAirborneState)”. So I think Unity is just taking the first component that implements IState and using that.

How can I access the IState Interface from the PlayerAirborneState component without switching the order of components in the inspector?

To get the last component, you can simply do this.

IState[] states = GetComponents<IState>();
IState lastState = states[states.Length-1];

Although, looking at your code, you may assign the component itself, as IState

playerAirborneStateScript = GetComponent<PlayerAirborneState>();
airborne = playerAirborneStateScript as IState; // or
airborne = (IState) playerAirborneStateScript;

Something like this perhaps?

using System.Linq;

var states = GetComponents<IState>();
var airborneState = states.First(f => f.GetType().ToString().Contains("Airborne"));