Object accecable from all scenes

I new to unity and I am wondering if It is possible to create an object(not derived from MonoBehavior perse) that doesn’t get destroyed when another scene is loaded.
I want to be able to access the player’s total score among other things. But if I construct an object within a scene, it is gone when the next scene is loaded, right?

You should use somehing like this:

function Awake () {
    DontDestroyOnLoad (transform.gameObject);
}

Thanks, so that object doesn’t get destroyed when I load a new scene.
But what happens if I load the original scene again after that? Will that object be newly created because the create script is run again?

yupp it will.
The solution is to first check if an instance of this class already exists

function Awake () {
  if (FindObjectsOfType(thisScriptsName).Length > 1)
  {
    DestroyImmediate(gameObject)
  } else {
    DontDestroyOnLoad (gameObject);
  }

}

I would also consider moving the dontdestroy etc up here from awake to start, that way you can be assured that all objects are known that were part of the scene

Thanks for the quick replies!! I will have a go at this tonight:-)

This is called the Singleton design pattern, or at least that’s what your asking for.

This may help more too: http://wiki.unity3d.com/index.php?title=Singleton