I’m working on a card game and here it is my error and code can anyone help me?
**Error:**Assets\Scripts\ThisCard.cs(49,31): error CS0120: An object reference is required for the non-static field, method, or property 'PlayerDeck.deckSize
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class ThisCard : MonoBehaviour
{
public List<Card> thisCard = new List<Card>();
public int thisId;
public int id;
public string cardName;
public int cost;
public int power;
public string cardDescription;
public Text nameText;
public Text costText;
public Text powerText;
public Text descriptionText;
public Sprite thisSprite;
public Image thatImage;
public Image frame;
public bool cardBack;
public static bool staticCardBack; //
CardBack CardBackScript;
public GameObject Hand;
public int numberOfCardsInDeck;
// Start is called before the first frame update
void Start()
{
numberOfCardsInDeck = PlayerDeck.deckSize;
CardBackScript = GetComponent<CardBack>();
thisCard[0] = CardDatabase.cardList[thisId];
}
// Update is called once per frame
void Update()
{
id = thisCard[0].id;
cardName = thisCard[0].cardName;
cost = thisCard[0].cost;
power = thisCard[0].power;
cardDescription = thisCard[0].cardDescription;
thisSprite = thisCard[0].thisImage;
nameText.text = "" + cardName;
costText.text = "" + cost;
powerText.text = "" + power;
descriptionText.text = "" + cardDescription;
thatImage.sprite = thisSprite;
switch (thisCard[0].color)
{
case "Red":
frame.GetComponent<Image>().color = new Color32(255, 0, 0, 255);
break;
case "Blue":
frame.GetComponent<Image>().color = new Color32(0, 0, 255, 255);
break;
case "Brown":
frame.GetComponent<Image>().color = new Color32(153, 76, 0, 255);
break;
case "Yellow":
frame.GetComponent<Image>().color = new Color32(255, 255, 0, 255);
break;
default:
frame.GetComponent<Image>().color = new Color32(30, 30, 30, 255);
break;
}
staticCardBack = cardBack; //
//CardBackScript.UpdateCard(cardBack); //
}
}