0

So, I'm pretty new at C#. Teaching myself and using tutorials when I can. Currently I am working on an inventory system. I have a scriptable object to store all my pieces of armor by sets. I'm using iFrames to do this. What I need to be able to do is when I set my default armor for different classes to just be able to scroll through a list of armor (I've made the list in my armor script) on the inspector on my PlayerClass Scriptable Object.

Below is the code for my Armor Collection

public class ArmorCollection : ScriptableObject
{
    [System.Serializable]
    private class ArmorSet
    {
        public string armorSetName;
       //gear sprites and stats are below this in this nested class
    }

    [SerializeField] List<ArmorSet> armorSet;
    
    private Dictionary<int, string> setName; //not sure if it should be a List or Dictionary currently
    [HideInInspector] public Dictionary<int, string> SetName { get => setName; }

    private void OnValidate()
    {
        for (int i = 0; i < armorSet.Count; i++)

        {
            setName.Add(i+1,armorSet[i].armorSetName);
        }
    }

And here is where I am stuck on my Player Class script:

public class PlayerClass : ScriptableObject
{

    [SerializeField] PlayerStats playerData;
    [SerializeField] PlayerGear gear;
    [SerializeField] ArmorCollection armor; 
    
    [Space]
    [SerializeField] string className;

    [Header("Gear")]
    [SerializeField] string startingArmorSet; //needs to be a dropdown list

So far, I thought about using enums, then realized that they are readonly. So that's out. I need to be able to change it based on the different scriptable objects: default class armor, common armor, uncommon armor, etc. Each one would have it's own set of different armor to pull from. I have been going between making the setName a list or a dictionary, but not sure how to make either a dropdown in my PlayerClass script.

Any help would be appreciated.

  • 1
    What's iFrames? Do you know [how to customize inspector](https://docs.unity3d.com/2021.2/Documentation/Manual/UIE-HowTo-CreateCustomInspector.html)? – shingo Aug 29 '23 at 05:29
  • 1
    A bit unclear how your expected Inspector would look like and how it should behave ... but in general you would need a [custom editor](https://docs.unity3d.com/Manual/editor-CustomEditors.html) and then use e.g. a [popup](https://docs.unity3d.com/ScriptReference/EditorGUILayout.Popup.html) .. see also e.g. my post here https://stackoverflow.com/a/60865726/7111561 – derHugo Aug 29 '23 at 06:55

0 Answers0