After a couple of hours of tackling a nasty bug, I managed to break it all down to one single thing that I can't comprehend.
I have a gameObject character, which has 2 component scripts.
1) StateSwitcher (a class applying the factory design principle: it returns states depending on certain conditions of the character)
2) General State (a class from which all states inherit, which contains general state data and behaviour
My character inspector looks like this:
As you can see, I assigned the StateSwitcher to GeneralState by simply selecting it in the inspector view.
This is what GeneralState.cs look like:
// This class contains all fields, properties & methods shared across all states
public class GeneralState : MonoBehaviour
{
private void Start()
{
Debug.Log(StateSwitcher);
}
}
This is what baffles me:
edit 1:
// This class contains all fields, properties & methods shared across all states
public class GeneralState : MonoBehaviour
{
private void Start()
{
Debug.Log(StateSwitcher.GetInstanceID());
}
}
Results in this:
edit 2:
// This class contains all fields, properties & methods shared across all states
public class GeneralState : MonoBehaviour
{
private void Start()
{
Debug.Log(this.GetInstanceID());
}
}
results in this: