-
-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Feature description
First of all thanks for the great package, it works like a charm!
So I'm not sure if this is possible, but it would be nice if we could use SubclassSelector on abstract classes with a generic type. This way we could add an interface to the abstract class that does not have a generic type. Then we could use this to specify config values in a dictionary without a type.
My workaround for this is to use a generic interface and have a second plain interface just for selecting targets easily in configs.
public class Example : MonoBehaviour
{
[SerializeReference, SubclassSelector]
private Target<Character> _target;// does NOT show ConcreteTarget
[SerializeReference, SubclassSelector]
private ITarget<Character> _target2;// DOES show ConcreteTarget
// [SerializeReference, SubclassSelector]
// private SerializedDictionary<ITarget, float> _configs;// not possible as the interface needs a generic type
[SerializeReference, SubclassSelector]
private SerializedDictionary<ITargetConfigurable, float> _configs2;// possible workaround
}
// ideally we could add the generic type in the abstract class instead
public interface ITarget<T>
{
T GetTargets();
}
// using an extra interface instead of ITarget allows us to select a target without type eg. in a config
public interface ITargetConfigurable { }
public abstract class Target<T> : ITarget<T>, ITargetConfigurable
{
public abstract T GetTargets();
}
[Serializable]
public class ConcreteTarget : Target<Character>
{
public override Character GetTargets() => null;
}
public class Character { }Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request