How to expose script properties in C# ?

The documentation seems to contradict.

First it says that all behaviour scripts must derive from MonoBehaviour. Then it says that in order to display variables in the inspector, "you need create a class that derives from System.Object". How is it possible to do both? Am I misunderstanding what a "behaviour script" is? I thought it was a script that you attach to a game object.

everything is derived from System.Object so there is no problem outthere. MonoBehaviours are derived from System.Object too.

yes a Behaviour is a script that can be attached to a gameObject and become enabled/disabled and receive events and ...

just declare your variables public and derive from MonoBehaviour then the variables will be exposed. some types of variables don't have default inspectors so without writing editor scripts you can not show them. ulong for example can not be exposed. also keep in mind that properties like public int something {get;set} can not be exposed (pure variables only).

Hi,

Not 100% sure I understand your question, but [SerializeField] seems to be what you're looking for:

using UnityEngine;
using System.Collections;

public class NewScript : MonoBehaviour {

[SerializeField]
private NewScript myNewScript = new NewScript();
}

Simply make your variables public like so...

using UnityEngine;
using System.Collections;

public class NewScript : MonoBehaviour
{
    public GameObject myGameObject;
}

On your script in the inspector then you can drag the relevant gameObject to populate the variable.