Editor - Scriptable Object - Prefab Dropdown

I’m sure this is a question that has already been answered but any answers i could find i couldn’t get working properly.

I currently have the following scriptable object

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class ScriptableWeaponBase : ScriptableObject
{
    public string Name;
    public string Description;

    public AttackType attackType;

    public WeaponStats weaponStats;

    [Header("Modules")]
    public AttackBase attack;
    public HitBase hit;

    [Header("Charge weapon only")]
    public float chargeTime;
    public float minCharge;
    public float maxCharge;

    public virtual void update(Weapon weapon, ScriptableWeaponBase scrWeaponBase)
    {
        attack.AttackUpdate(weapon,scrWeaponBase);
    }
}

I want to be able to have the AttackBase and HitBase field be displayed as a drop down that will list all potentials.
when i’m assigning these values manually I’m currently having to create a prefab applying the AttackBase or HitBase Type script to the prefab then dragging the prefab into the scriptable object. Strangely as well when i click the little circle bit it won’t even show the prefabs stored in my assets.

Cheers for any help.

I think this is just how Unity works: if you make a public field of type Foo, it will only suggest Foos in your scene, not Prefabs that contain Foos. Prefabs that contain a Foo are actually GameObjects.

Check some tutorials on getting this up in the editor. It is totally possible and it is far too long for anyone to type here!

1 Like