Are default references restricted to MonoBehaviour classes?

Are default references restricted to MonoBehaviour classes?

In the changes of Version 2.1 it says

Editor scripts no longer have MonoBehaviour default references, this makes wizards no longer have default references. It is necessary because otherwise some scriptable object based editor functionality would behave incorreclty with the automatically generated ScriptableObjects. link text

I'm not sure what you mean by restricted to MonoBehaviour classes.

Default references are just a feature which allows you to setup "project references" on script classes so when you create an instance of this script (adding it to a GameObject) the variable is set with the given reference. Of course you can't assign context-specific references (like objects in a scene) to a default reference.

Default references can reference any UnityEngine.Object derived type which is saved in the project (visible in the project-view). Common things are prefabs (either GameObject or any object derived from Component), materials, meshes, textures. In short any off-scene content in your project.

The changes-note you've quoted belongs to editor scripts which don't support default references anymore, at least that's what i read out of this note.

Hopefully this answers your question. If not, can you go a bit more in detail what you want to do? Whether you talk about editor scripts (EditorWindow, Editor) or runtime scripts (MonoBehaviour) and for what purpose you need to set default references?


My test project uses still Unity version 3.0, but that shouldn't have changed in 3.5.

I've just added some test variables to one of my editorwindows and i can see and edit the default references:

// C#
public class UVEditor : EditorWindow
    // [...]
    public GameObject testGameObject;
    public Material testMaterial;
    public MonoBehaviour testScript;
    public UnityEngine.Object testObject;
    // [...]

Default references of an EditorWindow script

ps. don't get confused by the inspector at the bottem right, it's just another inspector window ;)


I just downloaded Unity 3.5 and it seems they dropped the default references support for all classes except MonoBehaviour without any notice.