setactive true in OnBeginDrag

Everytime I wanna use SetActive in OnBeginDrag a “NullReferenceException: Object reference not set to an instance of an object” appears. My objetive is to appear a new panel when I drag a card.

NullReferenceExceptions happen when the variable in front of the dot does not reference an object (or, if you put the dot behind a method call, that method returned null rather than a reference to an object).

Find out why you don’t have a reference, but a null value. Since you’re working with SetActive, a possible thing I could imagine is that you are using a method like GameObject.Find, which actually doesn’t find inactive objects. Either way, the problem in your code is not the SetActive line, but the part of the code that’s supposed to get the reference to the object you want to work with.