Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR CS0117 ('Debug' does not contain a definition for 'log')

Im trying to show on console when a gameobject collides with another gameobject with collide. I keep getting this error on unity's console ERROR CS0117, 'Debug' does not contain a definition for 'log'.

  • im on mac using .net core
  • im using vs code 1.35.1 and unity 2019.3.0a5
  • i already have all the usings that i need, but intellisense does not find a definition for my debug or for anything whatsoever, this is frustrating :/
  • i dont have any other .cs file named debug neither

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine.SceneManagement;
    
    public class DeadZone : MonoBehaviour
    {
        private void OnCollisionEnter2D(Collision2D collision){
            Debug.log("Collision");
        }
    
        private void OnTriggerEnter2D(Collider2D collision){
            Debug.log("Trigger");
        }
    }
    

i expect a "collision" message in the console of unity when my ball gameobject touches a wall gameobject, both with collider but i only get that error within the console, i also already tried using UnityEngine.Debug.log(); but havent got any success yet... :(

like image 468
b i c c s Avatar asked Mar 21 '26 21:03

b i c c s


1 Answers

You are using Debug.log(). but you should be using Debug.Log(). Notice the capitalised "L" on "Log".

By naming convention for C# method names will always start with a capital letter.

If you look at the Unity Docs for Debug.Log you'll also see in the code examples/title that it uses the capital L

Also judging from your tags you are using Visual Studio. Make sure that intelliSense is turned on, as this should detect and most of the time even automatically fix these kinds of typos for you.

like image 165
Remy Avatar answered Mar 24 '26 11:03

Remy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!