I Can Print() This Data But I Can't Use It

I have a scriptable object which has a list of other scriptable objects and I am trying to reach it from another script to do some calculations. When I try to assign the float that the scriptable objects should return it gives this error but when I try to print it, it works fine. How can unity print a float but can’t use it?

The error: Object referance not set to instance of an object.

The code that gives error:

ChpPVote = allCityScriptabelData.AllCityScriptableObjects[cityNumber].ChpVotes[0];

The code that works just fine:

print(allCityScriptabelData.AllCityScriptableObjects[cityNumber].ChpVotes[0]);

You’ll need to post more of the code, I think.

The problem is solved after restarting unity. Weird.

Yup. That’s how it works sometimes.

Take it from a retired Windows engineer…

Back in the day, we used this agenda:

  1. Run it again.
  2. Recompile it and run it again.
  3. Reboot, recompile it, and run it again.
  4. Go to lunch.

Remember, if it hadn’t been for long compiles, no one ever would have solved Rubik’s Cube.