Way to setup editor to fill variable if another was provided

So I have a struct like this:

[System.Serializable]
public struct Buff
{
    public Stats stat;
    public Sprite icon;
    public int value;
    public float fvalue;
}

I use it to assign buffs to my items and then interpret using Stats enum what they should do on my characters.

My problem is, that I have to assign Icon along with a stat everytime I am asigning the buff/value to each and every item.
Is there a way to assign an icon to enum in editor, so that everytime I set the enum the icon automatically assigns itself in editor ? I experimented using some Dictionaries in seperate class etc but I want this to remain simple data and use enum to differentiate between stats with no setup required. So I’m looking for a way to tell my editor “hey if I set this value on this struct you should set the other to that”.

Any ideas ?

Hi, the reason you have to set that every single time is because your reinstantiating the ‘buff’ on each item as opposed to referencing one, single buff.

What you might want to do is make your buff into a Scriptable Object and have your items have a list or array of buffs which they reference.

[CreateAssetMenu]
public class Buff:ScriptableObject
{
public Stats stat;
public Sprite icon;
public int value;
public float fvalue;
}

[CreateAssetMenu]
public class Item:ScriptableObject
{
[SerializeField] Buff [] buffs = null; //Remember to add buffs in the inspector.
}

This also fixes the issue where changing the Buff on one Item doesn’t change it on all of them; Since any item that references the changed buff has a reference to that specific instance of the buff, the change will automatically be implemented.