C
C#2mo ago
RANI

yo im tied to make a game and there is problom

tile class using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UIElements; public class Tile : MonoBehaviour { public Tile state {get; private set;} public tillcell cell {get; private set;} public int number {get; private set; } private Image background; private TextMeshProUGUI text; private void Awake() { background = GetComponent<Image>(); text = GetComponent<TextMeshProUGUI>(); } public void Setstate(tilestate state , int number) { this.state = state; this.number = number; } } tilestates using System.Collections; using System.Collections.Generic; using UnityEngine; [CreateAssetMenu(menuName = "tile")] public class tilestate : ScriptableObject { public Color backroundcolor; public Color textColor; }
2 Replies
RANI
RANI2mo ago
problom is in public void Setstate(tilestate state , int number) { this.state = state; this.number = number; } and problom show Cannot implicitly convert type 'tilestate' to 'Tile'
iTunesIsEvil
iTunesIsEvil2mo ago
You're trying to set the state property, which you've defined as being of type Tile (public Tile state {get; private set;}), to the parameter state, but the parameter state is of type tilestate. I'm not familiar with those types, but since they're not the same (and apparently there's not an implicit cast available between Tile and tilestate), you can't assign the state parameter to the state property.