C/C++

CS0246 name 'Coin' could not be found (are you missing a using directive or an assembly reference?)

The type or namespace name 'Coin' could not be found (are you missing a using directive or an assembly reference?

public class ScinControl : MonoBehaviour
{
public int skinNum;
public Button buyButton;
public Image iLock;
public int price;
private Coin Coin;

public Sprite buySkin;
public Sprite equipped;
public Sprite equip;
public Sprite falseLock;
public Sprite trueLock;

public Image[] skins;

private void Start()
{
if (PlayerPrefs.GetInt("scin1" + "buy") == 0)
{
foreach (Image img in skins)
{
if ("scin1" == img.name )
{
PlayerPrefs.SetInt("scin1" + "buy", 1);
PlayerPrefs.SetInt("scin1" + "equip", 1);
}
else
{
PlayerPrefs.SetInt(GetComponent<Image>().name + "buy", 0);
}
}
}
}

private void Update()
{
if (PlayerPrefs.GetInt(GetComponent<Image>().name + "buy") == 0)
{
iLock.GetComponent<Image>().sprite = falseLock;
buyButton.GetComponent<Image>().sprite = buySkin;
}
else if(PlayerPrefs.GetInt(GetComponent<Image>().name + "buy") == 1)
{
iLock.GetComponent<Image>().sprite = trueLock;
if (PlayerPrefs.GetInt(GetComponent<Image>().name + "equip") == 1)
{
buyButton.GetComponent<Image>().sprite = equipped;
}
else if (PlayerPrefs.GetInt(GetComponent<Image>().name + "equip") == 0)
{
buyButton.GetComponent<Image>().sprite = equip;
}
}
}
public void buy()
{
if(PlayerPrefs.GetInt(GetComponent<Image>().name + "buy") == 0) {
if (Coin.Coin >= price)
{

iLock.GetComponent<Image>().sprite = trueLock;
buyButton.GetComponent<Image>().sprite = equipped;
Coin.Coin -= price;

PlayerPrefs.SetInt(GetComponent<Image>().name + "buy", 1);
PlayerPrefs.SetInt("skinNum", skinNum);
PlayerPrefs.SetInt("Coin", Coin.Coin);

foreach(Image img in skins)
{
if (GetComponent<Image>().name == img.name )
{
PlayerPrefs.SetInt(GetComponent<Image>().name + "equip", 1);
}
else
{
PlayerPrefs.SetInt( img.name + "equip", 0);
The error message you're seeing indicates that the compiler couldn't find the definition of the 'Coin' class. There could be a few reasons for this issue:

1. Missing reference or using directive: Make sure you have the necessary using directive or assembly reference at the top of your code file to include the namespace or assembly where the 'Coin' class is defined.

2. Incorrect class name or namespace: Double-check that the 'Coin' class is correctly named and is in the expected namespace. Verify that the class is defined in a file that is part of your project and accessible to the current code file.

3. Typo or casing issue: Ensure that the spelling and casing of the 'Coin' class name match exactly where it is defined.

Reviewing your code, it seems that you have a private field called 'Coin,' but it's not clear where this class is defined or how it is related to the code snippet you provided. Please ensure that the 'Coin' class is properly defined and accessible within your code.
БИ
Боря И Оля Ап
3 078
Лучший ответ
Вижу в коде:
 private Coin Coin;  
По сути, здесь объявлено приватное поле типа Coin по имени Coin.

А есть ли у вас в проекте класс Coin, чтобы объявлять поля такого типа?
Если класса Coin нет, то в этом и проблема.