Null reference exception with static method

My static method that i’ve set within an abstract class using a custom namespace keeps giving me a null reference exception when i try to pass a Vector3 to it.

using UnityEngine;

namespace DebugUtility
    public class DebugUtility
        public static void DisplayInfo(Vector3 pos, string info)
            Vector3 pointOnScreen = Camera.main.WorldToScreenPoint(pos);
            //rest of the code

I call it with: DebugUtility.DebugUtility.DisplayInfo(,text);

Well, possible reasons are:


The first enabled camera tagged
“MainCamera” (Read Only).

The primary Camera in the scene.
Returns null if there is no such camera in the scene. This property
uses FindGameObjectsWithTag internally
and doesn’t cache the result. It is
advised to cache the return value of
Camera.main if it is used multiple
times per frame.

The second possible reason is this

//rest of the code

I think you should be more specific here. If you get a NullRef exception you get a stacktrace with line numbers. You haven’t provided any. Finally from the code we see it’s also possible that your info string is null. However we do not know if and how you may use it inside your method and we do not know where text is coming from.

In short:

This question can not be answered.

I have a main camera tagged as the default mainCamera.
I don’t know what the issue here was, but i reimported all assets and its seems to have fixed the issue.