- Home /
'SkinShopItem' is missing the class attribute 'ExtensionOfNativeClass'!
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class SkinShopitem: MonoBehaviour { int coins = 0;
public int cost;
public Sprite sprite;
[SerializeField] private SkinManager skinManager;
[SerializeField] private int skinIndex;
[SerializeField] private Button buyButton;
[SerializeField] private Text costText;
private Skin skin;
// Start is called before the first frame update
void Start()
{
skin = skinManager.skins[skinIndex];
GetComponent<Image>().sprite = skin.sprite;
if (skinManager.isUnlocked(skinIndex))
{
buyButton.gameObject.SetActive(false);
}
else
{
buyButton.gameObject.SetActive(true);
costText.text = skin.cost.ToString();
}
}
public void OnSkinPressed()
{
if (skinManager.isUnlocked(skinIndex))
{
skinManager.SelectSkin(skinIndex);
}
}
public void OnBuyButtonPressed()
{
coins = PlayerPrefs.GetInt("coins", coins - skin.cost);
if (coins >= skin.cost && !skinManager.isUnlocked(skinIndex))
{
PlayerPrefs.GetInt("coins", coins - skin.cost);
skinManager.Unlock(skinIndex);
buyButton.gameObject.SetActive(false);
skinManager.SelectSkin(skinIndex);
}
else
{
Debug.Log("Not enough coins :(");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Standalond built for Windows doesn't include text assets 0 Answers
The 3 mono scripts that come with the First Person Controller asset are missing! 1 Answer
Creating a Prefab and Keeping Original Objects Script Information 0 Answers
Checking to see if a Public transform is (missing) 1 Answer
Door Missing 1 Answer