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.
 
 
 
 

39 lines
1001 B

using System.Collections;
using System.Collections.Generic;
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();
}
// Update is called once per frame
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();
}
}