SerializedScriptableObject with interface field and [AssetsOnly] issues

Issue #215 open
wavebit created an issue

hi, I have defined some types below, then create an asset file of EventHub and an asset file of UnitDec. The EventHub.Next can be assigned by dragging an asset file, but cannot finish it in the poped up selecting window. If I select None in the poped up selecting window, I will get an error tip [see pic1 below], if I click the error, I will get another error tip [see pic2 below].

public interface IPublishEvent
{
  event Action<int> OnEvent;
}

[CreateAssetMenu]
public class EventHub : SerializedScriptableObject, IPublishEvent
{
  public event Action<int> OnEvent;

  [AssetsOnly]
  public IPublishEvent Next;

  public void PublishEvent(int value)
  {
    OnEvent?.Invoke(value);
  }
}

[CreateAssetMenu]
public class UnitDec : SerializedScriptableObject
{
  [AssetsOnly]
  public IPublishEvent UnitEvent;
}

pic.PNG

pic1.PNG pic1 pic2.PNG pic2

Comments (3)

  1. Tor Esa Vestergaard
    • changed status to open

    Hmm, we'll have to consider this possible case when deciding whether to display that error message. Thanks for the report!

    For now, you can put the [SuppressInvalidAttributeError] attribute on your field, and that will hide the error message.

  2. Log in to comment