Children could not be evaluated

So, I want to set up different cursors depending on what mode or state my program is in. I set up a cursor utility class to accommodate the different states based on bools.

I’m going to break down the class to a small snippet to show you what I have set up.

Script that is attached to “RingSpawnPoint”:

public void DrawLines(string num)
	{
        try{
            GameObject.Find("RingSpawnPoint").GetComponent<CursorUtility>().number = num;
            GameObject.Find("RingSpawnPoint").GetComponent<CursorUtility>().drawingCursor = true; //Exception happens here
			/* Other code omitted */
		}
		catch (Exception ex)
		{
			Log.Item(ex);
		}
	}

So, when I call DrawLines and I pass in a string number like “1” or “2”… DrawLines(“1”) for example, I get an exception at the line indicated above and the exception is “Children could not be evaluated”. I’m not sure why that occurs?

EDIT: for clarification, the CursorUtility class is not attached to any game object. Could doing something like below be an issue?

GameObject.Find("RingSpawnPoint").GetComponent<CursorUtility>();

If so, how can I fix that so that CursorUtility is still not attached to game object but I can still use the methods?

If you want to do your method static, you could do something like this:

public class CursorUtility {
    public static void DoSomething() {
    //Do Something logic
    }
}

And whenever you want to consume that method you could use the type name to invoke the method

 CursorUtility.DoSomething();

Without the need of having an instance or a monobehavior that has this component. If you need a variable, you can do the same, except that your variable needs to be static as well:

public class CursorUtility {
        public static float myVar = 5.0f;
        public static void DoSomething() {
        //Do Something logic
        }
    }

And access it using the type as in the method example:

var localFloat = CursorUtility.myVar;

Please keep in mind that on this schema, usually the best practice is to have just the methods static. If you need certain variables to be Static, I hardly recommend to have a class with all the constants used on your game and use this class to access all constant variables.

public class MyGameVars {
   public const string MY_CONST1 = "hello";
   public const string MY_CONST2 = "world";
}

And use it whenever you need as:

string localVar = MyGameVars.MY_CONST1;

Hope this helps a bit.