Search Unity

How do I set a global exception catcher in unity?

Discussion in 'Scripting' started by JohnSonLi, May 22, 2015.

  1. JohnSonLi

    JohnSonLi

    Joined:
    Apr 15, 2012
    Posts:
    586
    once my code throws out an self-defined exception like
    PrefabNullException

    codes of loading prefab are everywhere, I dont want set a catcher for them individually, that would be ugly and inconvenient........so is there any way to set a global catcher for them?
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Instead of loading it with a Unity method, you may create your own one which can replace all the Unity ones. In there you can also use try+catch around the Unity method.
     
  3. JohnSonLi

    JohnSonLi

    Joined:
    Apr 15, 2012
    Posts:
    586
    thx,I have already find another way to solve my problem..