maaua
maaua

Reputation: 27

Am scripting using C# in Unity but cant run code

I'm getting started with scripting in Unity and after running the attached codes. i get the error in the unity console. Any assistance for me.

Error in unity image.

enter image description here

This the the code i run in the VS for the unity.

enter code here

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

Upvotes: 0

Views: 57

Answers (1)

Frenchy
Frenchy

Reputation: 16997

you have 2 Classes named CubeScript in your project. its the reason of error

Look at other script if one contains the same name of class

to avoid duplicate classes, you could add namespace too:

namespace NameOfSceneForExample
{
    public class CubeScript : MonoBehaviour
   {
   }
}

Upvotes: 2

Related Questions