You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
902 B

using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class ColourSquareCollection : MonoBehaviour
{
public Texture colouredTexture;
public GameObject counterScore;
public GameObject colourCube;
public Color currentPlayerColour;
GameObject[] objs;
Renderer abc;
int counter = 0;
void Start(){
//have to first get colour from player, hard code purple in at the moment
colourCube.GetComponent<Image>().color = currentPlayerColour;
objs = GameObject.FindGameObjectsWithTag("Coloured");
counter = 1;
counterScore.GetComponent<TextMeshProUGUI>().text = counter.ToString();
}
public void colourupdatefromMove()
{
counter = 1;
foreach(GameObject a in objs){
abc = a.GetComponent<Renderer>();
if (abc.material.GetTexture("_Albedo") == colouredTexture)
{
counter++;
}
}
counterScore.GetComponent<TextMeshProUGUI>().text = counter.ToString();
}
}