Object reference disappears in the inspector on Play

This is all the code related to it.

    [SerializeField]
    private EdgeCollider2D swordCollider;

    public EdgeCollider2D SwordCollider
    {
        get
        {
            return swordCollider;
        }
    }

When the animation plays I am enabling and disabling it from another script. When i click play AND THEN add the edgecollider then it doesn’t disappear it stays there.

Thanks.

Sounds like another script is clearing the reference in Awake() or Start().

Do a ‘Find All References’ on swordCollider to see if you can spot where it’s happening.