P
P
Pavel2018-05-20 19:35:50
C++ / C#
Pavel, 2018-05-20 19:35:50

Where can NullReference come from?

I ran into a very strange situation.
I have a script.
skrinshoter.ru/s/200518/BcX02lhN?a
It has 4 debug logs. After the first log there should always be a second one.
But instead NullReference crashes in the application.
Moreover, there is one very interesting nuance: the application works properly in the editor, but this error occurs on the device and the emulator.
Here is a screenshot of the logs from the console on the device:
skrinshoter.ru/s/200518/6vkU9upq?a Does
anyone have any ideas how this can be?
PS log for case 0: did not set, because works properly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2018-05-21
@youkerni

They write to you correctly: without callstack it is impossible to find out exactly where the error got out, maybe not even in this method, maybe somewhere inside GeneratePairGame, maybe randomLevel = null. You need to log Exception, wrap the body of the case inside a try-catch

case 2:
  try
  {
    GeneratePairGame(randomLevel);
    ...
    break;
  }
  catch(Exception ex)
  {
    Debug.Log(ex);
  }

Then you will see exactly where and what happened.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question