How Do You Add A Mono Behavior Component to a Game Object?

As in the title. Thanks!

Dragging the script from the project window onto a selected object will do it. You can also add these components to the window menu for convenience, using [AddComponentMenu("path_here’)] in your scripts. Behaviours can be added procedurally too. Lots of ways!

So to be really clear on the simplest way to add a component:

  1. Find the script you want in your project browser.
  2. Select the gameobject you want to add the script to from your scene. It will appear in your inspector window.
  3. Drag the script onto the view of the gameobject in the inspector.

That’s it. As mentioned elsewhere, you can also add components procedurally but based on your comments that’s something for you to think about when you are more familiar with Unity.

Hmm. OK. Thanks. The reason I ask basically is because I inherited a Unity project and wasn’t sure how the original engineer for the project did it. Still not sure I follow from these answers, but I’ll give it another go.

Hmm. The thing that confuses me is that for the ‘Mono Behavior’ component that I’m trying to emulate it says that there is no script associated with it: Missing (Mono Script). So still at a loss unfortunately. Any ideas would be greatly appreciated. I’ve been able to create scripts and associate them with GameObjects, but I am still really unsure of how to associate this ‘Mono Behavior’ component with a new GameObject that I create.

Thanks a ton.