Search Unity

Debug.log not working?

Discussion in 'Scripting' started by CaramelBeet, Mar 8, 2016.

  1. CaramelBeet

    CaramelBeet

    Joined:
    Mar 8, 2016
    Posts:
    4
    I'm starting to code with c# (yay!) and I tried using a debug.log command, but unity gives me two errors:
    Assets/Variables.cs(12,19): error CS0117: `UnityEngine.Debug' does not contain a definition for `log'
    and
    Assets/Variables.cs(16,13): error CS0103: The name `debug' does not exist in the current context

    Here is my coding. I'm using visual studio 2015 to code.
    using UnityEngine;
    using System.Collections;

    public class Variables : MonoBehaviour {

    public bool Alive = true;
    // Use this for initialization
    void Start()
    {
    if (Alive == true)
    {
    Debug.log("You are alive!");
    }
    else
    {
    debug.log("You are not alive.");
    }

    }
    // Update is called once per frame
    void Update () {

    }
    }
    Thanks!!
     
  2. ericbegue

    ericbegue

    Joined:
    May 31, 2013
    Posts:
    1,353
    it's Debug.Log, not Debug.log.
     
    FlipCn, Bunny83 and CaramelBeet like this.
  3. Darholm

    Darholm

    Joined:
    Mar 1, 2016
    Posts:
    63
    And also, in you else statement : Debug.Log()
    What IDE are you using? Visual Studio has a pretty usefull code completion that avoids this kind of errors.
     
    Bunny83, CaramelBeet and ericbegue like this.
  4. CaramelBeet

    CaramelBeet

    Joined:
    Mar 8, 2016
    Posts:
    4
    Woah, it works! Thanks! I guess I've been writing HTML for too long, where it's not case sensitive.

    I admit, I have no idea what an IDE is.
     
  5. Darholm

    Darholm

    Joined:
    Mar 1, 2016
    Posts:
    63
    IDE meands Integrated Development Environment.
    Visual Studio, Mono, Eclipse...just to name a few of them, are IDE.
    So my question was : in what kind of software are you writting your scripts?
     
  6. CaramelBeet

    CaramelBeet

    Joined:
    Mar 8, 2016
    Posts:
    4
    Ah, right. I'm using Visual Studio Community 2015.
     
  7. Darholm

    Darholm

    Joined:
    Mar 1, 2016
    Posts:
    63
    Ok. When you type a method name, you can press Ctrl+space bar to have the code completion. That will help avoiding case sensitive issues.
    Code completion is the best tool for programming.
    But by default, VS 2015 should pop up this window automatically.
     
    amaracodes likes this.