Closed laurentopia closed 2 weeks ago
it's possible that it's a bug...
Hi,
AFAIK, an interface should either be non-UnityEngine.Object, or a UnityEngine.Object. they use two different mechanisms:
SerializeReference
provided by Unity (which can not be used on a UnityEngine.Object), I don't know if there is a way to make the two use the same process. At this point, we can only do:
public interface IPhysicsRelayReceiver
{
void OnTriggerEnterRelayed(Collider other);
void RegisterCollider(Collider col);
}
public struct ExampleStructOfInterface : IPhysicsRelayReceiver
{
public string DisplayName;
public void OnTriggerEnterRelayed(Collider other)
{
}
public void RegisterCollider(Collider col)
{
}
}
public class MCPhysicsRelay : MonoBehaviour, IPhysicsRelayReceiver
{
// example of non-UnityEngine.Object
[SerializeReference, ReferencePicker]
public IPhysicsRelayReceiver nonUnityObject;
// example of UnityEngine.Object
public SaintsInterface<UnityEngine.Object, IPhysicsRelayReceiver> unityObject;
public void OnTriggerEnterRelayed(Collider other)
{
}
public void RegisterCollider(Collider col)
{
}
}
SaintsInterface seems to be the easiest to use with minor changes and more importantly it doesn't break when changing the class name like [SerializeReference] does. I'll use that, or a few hidden vars. Thanks again.
if I do
it doesn't display the drop bucket like other reference fields do, only a button. Could you add a drag and drop area?