Accessing a table in a list of subclasses (unity)
Hello, i'm trying to change a value of a table during runtime.
I have a unity object called manager that is the main, which in turn contains a class called unit, unit contains a list with costumes, along with all the options in a table, where of inside there is a simple bool which i'd like to change from ALLOWED to DISABLED and vice versa, however when i try to access this during runtime it tells me that the object I try access doesn't exit even if i know it's there and, simplified it's something like this
What I doing wrong?
6 Replies
Really hard to say without seeing the actual code, but if it's telling you some object doesn't exist, I'd wager you are mistaken in thinking that it does 😄
Have you tried setting a breakpoint and checking the values at each step? Apparently something isn't properly initialized when you think it should be.
some object in the chain must be null
you have to check for nulls
how you check that depends on whether it's a unity object or a simple object
What's the difference between checking them for nulls?
Unity overloads
null
in some weird ways
Where x == null
might be true, but x is null
might be falsex == null
checks if x has been destroyed, or isn't assignedThanks so much I will see if doing those checks helps me