Search Unity

Question How to disable specific warning

Discussion in 'Navigation' started by XukeLho, Jan 14, 2022.

  1. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    I'd like to disable this warning:
    "NavMeshAgent and NavMeshObstacle components are active at the same time. This can lead to erroneous behavior."
    Yes I understand the risks of using both components on the same object, but I have a manager for doing so.
    I've tried #pragma warning disable/restore but with no success (as expected as these are for specific error codes)
    I'd like to disable this warning only on the gameobject that I am currently using it on, as if I mix NavMeshAgent and NavMeshObstacle in the future in a different object, I'd like to receive that warning again, to remind me to be sure that I want to do that, or to remind me it was a mistake.
     
  2. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    300
    You should never have both objects active at the same time anyway, as it does not make any sense. So if you want to move your agent, switch off NavMeshObstacle and switch on NavMeshAgent and vice versa.
    There is no way to get rid of this warning otherwise.
     
  3. CantThinkOfUniqueUsername

    CantThinkOfUniqueUsername

    Joined:
    Jan 30, 2021
    Posts:
    1
    @XukeLho not sure if you figured this out already, but I just came across something similar in my code. The problem was that even though I had a logic toggling agent/obstacle, the prefab would spawn in initially with both toggled on, and only afterwards controlled by the logic. Fix was simple → turn off obstacle in the prefab, such that it only spawns with agent toggled on.