In my scene, I have an instance of FPSController from the Characters standard assets named player
. The following behavior happens when attempting to remove a script from it:
Component FpsControllerScript = player.GetComponent(typeof(MonoBehaviour));
// prints "UnityStandardAssets.Characters.FirstPerson.FirstPersonController"
Debug.Log(FpsControllerScript.GetType().ToString());
// prints exactly the same thing
Debug.Log(typeof(FirstPersonController).ToString());
// prints "false", wtf???
Debug.Log(FpsControllerScript.GetType() == typeof(FirstPersonController));
// Does nothing
Destroy(player.GetComponent(typeof(FirstPersonController)));
// Destroys script
Destroy(player.GetComponent(FpsControllerScript.GetType()));
Any ideas? This type error doesn’t make any sense.