I am approaching the tedious part of creating my game - creating prefabs and changing settings for a large number of objects. These objects (i.e. different strike-craft) have all got the same scripts on them but there are many many scripts to add to each one.
I need a way (or the correct syntax) to add ONE script to an object and have it add the rest - similar to @script require component.
Editor scripting is a lot like any other scripting, except that it runs in the editor. Some of them also make use of the UnityEngine namespace – those ones should go in the Editor folder.
For example, you could create a MenuItem that adds your scripts:
#pragma strict
@MenuItem("Extras/Add Components")
static function AddScripts() {
for (var transform : Transform in Selection.transforms) {
var box = transform.gameObject.AddComponent(BoxCollider);
box.size = Vector3.one * 5;
}
}
The “Extras” menu will appear in the top bar of your Unity editor window (near “File” and so on). Sometimes it won’t show up at first until you click another menu.
Editor scripting is very powerful, but not as well documented as I’d like.