Possible Bug

Using Unity 2019.4

Yesterday I tried the following:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Puzzle.GreatAlembic
{
public interface _OutputMultiplier : MonoBehaviour
{
void Multiplier(float factor);
}
}

and then set up another class with a public array as follows:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Puzzle.GreatAlembic
{
public _OutputMultiplier[ ] item;
}

The inspector didn’t show the array at all. However, when I changed from an interface to an abstract class:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Puzzle.GreatAlembic
{
public abstract class _OutputMultiplier : MonoBehaviour
{
public abstract void Multiplier(float factor);
}
}

it worked as expected

My understanding is Unity does not expose fields in the inspector which are of an interface type. Also, use Code tags when posting code into the forum, and Unity 2019.4 won’t be released for another 10+ months.

1 Like

I don’t even know how your first one even compiled… you can’t have an interface inherit from MonoBehaviour.

And yeah, Joe-Censored hit it on the head. Unity does not support serializing interfaces.

error CS0527: Type ‘MonoBehaviour’ in interface list is not an interface

The easiest solution was to simply convert it to an abstract class.