What IS a script?

In C# i want to make a generic list of scripts, but what is a script in C#?

and how do i hold a reference to a script, what do I declare it?

a script is a file that contains 1 or more classes.

Technically its not really a script though its code that really gets compiled through mono.

There isn’t anything else to it, so if you know how to code in C# you already know all of it

Script

A script is a text or print. A C# script is a programming text saved as a file used in this case in the Unity Engine. From what I understand, a script can become a part of a “Game Object” once it is attached to a “GameObject”… Therefore you simply right a C# instructions in a script file and save to your assets folder. Drag it to the GameObject which declares it for that object…

Still learning myself…

MageArt hacking Unity…

No i’m asking what it’s refereed to as in C# using the unity libary.

as in GameObject, Transform etc the decleration.

Script has no reference. Script is just another name for code file, though commonly used in a non-compiled environment.

Scripts don’t exist inside the engine in any other form, there is no class script or alike to search or use.

What is a script? A little vague!?

MageArt hacking Unity…:sunglasses:

Use the script name. For a List of different scripts, I guess you’d have to use Object.

–Eric

In response to Eric:

Would one use the file name along with the extensions?

MageArt hacking Unity…

The script name is the same as the class name.

A C# script called MyScript:

using UnityEngine;

public class MyScript : MonoBehaviour {

}

Declaring a variable called “someOtherScript” that will refer to that script, from a different C# script:

using UnityEngine;

public class AnotherScript : MonoBehaviour {
	public MyScript someOtherScript;
}

The type is MyScript. You can have an array of MyScript:

MyScript[] someOtherScripts;

Or a List of MyScript:

List<MyScript> someOtherScripts;

As I said, to have an List of a bunch of different scripts, the list type would have to be Object…not sure what else you could use, since they are all different types. There is no “script type”.

–Eric

You could use List for most user made scripts. But that wouldn’t cover built in Components or user made editor scripts.

Or scripts that don’t derive from MonoBehaviour, but that’s a good point, since probably the kind of scripts that you’d be adding to a list are likely to be MonoBehaviour anyway.

–Eric

This is true, when I hear “script” I usually assume something that extends MonoBehaviour, although that’s obviously not always true.