Skip to content

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

@senft-research

Description

@senft-research

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions