- Home /
The question is answered, right answer was accepted
Auto Build Script
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.
Any suggestions?
Answer by Myth · Aug 19, 2014 at 02:22 AM
The code is:
[RequireComponent(typeof(StrikeCraftFlightInput))]
Where StrikeCraftFlightInput is the name of the script.
(for C#)
Answer by rutter · Aug 09, 2014 at 01:09 AM
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.
can you make an example that has the scripts "craftInfo.cs" and "generator.cs" in it. I can add the other 37 scripts myself once I understand this better