错误CS0117(“调试"不包含“日志"的定义) [英] ERROR CS0117 ('Debug' does not contain a definition for 'log')

查看:1256
本文介绍了错误CS0117(“调试"不包含“日志"的定义)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在游戏对象与另一个发生碰撞的游戏对象碰撞时在控制台上显示.我一直在统一控制台ERROR CS0117上收到此错误,调试"不包含日志"的定义.

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'.

  • 使用.net core在Mac上安装即时通讯
  • 我使用vs代码1.35.1 和统一2019.3.0a5
  • 我已经拥有了我需要的所有用法,但是intellisense找不到我的调试或任何定义的定义,这很令人沮丧:/
  • 我没有任何其他名为debug的.cs文件

  • 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");
    }
}

当我的球类游戏对象碰触墙壁游戏对象时,我希望在统一控制台中出现碰撞"消息,两者都使用对撞机,但我只在控制台内收到该错误,我也已经尝试过使用UnityEngine.Debug.log();但是还没有成功...:(

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... :(

推荐答案

您正在使用Debug.log().但是您应该使用Debug.Log().注意日志"上的大写字母"L".

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

根据C#方法名称的命名约定,始终以大写字母开头.

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

如果您查看 Unity Debug.Log文件,还将在代码示例/标题中看到它使用大写字母L

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

还可以从标记中判断您正在使用Visual Studio.确保intelliSense处于打开状态,因为这应该可以检测到,并且在大多数情况下甚至可以自动为您修复这些类型的错字.

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.

这篇关于错误CS0117(“调试"不包含“日志"的定义)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆