class WeaponList
{
var point_weapon : Weapon;
var flag_obtained : boolean;
var main_ammo : Ammo;
var list_ammo : Ammo[];
}
var list_weapons : WeaponList[];
what i want this script to do in the inspector is allow the user to attach a script at Weapon and Ammo, however at the moment when i try and drag a script over to one of these the script doesn’t attach, and i missing some code in this?
EDIT: there actully are scripts called Weapon and Ammo created, i use them as templates
there are 3 types of scripts in unity as others said.
MonoBehaviours are classes which you define in js without even using the class keyword and you can attach them using a gameObject/Prefab with that script attached. they are a component and can not be attached.
normal classes (i.e derrived from System.Object) which if you want them to be shown in inspector to be able to change their values like Vector3’s inspector, in C# you need to set [System.Serializable] attribute for them but in js it’s implicit too just derrive from System.Object like the code example below.
scriptableObjects are a great type which developers don’t use that much. if you derrive from it then you can save the class as an asset in your project and you can drag assets of this type to a variable of the same type just like Texture2D and other asset types. to create an asset you need to use the UnityEditor.AssetDatabase class.
code example for the second type of scripts
class test extends System.Object
{
//class definition
}