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);
C/C++
CS0246 name 'Coin' could not be found (are you missing a using directive or an assembly reference?)
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.
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.
Вижу в коде:
А есть ли у вас в проекте класс Coin, чтобы объявлять поля такого типа?
Если класса Coin нет, то в этом и проблема.
private Coin Coin;
По сути, здесь объявлено приватное поле типа Coin по имени Coin.А есть ли у вас в проекте класс Coin, чтобы объявлять поля такого типа?
Если класса Coin нет, то в этом и проблема.
Похожие вопросы
- Что такое #include <iostream>, std using namespace std В языке программирования C++?
- C++, using, помогите пожалуйста
- Почему никто из программистов никогда не пишет using namespace std;? Все пишут например вот так:std::vector<int> v1(10);
- Программирование на С++.Комплексное число представляют парой действительных чисел (a,b).
- Помогите пожалуйста построить таблицу значений функции y = f(x) для x ∈ [a, b] с шагом h (с помощью условного оператора)
- Чем отличается переменная *a от простой a в C++?
- Подскажите, пожалуйста, что значит эта строка n+=l?a[--l]-'0':0 c++?
- Составьте программу удаления столбца, содержащего максимальный элемент матрицы A[N][N] НА ЯЗЫКЕ СИ
- Заданы натуральное число n и действительные числа a1, a2, …, an. Вычислить
- С++. Упорядочить строки массива A в порядке убывания сумм цифр первого элемента каждой строки.