scene-ref-attribute icon indicating copy to clipboard operation
scene-ref-attribute copied to clipboard

InterfaceRef seems to refer to transform when dragged into the property drawer.

Open senft-research opened this issue 5 months ago • 0 comments

Not sure if InterfaceRef is supposed to only be used with the automatic referencing (like [SerializeField, Child] as an example) but it seems that trying to drag objects into the property drawer directly leads to the transform component being the thing serialized, leading to errors at runtime.

Images for reference:

Image The Object "Cube" has script `ReturnToPoolAfterTimer` which implements `IPoolable` Image `TestPoolBootstrap2` has `Object To Spawn` Property that is a `InterfaceRef` serialized field
    [SerializeField]
    InterfaceRef<IPoolable> objectToSpawn;
Image

The end result of dragging Cube into the ObjectToSpawn property, note that it is considering the transform, not the correct IPoolable implementing component

Error message at runtime when the value of the Cube's IPoolable implementing component is called:

NullReferenceException: Object reference not set to an instance of an object _Scripts.Util.Pools.ObjectPoolManager.SpawnObject (_Scripts.Util.Pools.IPoolable poolableToSpawn, UnityEngine.Vector3 spawnPosition, UnityEngine.Quaternion spawnRotation) (at Assets/_Scripts/Util/Pools/ObjectPoolManager.cs:34) TestPoolBootStrap2.Update () (at Assets/TestPoolBootstrap2.cs:16)

senft-research avatar Jul 30 '25 02:07 senft-research