0

I'm using Unity 2020.3.8f1. I'm having some issues with console errors. Yesterday everything was working well but suddenly, the "Null Pointer Errors" and "Argument Null", etc won't appear on console.

The error symbol is selected and script errors (like missing a semi-colon ( ; ) ) still appear. But the errors that can appear during play mode won't appear.

As you can see on the image, I wrote this code to force errors on the console. Line 48 and line 49 appear on the console. (L49 even appears as an Error). After that, not a single line appears. On line 55, we should have an error saying that the list is empty or something like that.

Error

Error

Does anybody know what might be causing this?

public class PackOpeningManager : MonoBehaviour
{
    GameObject bla;
    public void Test()
    {
        Debug.Log("Hey Test");
        bla.SetActive(true);
        Debug.Log("Hey Won't appear");

    }
}

And then I instantiate the Prefab:

GameObject packOpeningManager = Instantiate(Resources.Load("UIPrefabs/PackSystem/Pack Opening Manager") as GameObject, canvas);
        PackOpeningManager packManager = packOpeningManager.transform.GetChild(0).GetComponent<PackOpeningManager>();
        packManager.backgroundMovingParent = backgroundMovingParent;
        packManager.background = background;
        packManager.Test();
derHugo
  • 83,094
  • 9
  • 75
  • 115
  • 1
    Could you post more context of your code? Is this being called on a background thread / some async Task? In general **don't post images of code!** – derHugo May 18 '21 at 15:36
  • 2
    @Mr.Banks a warning is never logged for an exception, though – derHugo May 18 '21 at 15:37
  • The `Debug.Log(emptyList[i]);` will not throw a `NullReferenceException` nor an `ArgumentNullException`. The first two elements log correctly `Null`. For the third iteration you should rather get an `IndexOutOfRangeException` since there are only two elements ... The only case why these wouldn't show up afaik would be that this runs async and isn't properly awaited – derHugo May 18 '21 at 15:43
  • as @derHugo said this MUST throw an `IndexOutOfRangeException`. Are you calling this method in the `Start()` ? – mahdiful May 18 '21 at 15:47
  • You are right, it would be an IndexOutOfRange. Anyway, It's not on Start() but if it's being called. Otherwise, the rest of the prints won't appear, right? – Goncalo Diogo May 18 '21 at 15:57
  • To be honest we need more context to follow the code. it's hard to predict – mahdiful May 18 '21 at 16:03
  • Again **when** and **how** is it called .. Everything going through the Unity `Debug` is treaded special .. an exception might not be tracked if it happens on a different thread/task .. see e.g. [Catch an exception thrown by an async void method](https://stackoverflow.com/questions/5383310/catch-an-exception-thrown-by-an-async-void-method) – derHugo May 18 '21 at 16:04
  • Basically, I'm instantiating a Prefab that has that code. After instantiating I call the function above. The normal debug appears but the errors won't. I'm not using the threads or anything alike – Goncalo Diogo May 18 '21 at 16:16
  • One strange thing is that if I "force" an error on Start() it'll appear on console. – Goncalo Diogo May 18 '21 at 16:18
  • I edited the original Post with the code – Goncalo Diogo May 18 '21 at 16:42
  • Thats now how to make new game objects. So it probably silently barfs – BugFinder May 18 '21 at 17:01
  • How do you suggest? @BugFinder What am I doing wrong? – Goncalo Diogo May 18 '21 at 17:04
  • You dont do “new GameObject” you would instantiate it. You make an array of length 2 and then try 0 to 19. Which is why it shows 2 and quietly dies – BugFinder May 19 '21 at 10:07
  • Yes, I made that on purpose. The question here is after the 2 debugs, it should appear an IndexOutOfRangeException on the console. That doesn't occur. – Goncalo Diogo May 19 '21 at 10:20
  • Please use the correct tags! `unityscript` is or better was a JavaScript flavor like custom language used in early Unity versions and is long deprecated by now! Your script is clearly `c#`! – derHugo May 21 '21 at 17:56

1 Answers1

0

It seems DOTween was capturing all the errors by himself and wouldn't print them in the console.

If you have this issue, just check if your DOTWeen is capturing all the errors and, if so, just disable the DOTween Safemode.

Thank you all.