- Home /
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.
Answer by FlaSh-G · May 09, 2020 at 05:04 AM
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.
Your answer
Follow this Question
Related Questions
Get child name from another parent 2 Answers
physics.OverlapSphere colliders 1 Answer
change an image with touch/drag(enable/disable gameObject or Component) 0 Answers
Point Collection Bug 0 Answers