at this link of tutorial there’s a section where i have to create a gaveover function like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameController : MonoBehaviour
{
private string playerSide;
public Text[] buttonlist;
void Awake()
{
SetGameContollerReferenceOnButtons();
playerSide = "X";
}
void SetGameContollerReferenceOnButtons ()
{
for (int i = 0; i < buttonlist.Length; i++)
{
buttonlist[i].GetComponentInParent<GridSpace>().SetGameControllerReference(this);
}
}
public string GetPlayerSide()
{
return playerSide;
}
public void EndTurn ()
{
if (buttonlist [0].text == playerSide &&
buttonlist [1].text == playerSide &&
buttonlist [2].text == playerSide)
{
GameOver();
}
}
void GameOver ()
{
for (int i = 0; i < buttonlist.Length; i++)
{
buttonlist[i].GetComponentInParent().interactable = false;
}
}
}
but
void GameOver ()
{
for (int i = 0; i < buttonlist.Length; i++)
{
buttonlist[i].GetComponentInParent().interactable = false;
}
}
or to be more specific GetComponentInParent() gives me an error in vs saying:
type arguement for method 'Component.GetComponentInParent() cannot be inferred from usage. try specifiying the type arguments specifically.
i did it by the text i don’t know where this error comes from or what it means. what should i do?