Making a public member on a class that inherits from MonoBehaviour will allow me to set that member per instance of the component for objects I place in the editor.
However, making such a member of a type that isn’t a value type (IE: Material, GameObject, Mesh, etc.) will make a similar box show up in the script view.
What does this box do?
Those are called “default references”. All reference types (which can be serialized by Unity) will show up in this list on the script itself. It allows you to setup default references to assets which are automatically assigned when you create an instance of that class in the editor.
Here are some limitations:
- If you change the default references after you attached the script to a GameObject, nothing will happen. The default references only apply to instances which are created afterwards.
It only works in the editor. So using AddComponent at runtime won’t assign those default references.
- Since those references are stored along with the script asset, you can only reference other assets. It’s not possible to assign a reference to an instance in a scene since those are only available while the scene is loaded.
It’s like with any value type, you can drag or select an object of the same type of the variable in the inspector and you can access that object in the script. In your screen shot you can drag any Material from your project or click on the circle at the right and select one material of a list of all materials in your project.
For a GameObject reference you can drag any game object in your hierarchy or any prefab in your project.
If you add a variable of a Type that is a component you can drag any gameobject that has at least one component of that type, and the variable will reference that component on that game object inside the script.
This is really really basic, you should follow some of the official tutorials and read the official Unity manual (Unity - Manual: Unity User Manual 2021.3 (LTS)) to get some idea of how to use Unity, there are some stuff that are not that straightforward.