Unity, member names cannot be the same as their enclosing type?
Hi, ich habe ein Problem. Ich habe in Unity 3D eine Übersetzung für mein Spiel gemacht, und dann auf ein Fehler gestoßen, den ich nicht beheben konnte. "Assets\Scripts\Scripts3D\Sprachen.cs(9,18): error CS0542: 'Sprache': member names cannot be the same as their enclosing type"
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sprache : MonoBehaviour
{
public int Sprache;
// Start is called before the first frame update
void Start()
{
Sprache = PlayerPrefs.GetInt("Sprache");
}
// Update is called once per frame
void Update()
{
}
void Englisch()
{
PlayerPrefs.SetInt("Sprache", 0);
}
void Deutsch()
{
PlayerPrefs.SetInt("Sprache", 1);
}
void Französisch()
{
PlayerPrefs.SetInt("Sprache", 2);
}
}
Ich habe auch versucht, es in Zeile 9 mit z.B "public int Sprachen" oder "public int MeineSprachen" hat nicht funktioniert, da dann der Fehler "Assets\Scripts\Scripts3D\Sprache.cs(14,9): error CS0118: 'Sprache' is a type but is used like a variable" kommt. Kann mir jemand helfen?