title: Why is Unity throwing an error"The script dont inherit a native class that can manage" if class and file name are the same and inherit MonoBehaviour?
body: <p>Recently started studying the book &quot;Mobile Game Development with Unity&quot; by John Manning and there was a problem with the code.</p>
  <p>Unity keeps throwing this error when trying to add a component.
  <strong>&quot;The script dont inherit a native class that can manage&quot;</strong></p>
  <p>Here is the code itself. The name of the class and the code are the same. I've been digging the Internet for several hours and just can't find a solution.</p>
  <p>The code was attached to the book and it also gives an error when added.</p>
  <pre><code>using UnityEngine;
  
  [RequireComponent (typeof(SpriteRenderer))]
  public class BodyPart: MonoBehaviour
  {
      public Sprite detachedSprite;
      public Sprite burnedSprite;
      public Transform bloodFountainOrigin;
      bool detached = false;
      public void Detach()
      {
          detached = true;
          this.tag = &quot;Untagged&quot;;
          transform.SetParent(null, true);
      }
      public void Update()
      {
          if (detached == false)
          {
              return;
          }
          var rigidbody = GetComponent&lt;Rigidbody2D&gt;();
          if (rigidbody.IsSleeping())
          {
              foreach (Joint2D joint in GetComponentsInChildren&lt;Joint2D&gt;())
              {
                  Destroy(joint);
              }
              foreach (Rigidbody2D body in GetComponentsInChildren&lt;Rigidbody2D&gt;())
              {
                  Destroy(body);
              }
              foreach (Collider2D collider in GetComponentsInChildren&lt;Collider2D&gt;())
              {
                  Destroy(collider);
              }
              Destroy(this);
          }
      }
      public void ApplyDamageSprite(Gnome.DamageType damageType)
      {
          Sprite spriteToUse = null;
          switch (damageType)
          {
              case Gnome.DamageType.Burning:
                  spriteToUse = burnedSprite;
                  break;
              case Gnome.DamageType.Slicing:
                  spriteToUse = detachedSprite;
                  break;
          }
          if (spriteToUse != null)
          {
              GetComponent&lt;SpriteRenderer&gt;().sprite = spriteToUse;
          }
      }
  }
  </code></pre>