How can I create a list of preset class/objects to be used in the editor

Sorry I wasn’t really sure how to word the question and not exactly sure how to ask this but basically I want to know how exactly can I get this goal done;

After creating a class , Lets say “Equipment”, I create an array of that Equipment class and preset all the variables in the inspector drop down. Now lets say I have 10 items in this Equipment array… How can I make that a permanent list for the game where I can now call “Equipment item” from a script and when I try to initialize the object in the inspector it will give me a drop down of the set list of equipment where I can now choose one of those to be that item?

I’m sorry in advanced if this is a bit confusing. If you have other questions that will clear things up a bit please let me know. I would really like to know how I can get this done.

Thanks!

Ok so if I understood correctly, you want to define an array with some Equipment instances, and then a drop-down where you choose just one of them. Right?

If so, you’d have:

public class MyScript : MonoBehaviour {
    public Equipment[] equipments;
    public Equipment currentEquipment;
}

And editor related code (quick custom editor for MyScript, not optimized, so it won’t be as fast as it should):

[SerializeField]
int index = 0;

[SerializeField]
MyScript myScript;

void OnEnable () {
    if (myScript == null)
        myScript = target as MyScript;
}

public override void OnInspectorGUI () {
    string[] equipmentStrings = new string[myScript.equipments.Length];
    for (int i = 0; i < equipmentStrings.Length; i++) {
        equipmentStrings _= myScript.equipments*.equipmentName; // choose here the string you want to show in the drop-down*_

}
serializedObject.Update ();
EditorGUILayout.PropertyField (serializedObject.FindProperty (“equipments”));
EditorGUI.BeginChangeCheck ();
index = EditorGUILayout.Popup (index, equipmentStrings);
if (EditorGUI.EndChangeCheck ()) {
serializedObject.FindProperty (“currentEquipment”).objectReferenceValue = myScript.equipments[index];
}
serializedObject.ApplyModifiedProperties ();
}
Note that the example above doesn’t support multi-edit out of the box (as we’re accessing target, things will probably mess up if you enable multi-edit). It would require some tweaking.
Check the code yourself, as I’ve typed it straight in the browser and may contain typos.