Search code examples
c#game-development

The namespace '<global namespace>' and same parameter types


I try to create virtual novel game but I don't know what I already done so it suddenly have 7 error first is:

Assets\script\scriptreader.cs(8,14): error CS0101: The namespace '' already contains a definition for 'scriptreader'

and the six left is about my class

Type 'scriptreader' already defines a member called 'Start' with the same parameter types

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Ink.Runtime;
using TMPro;

public class scriptreader : MonoBehaviour
{
    [SerializeField]
    private TextAsset _InkJsonFile;
    private Story _StoryScript;


    public TMP_Text DialogueBox;
    public TMP_Text nameTag;

    public Image characterIcon;

    // Start is called before the first frame update
    void Start()
    {
        Loadstory();
    }

    void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space))
        {
            DisplayNextLine(); 
        }
    }

    void Loadstory()
    {
        _StoryScript = new Story(_InkJsonFile.text);

        _StoryScript.BindExternalFunction("Name", (string CharName) => ChangeName(CharName));
    }

    public void DisplayNextLine()
    {
        if (_StoryScript.canContinue)
        {
            string text = _StoryScript.Continue();
            text = text?.Trim();
            DialogueBox.text = text;
        }

        else
        {
            DialogueBox.text = "ติดตามชมภาคต่อไป";
        }
    }

    public void ChangeName(string name)
    {
        string speakerName = name;

        nameTag.text = speakerName;
    }

    public void CharacterIcon(string name)
    {
        var charIcon = Resources.Load<Sprite>("");
    }
}

I already reopen it but it still not working. Can you edit it or suggest it for me? I'm new in programming. Thanks


Solution

  • I think scriptreader class exist twice. Change the class name or delete other class if not required.