i want to make a script prefab , so that i can add all the varaible and gameobject referneces i need to fill it all out , and the drag that onto a game object that needs it .
i can do that with a gameobject , the drag the script on to it make it a prefab then fill it all in . but when i drag it to a model it add its to the gameobject heiracky and not the scrips , were i would like it to go , is there a way to do this ?
Scripts can only exist as components on a game object (or inside other scripts / as static classes etc). However you can give your exposed variables a default value, though this doesn’t really work with game object references:
public float Foo = 1; //will be 1 by default in editor
public GameObject Bar1 = null; //works
public GameObject Bar2 = new GameObject(); //wont work
public GameObject Bar3 = GameObject.Find("bla"); //wont work
numberkruncher: “If you select a script, the inspector allows you to specify default values (and associate other project wide objects) for new instances of script”.
(credit to numberkruncher for the above quote)