【问题标题】:Error with C#script in unity using Vs code使用 Vs 代码统一 C#script 时出错
【发布时间】:2023-01-03 12:58:00
【问题描述】:

我在尝试学习 C# 和 unity 进行游戏开发时遇到了这个错误。我试图将此 C# 脚本添加到预制件中:

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

public class PrintToConsole : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Debug.log("I'm printing to console");
    }

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

}

我最终在控制台中收到此错误:

Assets\PrintToConsole.cs(10,15):错误 CS0117:“调试”不 包含“日志”的定义

我很困惑为什么。

如果有帮助,这是我的 Unity 的屏幕截图。

我期待在我的统一平台的控制台中打印一条消息。

【问题讨论】:

    标签: c# unity3d visual-studio-code


    【解决方案1】:

    C# 区分大小写。 Debug.log 和Debug.Log 不是一回事。

    【讨论】:

      【解决方案2】:

      Debug中没有函数log,而是大写的Log。 在 C# 命名约定中,每个函数都是用 Pascal 大小写编写的,所以请记住这一点。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-05-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多