[ANSWERED]Debug.Log and print() is very much not working for me

The script is simple. (And this example script is not the same as mine)

void Update()
{
Debug.Log("Hello.");
}
  1. The script is very much attached to a game object
  2. The object that has this scrips is very much active
  3. The script is also very much active
  4. Everything should very much work, but instead it very much doesn’t work
  5. I only tested it in FixedUpdate (fail), Update (fail) and Awake and only Awake worked and printed it out.

Please help me with this I just need to check something to see if my code works at all and if it doesn’t I guess I’m gonna throw my pc out the window and instead build a new one using scraps cuz thats still easier then making this code work because I am a complete noob trying to challenge myself ;-;

This code works for me, and outputs Hello about 100 times a second. Update is called on every frame. Please share your entire script. Have you confirmed Start() ?

I don’t see anything wrong with that code, but we’d need the full script to be certain.

My guess would be it isn’t getting compiled and it’s using a previous version of the script that didn’t have the debug statement? Is that possible?

Do you

  • have any error messages in the console?
  • have this script in a file which has the same name (including caps) as the class name?
  • have your class inheriting from MonoBehaviour?

Also if you want help, give us your script. We don’t try to fix the example script. we try to fix yours.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class rayManager : MonoBehaviour {

    [Tooltip("Diameter.")]
    [Range(0.125f, 5)]
    public float holeSize;

    public int resolution;

    private float height;
    private List<Vector3> spawnLocation;
      

    void Awake()
    {
        resolution = 2;

        holeSize = 0.125f;

      
    }

    void Update()
    {
        height = Camera.main.orthographicSize * 2;
        Vector3 top = new Vector3(0, height / 2);
        Vector3 hole = new Vector3(0, holeSize / 2);
        Vector3 down = new Vector3(0, height / (-2));

        Debug.DrawLine(top, hole);
        Debug.DrawLine(down, hole * (-1));
     
        Debug.Log("Spawn Location: " + spawnLocation.Count);
       
        if (resolution <= 2)
            resolution = 2;

        float spawn = 0f;

        for (float step = holeSize / resolution ; spawn < holeSize ; spawn = spawn + step )
        {

            spawnLocation.Add(new Vector3(0, spawn));

        }
    }

}

Also if any of you want to try helping me with the list I would appreciate it alot. (Because idk how to use them).

Comment out everything in Update except a Debug.Log call

Debug.Log ("I’m here in Update!);

I suspect you are receiving a runtime exception.

Well it was because I didnt initialize the list. I just added = new List(); to the list and it works now. So I guess you are right.

1 Like