[Unity中使用C#但无法运行代码的Am脚本编写

问题描述 投票:0回答:1

我开始在Unity中运行脚本,并在运行所附代码之后。我在统一控制台中收到错误。对我有任何帮助。

统一图像错误。

enter image description here

这是我在VS中为统一运行的代码。

在此处输入代码

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

public class CubeScript : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Start method is Called");
    }

    // Update is called once per frame
    void Update()
    {
        Debug.Log("Update is calling");
    }
}**
c# unity3d
1个回答
1
投票

您在项目中有2个名为CubeScript的类。其错误原因

如果其他脚本包含相同的类名称,请查看其他脚本

为了避免重复的类,您也可以添加名称空间:

namespace NameOfSceneForExample
{
    public class CubeScript : MonoBehaviour
   {
   }
}
© www.soinside.com 2019 - 2024. All rights reserved.