Search Unity

Debug.Log not working

Discussion in 'Scripting' started by TAMgames, Oct 25, 2014.

  1. TAMgames

    TAMgames

    Joined:
    Oct 9, 2014
    Posts:
    5
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class NewBehaviourScript : MonoBehaviour
    5. {
    6.     Debug.Log ("test");
    7. }
    8.  
    Debug.Log just stopped working. It wouldn't auto complete in MonoDevelop and gave me an error.

    So, I opened a new project and a new script just to test Debug.Log

    The code at the top is the exact c# script I'm trying to get to work with now. It gives me the error "Invalid token '(' in class, struct, or interface member declaration (CS1519..."

    Is Unity or Monodevelop broken? Should I just reinstall them?
     
  2. TAMgames

    TAMgames

    Joined:
    Oct 9, 2014
    Posts:
    5
    Oh and UnityEngine.Debug.Log doesn't work either...
     
  3. Magiichan

    Magiichan

    Joined:
    Jan 5, 2014
    Posts:
    403
    o__o
    You need to put that in a function...
    Everything but declerations & imports need to be written inside functions.
    Start() { } Get's called right away when you start ur scene. So put the debug.log inside that if u want it to be called once.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class NewBehaviourScript : MonoBehaviour
    5. {
    6.     void Start () {
    7.         Debug.Log ("test");
    8.     }
    9. }
    Watch this, it should help you alot :3
    By the way, maybe it's a good idea to learn the basics of programming xD
     
    TAMgames likes this.
  4. TAMgames

    TAMgames

    Joined:
    Oct 9, 2014
    Posts:
    5
    Thank you... I have to stop working this late I do the stupidest things and get so frustrated...