P
P
ProgramDevel2020-07-02 13:05:19
Unity
ProgramDevel, 2020-07-02 13:05:19

What is wrong with C# script?

I have two scripts to generate

mazespawner maze

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

public class mazespawner : MonoBehaviour
{
    public GameObject CellPrefab;

    void Start()
    {
        mazegenerator generator = new mazegenerator();
        mazegeneratorcell[,] maze = generator.generatemaze();

        for (int x = 0; x < maze.GetLength(0); x++)
        {
            for (int y = 0; y < maze.GetLength(1); y++)
            {
                Instantiate(CellPrefab, new Vector2(x, y), Quaternion.identity);
            }
        }

    }

}


mazegenerator
using UnityEngine;

public class mazegeneratorcell 
{
  public int Y;
  public int X;

  public bool WallLeft = true;
  public bool WallBottom = true;
}

public class mazegenerator
{
  public int Width = 50;
    public int Height = 50;

    public mazegeneratorcell[,] generatemaze()
    {
    	mazegeneratorcell[,] maze = new mazegeneratorcell[Width, Height];

        for (int x = 0; x < maze.GetLength(0); x++)
        {
            for (int y = 0; y < maze.GetLength(1); y++)
            {
                maze[x, y] = new mazegeneratorcell(X = x, Y = y);
            }
        }

    	return maze;
    }
}


These two scripts give the error

Assets\Scripts\mazespawner.cs(5,14): error CS0101: The namespace '' already contains a definition for 'mazespawner'

Assets\Scripts\mazespawner.cs(9,10): error CS0111: Type 'mazespawner' already defines a member called 'Start' with the same parameter types

Please help!
What is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2020-07-02
@ProgramDevel

Somewhere else in the project there is a mazespawner

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question