title: Add script inheriting from scriptableobject to game object
body: <p>I have a script called Weapon.cs, which is a scriptable object.</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public abstract class Weapon : ScriptableObject {
  
  protected Camera _mainCamera;
  protected Transform _weaponTransform;
  protected int _damage;
  protected int _fireRatePerSecond;
  protected bool _isAutomaticWeapon;
  
  protected void FireWeapon()
  {
      //if the weapon is automatic
      if (_isAutomaticWeapon)
      {
          ShootRapidFireOnMouseHold();
      }
      //if the weapon is semi automatic
      else
      {
          ShootSingleBulletOnMouseClick();
      }
  }
  
  protected void MoveWeaponWithCamera(Transform weaponTransform)
  {
      _weaponTransform.rotation = _mainCamera.transform.rotation; //temporary way of making sure the gun moves with the camera
  }
  
  protected void ShootSingleBulletOnMouseClick()
  {
      if (Input.GetKeyDown(KeyCode.Mouse0)) //if left mouse button is clicked
      {
          CastRay();
      }
  }
  
  protected void ShootRapidFireOnMouseHold()
  {
      if (Input.GetKey(KeyCode.Mouse0)) //if left mouse button is held down
      {
          CastRay(); //rapid fire
          //PlayShootAnimation();
      }
  }
  
  protected void CastRay()
  {
      RaycastHit hit;
      if (Physics.Raycast(_mainCamera.transform.position, _mainCamera.transform.forward, out hit, 100))
      {
          Debug.Log(hit.transform.name);
      }
  }
  //protected abstract void PlayShootAnimation();
  }
  </code></pre>
  
  <p>I have a second script called MachineGun.cs, which inherits from Weapon.cs, and thus indirectly from scriptable object.</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class MachineGun : Weapon{
  
  private GameObject _machineGunBarrel;
  
  //private float _animationVelocity;
  
  // Use this for initialization
  void Start () {
      //initialize the basic properties of a weapon
      _damage = 7;
      _fireRatePerSecond = 10;
      _isAutomaticWeapon = true;
  
      _weaponTransform = GameObject.Find("Weapon_MachineGun").transform;
      _machineGunBarrel = GameObject.Find("machinegun_p1");
  
      _mainCamera = Camera.main;
  
  }
  
  // Update is called once per frame
  void Update () {
      MoveWeaponWithCamera(_weaponTransform);
      FireWeapon();
  }
  
  //protected override void Shoot()
  //{
  //    RaycastHit hit;
  //    if(Physics.Raycast(_mainCamera.transform.position, _mainCamera.transform.forward, out hit, 100))
  //    {
  //        Debug.Log(hit.transform.name);
  //    }
  //}
  
  void PlayShootAnimation()
  {
      _machineGunBarrel.transform.RotateAround(_machineGunBarrel.transform.up, _fireRatePerSecond * Time.deltaTime);
      PlayShootAnimation(); //play the shoot animation of the gun
  }
  }
  </code></pre>
  
  <p>It's currently impossible, since MachineGun.cs doesn't inherit from monobehaviour anymore.</p>
  
  <p>I have a weapon gameobject in my scene, and so here's my question:
  How do I go about adding the MachineGun.cs script as a component to my weapon gameobject? Or since this is impossible,</p>
  
  <p><strong>How should I build a weapon system with a general Weapon.cs script from which all weapons can inherit basic functions and fields/variables?</strong></p>
  
  <p>EDIT 1: provided code to my post and added the "why I wanna do this".</p>
  
  <p>Thanks in advance!</p>